Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ linters:
- io.Copy(*bytes.Buffer)
- io.Copy(os.Stdout)

# Display function signature instead of selector.
# Default: false
verbose: true

errchkjson:
# With check-error-free-encoding set to true, errchkjson does warn about errors
# from json encoding functions that are safe to be ignored,
Expand Down
5 changes: 5 additions & 0 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,11 @@
"description": "To disable the errcheck built-in exclude list",
"type": "boolean",
"default": false
},
"verbose": {
"description": "Display function signature instead of selector",
"type": "boolean",
"default": false
}
}
},
Expand Down
1 change: 1 addition & 0 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ type ErrcheckSettings struct {
CheckTypeAssertions bool `mapstructure:"check-type-assertions"`
CheckAssignToBlank bool `mapstructure:"check-blank"`
ExcludeFunctions []string `mapstructure:"exclude-functions"`
Verbose bool `mapstructure:"verbose"`
}

type ErrChkJSONSettings struct {
Expand Down
7 changes: 5 additions & 2 deletions pkg/golinters/errcheck/errcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func New(settings *config.ErrcheckSettings) *goanalysis.Linter {
checker.Tags = lintCtx.Cfg.Run.BuildTags

analyzer.Run = func(pass *analysis.Pass) (any, error) {
issues := runErrCheck(pass, checker)
issues := runErrCheck(pass, checker, settings.Verbose)

if len(issues) == 0 {
return nil, nil
Expand All @@ -56,7 +56,7 @@ func New(settings *config.ErrcheckSettings) *goanalysis.Linter {
WithLoadMode(goanalysis.LoadModeTypesInfo)
}

func runErrCheck(pass *analysis.Pass, checker *errcheck.Checker) []goanalysis.Issue {
func runErrCheck(pass *analysis.Pass, checker *errcheck.Checker, verbose bool) []goanalysis.Issue {
pkg := &packages.Package{
Fset: pass.Fset,
Syntax: pass.Files,
Expand All @@ -76,6 +76,9 @@ func runErrCheck(pass *analysis.Pass, checker *errcheck.Checker) []goanalysis.Is

if err.FuncName != "" {
code := cmp.Or(err.SelectorName, err.FuncName)
if verbose {
code = err.FuncName
}

text = fmt.Sprintf("Error return value of %s is not checked", internal.FormatCode(code))
}
Expand Down
Loading