Skip to content

Commit 044ef20

Browse files
committed
chore: update implementation
1 parent ceb4f0f commit 044ef20

File tree

5 files changed

+52
-3
lines changed

5 files changed

+52
-3
lines changed

.golangci.next.reference.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,6 +2318,23 @@ linters-settings:
23182318
patterns:
23192319
- ".*"
23202320

2321+
recvcheck:
2322+
# Disables the built-in method exclusions:
2323+
# - `MarshalText`
2324+
# - `MarshalJSON`
2325+
# - `MarshalYAML`
2326+
# - `MarshalXML`
2327+
# - `MarshalBinary`
2328+
# - `GobEncode`
2329+
# Default: false
2330+
disable-builtin: true
2331+
# User-defined method exclusions.
2332+
# The format is `struct_name.method_name` (ex: `Foo.MethodName`).
2333+
# A wildcard `*` can use as a struct name (ex: `*.MethodName`).
2334+
# Default: []
2335+
exclusions:
2336+
- "*.Value"
2337+
23212338
revive:
23222339
# Maximum number of open files at the same time.
23232340
# See https://github.com/mgechev/revive#command-line-flags

jsonschema/golangci.next.jsonschema.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,6 +2394,24 @@
23942394
}
23952395
}
23962396
},
2397+
"recvcheck": {
2398+
"type": "object",
2399+
"additionalProperties": false,
2400+
"properties": {
2401+
"disable-builtin": {
2402+
"description": "Disables the built-in method exclusions.",
2403+
"type": "boolean",
2404+
"default": true
2405+
},
2406+
"exclusions": {
2407+
"description": "User-defined method exclusions.",
2408+
"type": "array",
2409+
"items": {
2410+
"type": "string"
2411+
}
2412+
}
2413+
}
2414+
},
23972415
"nonamedreturns": {
23982416
"type": "object",
23992417
"additionalProperties": false,

pkg/config/linters_settings.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ type LintersSettings struct {
270270
Promlinter PromlinterSettings
271271
ProtoGetter ProtoGetterSettings
272272
Reassign ReassignSettings
273+
Recvcheck RecvcheckSettings
273274
Revive ReviveSettings
274275
RowsErrCheck RowsErrCheckSettings
275276
SlogLint SlogLintSettings
@@ -819,6 +820,11 @@ type ReassignSettings struct {
819820
Patterns []string `mapstructure:"patterns"`
820821
}
821822

823+
type RecvcheckSettings struct {
824+
DisableBuiltin bool `mapstructure:"disable-builtin"`
825+
Exclusions []string `mapstructure:"exclusions"`
826+
}
827+
822828
type ReviveSettings struct {
823829
Go string `mapstructure:"-"`
824830
MaxOpenFiles int `mapstructure:"max-open-files"`

pkg/golinters/recvcheck/recvcheck.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ import (
44
"github.com/raeperd/recvcheck"
55
"golang.org/x/tools/go/analysis"
66

7+
"github.com/golangci/golangci-lint/pkg/config"
78
"github.com/golangci/golangci-lint/pkg/goanalysis"
89
)
910

10-
func New() *goanalysis.Linter {
11-
a := recvcheck.Analyzer
11+
func New(settings *config.RecvcheckSettings) *goanalysis.Linter {
12+
var cfg recvcheck.Settings
13+
14+
if settings != nil {
15+
cfg.DisableBuiltin = settings.DisableBuiltin
16+
cfg.Exclusions = settings.Exclusions
17+
}
18+
19+
a := recvcheck.NewAnalyzer(cfg)
1220

1321
return goanalysis.NewLinter(
1422
a.Name,

pkg/lint/lintersdb/builder_linter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
672672
WithLoadForGoAnalysis().
673673
WithURL("https://github.com/curioswitch/go-reassign"),
674674

675-
linter.NewConfig(recvcheck.New()).
675+
linter.NewConfig(recvcheck.New(&cfg.LintersSettings.Recvcheck)).
676676
WithSince("v1.62.0").
677677
WithPresets(linter.PresetBugs).
678678
WithLoadForGoAnalysis().

0 commit comments

Comments
 (0)