Skip to content

Commit 8e38a6e

Browse files
build(deps): bump github.com/manuelarte/embeddedstructfieldcheck from 0.2.1 to 0.3.0 (#5811)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
1 parent 58036dd commit 8e38a6e

12 files changed

+155
-86
lines changed

.golangci.next.reference.yml

+5
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,11 @@ linters:
385385
ignore:
386386
- "0C0C"
387387

388+
embeddedstructfieldcheck:
389+
# Checks that sync.Mutex and sync.RWMutex are not used as embedded fields.
390+
# Default: false
391+
forbid-mutex: true
392+
388393
errcheck:
389394
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
390395
# Such cases aren't reported by default.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ require (
7474
github.com/ldez/usetesting v0.4.3
7575
github.com/leonklingele/grouper v1.1.2
7676
github.com/macabu/inamedparam v0.2.0
77-
github.com/manuelarte/embeddedstructfieldcheck v0.2.1
77+
github.com/manuelarte/embeddedstructfieldcheck v0.3.0
7878
github.com/manuelarte/funcorder v0.5.0
7979
github.com/maratori/testableexamples v1.0.0
8080
github.com/maratori/testpackage v1.1.1

go.sum

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonschema/golangci.next.jsonschema.json

+14
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,17 @@
10891089
}
10901090
}
10911091
},
1092+
"embeddedstructfieldcheckSettings": {
1093+
"type": "object",
1094+
"additionalProperties": false,
1095+
"properties": {
1096+
"forbid-mutex": {
1097+
"description": "Checks that sync.Mutex and sync.RWMutex are not used as embedded fields.",
1098+
"type": "boolean",
1099+
"default": false
1100+
}
1101+
}
1102+
},
10921103
"errcheckSettings": {
10931104
"type": "object",
10941105
"additionalProperties": false,
@@ -4356,6 +4367,9 @@
43564367
"dupl": {
43574368
"$ref": "#/definitions/settings/definitions/duplSettings"
43584369
},
4370+
"embeddedstructfieldcheck": {
4371+
"$ref": "#/definitions/settings/definitions/embeddedstructfieldcheckSettings"
4372+
},
43594373
"errcheck": {
43604374
"$ref": "#/definitions/settings/definitions/errcheckSettings"
43614375
},

pkg/config/linters_settings.go

+83-78
Original file line numberDiff line numberDiff line change
@@ -205,84 +205,85 @@ var defaultLintersSettings = LintersSettings{
205205
type LintersSettings struct {
206206
FormatterSettings `mapstructure:"-"`
207207

208-
Asasalint AsasalintSettings `mapstructure:"asasalint"`
209-
BiDiChk BiDiChkSettings `mapstructure:"bidichk"`
210-
CopyLoopVar CopyLoopVarSettings `mapstructure:"copyloopvar"`
211-
Cyclop CyclopSettings `mapstructure:"cyclop"`
212-
Decorder DecorderSettings `mapstructure:"decorder"`
213-
Depguard DepGuardSettings `mapstructure:"depguard"`
214-
Dogsled DogsledSettings `mapstructure:"dogsled"`
215-
Dupl DuplSettings `mapstructure:"dupl"`
216-
DupWord DupWordSettings `mapstructure:"dupword"`
217-
Errcheck ErrcheckSettings `mapstructure:"errcheck"`
218-
ErrChkJSON ErrChkJSONSettings `mapstructure:"errchkjson"`
219-
ErrorLint ErrorLintSettings `mapstructure:"errorlint"`
220-
Exhaustive ExhaustiveSettings `mapstructure:"exhaustive"`
221-
Exhaustruct ExhaustructSettings `mapstructure:"exhaustruct"`
222-
Fatcontext FatcontextSettings `mapstructure:"fatcontext"`
223-
Forbidigo ForbidigoSettings `mapstructure:"forbidigo"`
224-
FuncOrder FuncOrderSettings `mapstructure:"funcorder"`
225-
Funlen FunlenSettings `mapstructure:"funlen"`
226-
GinkgoLinter GinkgoLinterSettings `mapstructure:"ginkgolinter"`
227-
Gocognit GocognitSettings `mapstructure:"gocognit"`
228-
GoChecksumType GoChecksumTypeSettings `mapstructure:"gochecksumtype"`
229-
Goconst GoConstSettings `mapstructure:"goconst"`
230-
Gocritic GoCriticSettings `mapstructure:"gocritic"`
231-
Gocyclo GoCycloSettings `mapstructure:"gocyclo"`
232-
Godot GodotSettings `mapstructure:"godot"`
233-
Godox GodoxSettings `mapstructure:"godox"`
234-
Goheader GoHeaderSettings `mapstructure:"goheader"`
235-
GoModDirectives GoModDirectivesSettings `mapstructure:"gomoddirectives"`
236-
Gomodguard GoModGuardSettings `mapstructure:"gomodguard"`
237-
Gosec GoSecSettings `mapstructure:"gosec"`
238-
Gosmopolitan GosmopolitanSettings `mapstructure:"gosmopolitan"`
239-
Govet GovetSettings `mapstructure:"govet"`
240-
Grouper GrouperSettings `mapstructure:"grouper"`
241-
Iface IfaceSettings `mapstructure:"iface"`
242-
ImportAs ImportAsSettings `mapstructure:"importas"`
243-
Inamedparam INamedParamSettings `mapstructure:"inamedparam"`
244-
InterfaceBloat InterfaceBloatSettings `mapstructure:"interfacebloat"`
245-
Ireturn IreturnSettings `mapstructure:"ireturn"`
246-
Lll LllSettings `mapstructure:"lll"`
247-
LoggerCheck LoggerCheckSettings `mapstructure:"loggercheck"`
248-
MaintIdx MaintIdxSettings `mapstructure:"maintidx"`
249-
Makezero MakezeroSettings `mapstructure:"makezero"`
250-
Misspell MisspellSettings `mapstructure:"misspell"`
251-
Mnd MndSettings `mapstructure:"mnd"`
252-
MustTag MustTagSettings `mapstructure:"musttag"`
253-
Nakedret NakedretSettings `mapstructure:"nakedret"`
254-
Nestif NestifSettings `mapstructure:"nestif"`
255-
NilNil NilNilSettings `mapstructure:"nilnil"`
256-
Nlreturn NlreturnSettings `mapstructure:"nlreturn"`
257-
NoLintLint NoLintLintSettings `mapstructure:"nolintlint"`
258-
NoNamedReturns NoNamedReturnsSettings `mapstructure:"nonamedreturns"`
259-
ParallelTest ParallelTestSettings `mapstructure:"paralleltest"`
260-
PerfSprint PerfSprintSettings `mapstructure:"perfsprint"`
261-
Prealloc PreallocSettings `mapstructure:"prealloc"`
262-
Predeclared PredeclaredSettings `mapstructure:"predeclared"`
263-
Promlinter PromlinterSettings `mapstructure:"promlinter"`
264-
ProtoGetter ProtoGetterSettings `mapstructure:"protogetter"`
265-
Reassign ReassignSettings `mapstructure:"reassign"`
266-
Recvcheck RecvcheckSettings `mapstructure:"recvcheck"`
267-
Revive ReviveSettings `mapstructure:"revive"`
268-
RowsErrCheck RowsErrCheckSettings `mapstructure:"rowserrcheck"`
269-
SlogLint SlogLintSettings `mapstructure:"sloglint"`
270-
Spancheck SpancheckSettings `mapstructure:"spancheck"`
271-
Staticcheck StaticCheckSettings `mapstructure:"staticcheck"`
272-
TagAlign TagAlignSettings `mapstructure:"tagalign"`
273-
Tagliatelle TagliatelleSettings `mapstructure:"tagliatelle"`
274-
Testifylint TestifylintSettings `mapstructure:"testifylint"`
275-
Testpackage TestpackageSettings `mapstructure:"testpackage"`
276-
Thelper ThelperSettings `mapstructure:"thelper"`
277-
Unconvert UnconvertSettings `mapstructure:"unconvert"`
278-
Unparam UnparamSettings `mapstructure:"unparam"`
279-
Unused UnusedSettings `mapstructure:"unused"`
280-
UseStdlibVars UseStdlibVarsSettings `mapstructure:"usestdlibvars"`
281-
UseTesting UseTestingSettings `mapstructure:"usetesting"`
282-
Varnamelen VarnamelenSettings `mapstructure:"varnamelen"`
283-
Whitespace WhitespaceSettings `mapstructure:"whitespace"`
284-
Wrapcheck WrapcheckSettings `mapstructure:"wrapcheck"`
285-
WSL WSLSettings `mapstructure:"wsl"`
208+
Asasalint AsasalintSettings `mapstructure:"asasalint"`
209+
BiDiChk BiDiChkSettings `mapstructure:"bidichk"`
210+
CopyLoopVar CopyLoopVarSettings `mapstructure:"copyloopvar"`
211+
Cyclop CyclopSettings `mapstructure:"cyclop"`
212+
Decorder DecorderSettings `mapstructure:"decorder"`
213+
Depguard DepGuardSettings `mapstructure:"depguard"`
214+
Dogsled DogsledSettings `mapstructure:"dogsled"`
215+
Dupl DuplSettings `mapstructure:"dupl"`
216+
DupWord DupWordSettings `mapstructure:"dupword"`
217+
EmbeddedStructFieldCheck EmbeddedStructFieldCheckSettings `mapstructure:"embeddedstructfieldcheck"`
218+
Errcheck ErrcheckSettings `mapstructure:"errcheck"`
219+
ErrChkJSON ErrChkJSONSettings `mapstructure:"errchkjson"`
220+
ErrorLint ErrorLintSettings `mapstructure:"errorlint"`
221+
Exhaustive ExhaustiveSettings `mapstructure:"exhaustive"`
222+
Exhaustruct ExhaustructSettings `mapstructure:"exhaustruct"`
223+
Fatcontext FatcontextSettings `mapstructure:"fatcontext"`
224+
Forbidigo ForbidigoSettings `mapstructure:"forbidigo"`
225+
FuncOrder FuncOrderSettings `mapstructure:"funcorder"`
226+
Funlen FunlenSettings `mapstructure:"funlen"`
227+
GinkgoLinter GinkgoLinterSettings `mapstructure:"ginkgolinter"`
228+
Gocognit GocognitSettings `mapstructure:"gocognit"`
229+
GoChecksumType GoChecksumTypeSettings `mapstructure:"gochecksumtype"`
230+
Goconst GoConstSettings `mapstructure:"goconst"`
231+
Gocritic GoCriticSettings `mapstructure:"gocritic"`
232+
Gocyclo GoCycloSettings `mapstructure:"gocyclo"`
233+
Godot GodotSettings `mapstructure:"godot"`
234+
Godox GodoxSettings `mapstructure:"godox"`
235+
Goheader GoHeaderSettings `mapstructure:"goheader"`
236+
GoModDirectives GoModDirectivesSettings `mapstructure:"gomoddirectives"`
237+
Gomodguard GoModGuardSettings `mapstructure:"gomodguard"`
238+
Gosec GoSecSettings `mapstructure:"gosec"`
239+
Gosmopolitan GosmopolitanSettings `mapstructure:"gosmopolitan"`
240+
Govet GovetSettings `mapstructure:"govet"`
241+
Grouper GrouperSettings `mapstructure:"grouper"`
242+
Iface IfaceSettings `mapstructure:"iface"`
243+
ImportAs ImportAsSettings `mapstructure:"importas"`
244+
Inamedparam INamedParamSettings `mapstructure:"inamedparam"`
245+
InterfaceBloat InterfaceBloatSettings `mapstructure:"interfacebloat"`
246+
Ireturn IreturnSettings `mapstructure:"ireturn"`
247+
Lll LllSettings `mapstructure:"lll"`
248+
LoggerCheck LoggerCheckSettings `mapstructure:"loggercheck"`
249+
MaintIdx MaintIdxSettings `mapstructure:"maintidx"`
250+
Makezero MakezeroSettings `mapstructure:"makezero"`
251+
Misspell MisspellSettings `mapstructure:"misspell"`
252+
Mnd MndSettings `mapstructure:"mnd"`
253+
MustTag MustTagSettings `mapstructure:"musttag"`
254+
Nakedret NakedretSettings `mapstructure:"nakedret"`
255+
Nestif NestifSettings `mapstructure:"nestif"`
256+
NilNil NilNilSettings `mapstructure:"nilnil"`
257+
Nlreturn NlreturnSettings `mapstructure:"nlreturn"`
258+
NoLintLint NoLintLintSettings `mapstructure:"nolintlint"`
259+
NoNamedReturns NoNamedReturnsSettings `mapstructure:"nonamedreturns"`
260+
ParallelTest ParallelTestSettings `mapstructure:"paralleltest"`
261+
PerfSprint PerfSprintSettings `mapstructure:"perfsprint"`
262+
Prealloc PreallocSettings `mapstructure:"prealloc"`
263+
Predeclared PredeclaredSettings `mapstructure:"predeclared"`
264+
Promlinter PromlinterSettings `mapstructure:"promlinter"`
265+
ProtoGetter ProtoGetterSettings `mapstructure:"protogetter"`
266+
Reassign ReassignSettings `mapstructure:"reassign"`
267+
Recvcheck RecvcheckSettings `mapstructure:"recvcheck"`
268+
Revive ReviveSettings `mapstructure:"revive"`
269+
RowsErrCheck RowsErrCheckSettings `mapstructure:"rowserrcheck"`
270+
SlogLint SlogLintSettings `mapstructure:"sloglint"`
271+
Spancheck SpancheckSettings `mapstructure:"spancheck"`
272+
Staticcheck StaticCheckSettings `mapstructure:"staticcheck"`
273+
TagAlign TagAlignSettings `mapstructure:"tagalign"`
274+
Tagliatelle TagliatelleSettings `mapstructure:"tagliatelle"`
275+
Testifylint TestifylintSettings `mapstructure:"testifylint"`
276+
Testpackage TestpackageSettings `mapstructure:"testpackage"`
277+
Thelper ThelperSettings `mapstructure:"thelper"`
278+
Unconvert UnconvertSettings `mapstructure:"unconvert"`
279+
Unparam UnparamSettings `mapstructure:"unparam"`
280+
Unused UnusedSettings `mapstructure:"unused"`
281+
UseStdlibVars UseStdlibVarsSettings `mapstructure:"usestdlibvars"`
282+
UseTesting UseTestingSettings `mapstructure:"usetesting"`
283+
Varnamelen VarnamelenSettings `mapstructure:"varnamelen"`
284+
Whitespace WhitespaceSettings `mapstructure:"whitespace"`
285+
Wrapcheck WrapcheckSettings `mapstructure:"wrapcheck"`
286+
WSL WSLSettings `mapstructure:"wsl"`
286287

287288
Custom map[string]CustomLinterSettings `mapstructure:"custom"`
288289
}
@@ -367,6 +368,10 @@ type DupWordSettings struct {
367368
Ignore []string `mapstructure:"ignore"`
368369
}
369370

371+
type EmbeddedStructFieldCheckSettings struct {
372+
ForbidMutex bool `mapstructure:"forbid-mutex"`
373+
}
374+
370375
type ErrcheckSettings struct {
371376
DisableDefaultExclusions bool `mapstructure:"disable-default-exclusions"`
372377
CheckTypeAssertions bool `mapstructure:"check-type-assertions"`

pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,21 @@ package embeddedstructfieldcheck
33
import (
44
"github.com/manuelarte/embeddedstructfieldcheck/analyzer"
55

6+
"github.com/golangci/golangci-lint/v2/pkg/config"
67
"github.com/golangci/golangci-lint/v2/pkg/goanalysis"
78
)
89

9-
func New() *goanalysis.Linter {
10+
func New(settings *config.EmbeddedStructFieldCheckSettings) *goanalysis.Linter {
11+
var cfg map[string]any
12+
13+
if settings != nil {
14+
cfg = map[string]any{
15+
analyzer.ForbidMutexName: settings.ForbidMutex,
16+
}
17+
}
18+
1019
return goanalysis.
1120
NewLinterFromAnalyzer(analyzer.NewAnalyzer()).
21+
WithConfig(cfg).
1222
WithLoadMode(goanalysis.LoadModeSyntax)
1323
}

pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_comments.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Eembeddedstructfieldcheck
2-
package simple
2+
package testdata
33

44
import "time"
55

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//golangcitest:args -Eembeddedstructfieldcheck
2+
//golangcitest:config_path testdata/embeddedstructfieldcheck_mutex.yml
3+
package testdata
4+
5+
import "sync"
6+
7+
type MutextEmbedded struct {
8+
sync.Mutex // want `sync.Mutex should not be embedded`
9+
}
10+
11+
type MutextNotEmbedded struct {
12+
mu sync.Mutex
13+
}
14+
15+
type PointerMutextEmbedded struct {
16+
*sync.Mutex // want `sync.Mutex should not be embedded`
17+
}
18+
19+
type RWMutextEmbedded struct {
20+
sync.RWMutex // want `sync.RWMutex should not be embedded`
21+
}
22+
23+
type RWMutextNotEmbedded struct {
24+
mu sync.RWMutex
25+
}
26+
27+
type PointerRWMutextEmbedded struct {
28+
*sync.RWMutex // want `sync.RWMutex should not be embedded`
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: "2"
2+
3+
linters:
4+
settings:
5+
embeddedstructfieldcheck:
6+
forbid-mutex: true

pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_simple.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Eembeddedstructfieldcheck
2-
package simple
2+
package testdata
33

44
import (
55
"context"

pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_special_cases.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Eembeddedstructfieldcheck
2-
package simple
2+
package testdata
33

44
import "time"
55

pkg/lint/lintersdb/builder_linter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
213213
WithLoadForGoAnalysis().
214214
WithURL("https://github.com/charithe/durationcheck"),
215215

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

0 commit comments

Comments
 (0)