Skip to content

build(deps): bump github.com/manuelarte/embeddedstructfieldcheck from 0.2.1 to 0.3.0 #5811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ linters:
ignore:
- "0C0C"

embeddedstructfieldcheck:
# Checks that sync.Mutex and sync.RWMutex are not used as embedded fields.
# Default: false
forbid-mutex: true

errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ require (
github.com/ldez/usetesting v0.4.3
github.com/leonklingele/grouper v1.1.2
github.com/macabu/inamedparam v0.2.0
github.com/manuelarte/embeddedstructfieldcheck v0.2.1
github.com/manuelarte/embeddedstructfieldcheck v0.3.0
github.com/manuelarte/funcorder v0.5.0
github.com/maratori/testableexamples v1.0.0
github.com/maratori/testpackage v1.1.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,17 @@
}
}
},
"embeddedstructfieldcheckSettings": {
"type": "object",
"additionalProperties": false,
"properties": {
"forbid-mutex": {
"description": "Checks that sync.Mutex and sync.RWMutex are not used as embedded fields.",
"type": "boolean",
"default": false
}
}
},
"errcheckSettings": {
"type": "object",
"additionalProperties": false,
Expand Down Expand Up @@ -4356,6 +4367,9 @@
"dupl": {
"$ref": "#/definitions/settings/definitions/duplSettings"
},
"embeddedstructfieldcheck": {
"$ref": "#/definitions/settings/definitions/embeddedstructfieldcheckSettings"
},
"errcheck": {
"$ref": "#/definitions/settings/definitions/errcheckSettings"
},
Expand Down
161 changes: 83 additions & 78 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,84 +205,85 @@ var defaultLintersSettings = LintersSettings{
type LintersSettings struct {
FormatterSettings `mapstructure:"-"`

Asasalint AsasalintSettings `mapstructure:"asasalint"`
BiDiChk BiDiChkSettings `mapstructure:"bidichk"`
CopyLoopVar CopyLoopVarSettings `mapstructure:"copyloopvar"`
Cyclop CyclopSettings `mapstructure:"cyclop"`
Decorder DecorderSettings `mapstructure:"decorder"`
Depguard DepGuardSettings `mapstructure:"depguard"`
Dogsled DogsledSettings `mapstructure:"dogsled"`
Dupl DuplSettings `mapstructure:"dupl"`
DupWord DupWordSettings `mapstructure:"dupword"`
Errcheck ErrcheckSettings `mapstructure:"errcheck"`
ErrChkJSON ErrChkJSONSettings `mapstructure:"errchkjson"`
ErrorLint ErrorLintSettings `mapstructure:"errorlint"`
Exhaustive ExhaustiveSettings `mapstructure:"exhaustive"`
Exhaustruct ExhaustructSettings `mapstructure:"exhaustruct"`
Fatcontext FatcontextSettings `mapstructure:"fatcontext"`
Forbidigo ForbidigoSettings `mapstructure:"forbidigo"`
FuncOrder FuncOrderSettings `mapstructure:"funcorder"`
Funlen FunlenSettings `mapstructure:"funlen"`
GinkgoLinter GinkgoLinterSettings `mapstructure:"ginkgolinter"`
Gocognit GocognitSettings `mapstructure:"gocognit"`
GoChecksumType GoChecksumTypeSettings `mapstructure:"gochecksumtype"`
Goconst GoConstSettings `mapstructure:"goconst"`
Gocritic GoCriticSettings `mapstructure:"gocritic"`
Gocyclo GoCycloSettings `mapstructure:"gocyclo"`
Godot GodotSettings `mapstructure:"godot"`
Godox GodoxSettings `mapstructure:"godox"`
Goheader GoHeaderSettings `mapstructure:"goheader"`
GoModDirectives GoModDirectivesSettings `mapstructure:"gomoddirectives"`
Gomodguard GoModGuardSettings `mapstructure:"gomodguard"`
Gosec GoSecSettings `mapstructure:"gosec"`
Gosmopolitan GosmopolitanSettings `mapstructure:"gosmopolitan"`
Govet GovetSettings `mapstructure:"govet"`
Grouper GrouperSettings `mapstructure:"grouper"`
Iface IfaceSettings `mapstructure:"iface"`
ImportAs ImportAsSettings `mapstructure:"importas"`
Inamedparam INamedParamSettings `mapstructure:"inamedparam"`
InterfaceBloat InterfaceBloatSettings `mapstructure:"interfacebloat"`
Ireturn IreturnSettings `mapstructure:"ireturn"`
Lll LllSettings `mapstructure:"lll"`
LoggerCheck LoggerCheckSettings `mapstructure:"loggercheck"`
MaintIdx MaintIdxSettings `mapstructure:"maintidx"`
Makezero MakezeroSettings `mapstructure:"makezero"`
Misspell MisspellSettings `mapstructure:"misspell"`
Mnd MndSettings `mapstructure:"mnd"`
MustTag MustTagSettings `mapstructure:"musttag"`
Nakedret NakedretSettings `mapstructure:"nakedret"`
Nestif NestifSettings `mapstructure:"nestif"`
NilNil NilNilSettings `mapstructure:"nilnil"`
Nlreturn NlreturnSettings `mapstructure:"nlreturn"`
NoLintLint NoLintLintSettings `mapstructure:"nolintlint"`
NoNamedReturns NoNamedReturnsSettings `mapstructure:"nonamedreturns"`
ParallelTest ParallelTestSettings `mapstructure:"paralleltest"`
PerfSprint PerfSprintSettings `mapstructure:"perfsprint"`
Prealloc PreallocSettings `mapstructure:"prealloc"`
Predeclared PredeclaredSettings `mapstructure:"predeclared"`
Promlinter PromlinterSettings `mapstructure:"promlinter"`
ProtoGetter ProtoGetterSettings `mapstructure:"protogetter"`
Reassign ReassignSettings `mapstructure:"reassign"`
Recvcheck RecvcheckSettings `mapstructure:"recvcheck"`
Revive ReviveSettings `mapstructure:"revive"`
RowsErrCheck RowsErrCheckSettings `mapstructure:"rowserrcheck"`
SlogLint SlogLintSettings `mapstructure:"sloglint"`
Spancheck SpancheckSettings `mapstructure:"spancheck"`
Staticcheck StaticCheckSettings `mapstructure:"staticcheck"`
TagAlign TagAlignSettings `mapstructure:"tagalign"`
Tagliatelle TagliatelleSettings `mapstructure:"tagliatelle"`
Testifylint TestifylintSettings `mapstructure:"testifylint"`
Testpackage TestpackageSettings `mapstructure:"testpackage"`
Thelper ThelperSettings `mapstructure:"thelper"`
Unconvert UnconvertSettings `mapstructure:"unconvert"`
Unparam UnparamSettings `mapstructure:"unparam"`
Unused UnusedSettings `mapstructure:"unused"`
UseStdlibVars UseStdlibVarsSettings `mapstructure:"usestdlibvars"`
UseTesting UseTestingSettings `mapstructure:"usetesting"`
Varnamelen VarnamelenSettings `mapstructure:"varnamelen"`
Whitespace WhitespaceSettings `mapstructure:"whitespace"`
Wrapcheck WrapcheckSettings `mapstructure:"wrapcheck"`
WSL WSLSettings `mapstructure:"wsl"`
Asasalint AsasalintSettings `mapstructure:"asasalint"`
BiDiChk BiDiChkSettings `mapstructure:"bidichk"`
CopyLoopVar CopyLoopVarSettings `mapstructure:"copyloopvar"`
Cyclop CyclopSettings `mapstructure:"cyclop"`
Decorder DecorderSettings `mapstructure:"decorder"`
Depguard DepGuardSettings `mapstructure:"depguard"`
Dogsled DogsledSettings `mapstructure:"dogsled"`
Dupl DuplSettings `mapstructure:"dupl"`
DupWord DupWordSettings `mapstructure:"dupword"`
EmbeddedStructFieldCheck EmbeddedStructFieldCheckSettings `mapstructure:"embeddedstructfieldcheck"`
Errcheck ErrcheckSettings `mapstructure:"errcheck"`
ErrChkJSON ErrChkJSONSettings `mapstructure:"errchkjson"`
ErrorLint ErrorLintSettings `mapstructure:"errorlint"`
Exhaustive ExhaustiveSettings `mapstructure:"exhaustive"`
Exhaustruct ExhaustructSettings `mapstructure:"exhaustruct"`
Fatcontext FatcontextSettings `mapstructure:"fatcontext"`
Forbidigo ForbidigoSettings `mapstructure:"forbidigo"`
FuncOrder FuncOrderSettings `mapstructure:"funcorder"`
Funlen FunlenSettings `mapstructure:"funlen"`
GinkgoLinter GinkgoLinterSettings `mapstructure:"ginkgolinter"`
Gocognit GocognitSettings `mapstructure:"gocognit"`
GoChecksumType GoChecksumTypeSettings `mapstructure:"gochecksumtype"`
Goconst GoConstSettings `mapstructure:"goconst"`
Gocritic GoCriticSettings `mapstructure:"gocritic"`
Gocyclo GoCycloSettings `mapstructure:"gocyclo"`
Godot GodotSettings `mapstructure:"godot"`
Godox GodoxSettings `mapstructure:"godox"`
Goheader GoHeaderSettings `mapstructure:"goheader"`
GoModDirectives GoModDirectivesSettings `mapstructure:"gomoddirectives"`
Gomodguard GoModGuardSettings `mapstructure:"gomodguard"`
Gosec GoSecSettings `mapstructure:"gosec"`
Gosmopolitan GosmopolitanSettings `mapstructure:"gosmopolitan"`
Govet GovetSettings `mapstructure:"govet"`
Grouper GrouperSettings `mapstructure:"grouper"`
Iface IfaceSettings `mapstructure:"iface"`
ImportAs ImportAsSettings `mapstructure:"importas"`
Inamedparam INamedParamSettings `mapstructure:"inamedparam"`
InterfaceBloat InterfaceBloatSettings `mapstructure:"interfacebloat"`
Ireturn IreturnSettings `mapstructure:"ireturn"`
Lll LllSettings `mapstructure:"lll"`
LoggerCheck LoggerCheckSettings `mapstructure:"loggercheck"`
MaintIdx MaintIdxSettings `mapstructure:"maintidx"`
Makezero MakezeroSettings `mapstructure:"makezero"`
Misspell MisspellSettings `mapstructure:"misspell"`
Mnd MndSettings `mapstructure:"mnd"`
MustTag MustTagSettings `mapstructure:"musttag"`
Nakedret NakedretSettings `mapstructure:"nakedret"`
Nestif NestifSettings `mapstructure:"nestif"`
NilNil NilNilSettings `mapstructure:"nilnil"`
Nlreturn NlreturnSettings `mapstructure:"nlreturn"`
NoLintLint NoLintLintSettings `mapstructure:"nolintlint"`
NoNamedReturns NoNamedReturnsSettings `mapstructure:"nonamedreturns"`
ParallelTest ParallelTestSettings `mapstructure:"paralleltest"`
PerfSprint PerfSprintSettings `mapstructure:"perfsprint"`
Prealloc PreallocSettings `mapstructure:"prealloc"`
Predeclared PredeclaredSettings `mapstructure:"predeclared"`
Promlinter PromlinterSettings `mapstructure:"promlinter"`
ProtoGetter ProtoGetterSettings `mapstructure:"protogetter"`
Reassign ReassignSettings `mapstructure:"reassign"`
Recvcheck RecvcheckSettings `mapstructure:"recvcheck"`
Revive ReviveSettings `mapstructure:"revive"`
RowsErrCheck RowsErrCheckSettings `mapstructure:"rowserrcheck"`
SlogLint SlogLintSettings `mapstructure:"sloglint"`
Spancheck SpancheckSettings `mapstructure:"spancheck"`
Staticcheck StaticCheckSettings `mapstructure:"staticcheck"`
TagAlign TagAlignSettings `mapstructure:"tagalign"`
Tagliatelle TagliatelleSettings `mapstructure:"tagliatelle"`
Testifylint TestifylintSettings `mapstructure:"testifylint"`
Testpackage TestpackageSettings `mapstructure:"testpackage"`
Thelper ThelperSettings `mapstructure:"thelper"`
Unconvert UnconvertSettings `mapstructure:"unconvert"`
Unparam UnparamSettings `mapstructure:"unparam"`
Unused UnusedSettings `mapstructure:"unused"`
UseStdlibVars UseStdlibVarsSettings `mapstructure:"usestdlibvars"`
UseTesting UseTestingSettings `mapstructure:"usetesting"`
Varnamelen VarnamelenSettings `mapstructure:"varnamelen"`
Whitespace WhitespaceSettings `mapstructure:"whitespace"`
Wrapcheck WrapcheckSettings `mapstructure:"wrapcheck"`
WSL WSLSettings `mapstructure:"wsl"`

Custom map[string]CustomLinterSettings `mapstructure:"custom"`
}
Expand Down Expand Up @@ -367,6 +368,10 @@ type DupWordSettings struct {
Ignore []string `mapstructure:"ignore"`
}

type EmbeddedStructFieldCheckSettings struct {
ForbidMutex bool `mapstructure:"forbid-mutex"`
}

type ErrcheckSettings struct {
DisableDefaultExclusions bool `mapstructure:"disable-default-exclusions"`
CheckTypeAssertions bool `mapstructure:"check-type-assertions"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ package embeddedstructfieldcheck
import (
"github.com/manuelarte/embeddedstructfieldcheck/analyzer"

"github.com/golangci/golangci-lint/v2/pkg/config"
"github.com/golangci/golangci-lint/v2/pkg/goanalysis"
)

func New() *goanalysis.Linter {
func New(settings *config.EmbeddedStructFieldCheckSettings) *goanalysis.Linter {
var cfg map[string]any

if settings != nil {
cfg = map[string]any{
analyzer.ForbidMutexName: settings.ForbidMutex,
}
}

return goanalysis.
NewLinterFromAnalyzer(analyzer.NewAnalyzer()).
WithConfig(cfg).
WithLoadMode(goanalysis.LoadModeSyntax)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//golangcitest:args -Eembeddedstructfieldcheck
package simple
package testdata

import "time"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//golangcitest:args -Eembeddedstructfieldcheck
//golangcitest:config_path testdata/embeddedstructfieldcheck_mutex.yml
package testdata

import "sync"

type MutextEmbedded struct {
sync.Mutex // want `sync.Mutex should not be embedded`
}

type MutextNotEmbedded struct {
mu sync.Mutex
}

type PointerMutextEmbedded struct {
*sync.Mutex // want `sync.Mutex should not be embedded`
}

type RWMutextEmbedded struct {
sync.RWMutex // want `sync.RWMutex should not be embedded`
}

type RWMutextNotEmbedded struct {
mu sync.RWMutex
}

type PointerRWMutextEmbedded struct {
*sync.RWMutex // want `sync.RWMutex should not be embedded`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "2"

linters:
settings:
embeddedstructfieldcheck:
forbid-mutex: true
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//golangcitest:args -Eembeddedstructfieldcheck
package simple
package testdata

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//golangcitest:args -Eembeddedstructfieldcheck
package simple
package testdata

import "time"

Expand Down
2 changes: 1 addition & 1 deletion pkg/lint/lintersdb/builder_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithLoadForGoAnalysis().
WithURL("https://github.com/charithe/durationcheck"),

linter.NewConfig(embeddedstructfieldcheck.New()).
linter.NewConfig(embeddedstructfieldcheck.New(&cfg.Linters.Settings.EmbeddedStructFieldCheck)).
WithSince("v2.2.0").
WithURL("https://github.com/manuelarte/embeddedstructfieldcheck"),

Expand Down
Loading