diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index c73eb8da2b4d..4fc6e5f7ecf2 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -392,6 +392,9 @@ linters: - "0C0C" embeddedstructfieldcheck: + # Checks that there is an empty space between the embedded fields and regular fields. + # Default: true + empty-line: false # Checks that sync.Mutex and sync.RWMutex are not used as embedded fields. # Default: false forbid-mutex: true diff --git a/go.mod b/go.mod index 3216900d3482..3db6a87608b5 100644 --- a/go.mod +++ b/go.mod @@ -76,7 +76,7 @@ require ( github.com/ldez/usetesting v0.5.0 github.com/leonklingele/grouper v1.1.2 github.com/macabu/inamedparam v0.2.0 - github.com/manuelarte/embeddedstructfieldcheck v0.3.0 + github.com/manuelarte/embeddedstructfieldcheck v0.4.0 github.com/manuelarte/funcorder v0.5.0 github.com/maratori/testableexamples v1.0.0 github.com/maratori/testpackage v1.1.1 diff --git a/go.sum b/go.sum index f2c8d2f8c99a..1615d6c43c7f 100644 --- a/go.sum +++ b/go.sum @@ -397,8 +397,8 @@ github.com/macabu/inamedparam v0.2.0 h1:VyPYpOc10nkhI2qeNUdh3Zket4fcZjEWe35poddB github.com/macabu/inamedparam v0.2.0/go.mod h1:+Pee9/YfGe5LJ62pYXqB89lJ+0k5bsR8Wgz/C0Zlq3U= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/manuelarte/embeddedstructfieldcheck v0.3.0 h1:VhGqK8gANDvFYDxQkjPbv7/gDJtsGU9k6qj/hC2hgso= -github.com/manuelarte/embeddedstructfieldcheck v0.3.0/go.mod h1:LSo/IQpPfx1dXMcX4ibZCYA7Yy6ayZHIaOGM70+1Wy8= +github.com/manuelarte/embeddedstructfieldcheck v0.4.0 h1:3mAIyaGRtjK6EO9E73JlXLtiy7ha80b2ZVGyacxgfww= +github.com/manuelarte/embeddedstructfieldcheck v0.4.0/go.mod h1:z8dFSyXqp+fC6NLDSljRJeNQJJDWnY7RoWFzV3PC6UM= github.com/manuelarte/funcorder v0.5.0 h1:llMuHXXbg7tD0i/LNw8vGnkDTHFpTnWqKPI85Rknc+8= github.com/manuelarte/funcorder v0.5.0/go.mod h1:Yt3CiUQthSBMBxjShjdXMexmzpP8YGvGLjrxJNkO2hA= github.com/maratori/testableexamples v1.0.0 h1:dU5alXRrD8WKSjOUnmJZuzdxWOEQ57+7s93SLMxb2vI= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 67cd80a55e98..475ab5bcd920 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -1126,6 +1126,11 @@ "type": "object", "additionalProperties": false, "properties": { + "empty-line": { + "description": "Checks that there is an empty space between the embedded fields and regular fields.", + "type": "boolean", + "default": false + }, "forbid-mutex": { "description": "Checks that sync.Mutex and sync.RWMutex are not used as embedded fields.", "type": "boolean", diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 9394f89ba5f6..d0833f15b41b 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -24,6 +24,9 @@ var defaultLintersSettings = LintersSettings{ Dupl: DuplSettings{ Threshold: 150, }, + EmbeddedStructFieldCheck: EmbeddedStructFieldCheckSettings{ + EmptyLine: true, + }, ErrorLint: ErrorLintSettings{ Errorf: true, ErrorfMulti: true, @@ -380,6 +383,7 @@ type DupWordSettings struct { type EmbeddedStructFieldCheckSettings struct { ForbidMutex bool `mapstructure:"forbid-mutex"` + EmptyLine bool `mapstructure:"empty-line"` } type ErrcheckSettings struct { diff --git a/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go b/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go index c9df5038c064..ba4c06eb7c8f 100644 --- a/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go +++ b/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go @@ -12,7 +12,8 @@ func New(settings *config.EmbeddedStructFieldCheckSettings) *goanalysis.Linter { if settings != nil { cfg = map[string]any{ - analyzer.ForbidMutexName: settings.ForbidMutex, + analyzer.ForbidMutexCheck: settings.ForbidMutex, + analyzer.EmptyLineCheck: settings.EmptyLine, } }