Skip to content

Commit eb6e25c

Browse files
committed
review: update implementation
1 parent a026bd1 commit eb6e25c

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

.golangci.reference.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,10 @@ linters-settings:
11591159
require-specific: true
11601160

11611161
nonamedreturns:
1162+
# Report named error if it is assigned inside defer.
1163+
# Default: false
1164+
report-error-in-defer: true
1165+
# DEPRECATED use report-error-in-defer instead.
11621166
# Do not complain about named error, if it is assigned inside defer.
11631167
# Default: false
11641168
allow-error-in-defer: true

pkg/config/linters_settings.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,8 @@ type NoLintLintSettings struct {
486486
}
487487

488488
type NoNamedReturnsSettings struct {
489-
AllowErrorInDefer bool `mapstructure:"allow-error-in-defer"`
489+
AllowErrorInDefer bool `mapstructure:"allow-error-in-defer"` // Deprecated: use ReportErrorInDefer instead.
490+
ReportErrorInDefer bool `mapstructure:"report-error-in-defer"`
490491
}
491492
type ParallelTestSettings struct {
492493
IgnoreMissing bool `mapstructure:"ignore-missing"`

pkg/golinters/nonamedreturns.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func NewNoNamedReturns(settings *config.NoNamedReturnsSettings) *goanalysis.Lint
1515
if settings != nil {
1616
cfg = map[string]map[string]interface{}{
1717
a.Name: {
18-
analyzer.FlagAllowErrorInDefer: settings.AllowErrorInDefer,
18+
analyzer.FlagReportErrorInDefer: settings.ReportErrorInDefer || settings.AllowErrorInDefer,
1919
},
2020
}
2121
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
linters-settings:
22
nonamedreturns:
3-
allow-error-in-defer: true
3+
report-error-in-defer: true

0 commit comments

Comments
 (0)