Skip to content

Commit

Permalink
review: update implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Jun 26, 2022
1 parent a026bd1 commit d2f4668
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .golangci.reference.yml
Expand Up @@ -1159,6 +1159,10 @@ linters-settings:
require-specific: true

nonamedreturns:
# Report named error if it is assigned inside defer.
# Default: false
report-error-in-defer: true
# DEPRECATED use report-error-in-defer instead.
# Do not complain about named error, if it is assigned inside defer.
# Default: false
allow-error-in-defer: true
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/linters_settings.go
Expand Up @@ -486,7 +486,8 @@ type NoLintLintSettings struct {
}

type NoNamedReturnsSettings struct {
AllowErrorInDefer bool `mapstructure:"allow-error-in-defer"`
AllowErrorInDefer bool `mapstructure:"allow-error-in-defer"` // Deprecated: use ReportErrorInDefer instead.
ReportErrorInDefer bool `mapstructure:"report-error-in-defer"`
}
type ParallelTestSettings struct {
IgnoreMissing bool `mapstructure:"ignore-missing"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/golinters/nonamedreturns.go
Expand Up @@ -15,7 +15,7 @@ func NewNoNamedReturns(settings *config.NoNamedReturnsSettings) *goanalysis.Lint
if settings != nil {
cfg = map[string]map[string]interface{}{
a.Name: {
analyzer.FlagAllowErrorInDefer: settings.AllowErrorInDefer,
analyzer.FlagReportErrorInDefer: settings.ReportErrorInDefer || settings.AllowErrorInDefer,
},
}
}
Expand All @@ -25,5 +25,5 @@ func NewNoNamedReturns(settings *config.NoNamedReturnsSettings) *goanalysis.Lint
a.Doc,
[]*analysis.Analyzer{a},
cfg,
).WithLoadMode(goanalysis.LoadModeSyntax)
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}
1 change: 1 addition & 0 deletions pkg/lint/lintersdb/manager.go
Expand Up @@ -627,6 +627,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {

linter.NewConfig(golinters.NewNoNamedReturns(noNamedReturnsCfg)).
WithSince("v1.46.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
WithURL("https://github.com/firefart/nonamedreturns"),

Expand Down

0 comments on commit d2f4668

Please sign in to comment.