Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: update implementation
  • Loading branch information
ldez committed May 18, 2025
commit 8f82c8dfcb8fe6c648b2f9d2dca04a6dd355d41b
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
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)
}
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