Skip to content

Commit

Permalink
dev: minor clean up (#4577)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Mar 26, 2024
1 parent 840ef62 commit 085ac85
Show file tree
Hide file tree
Showing 41 changed files with 68 additions and 58 deletions.
5 changes: 5 additions & 0 deletions assets/linters-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@
],
"originalURL": "https://github.com/daixiang0/gci",
"internal": false,
"canAutoFix": true,
"isSlow": false,
"since": "v1.30.0"
},
Expand Down Expand Up @@ -449,6 +450,7 @@
],
"originalURL": "https://github.com/go-critic/go-critic",
"internal": false,
"canAutoFix": true,
"isSlow": true,
"since": "v1.12.0"
},
Expand Down Expand Up @@ -539,6 +541,7 @@
],
"originalURL": "https://github.com/denis-tingaikin/go-header",
"internal": false,
"canAutoFix": true,
"isSlow": false,
"since": "v1.28.0"
},
Expand Down Expand Up @@ -877,6 +880,7 @@
],
"originalURL": "https://github.com/butuzov/mirror",
"internal": false,
"canAutoFix": true,
"isSlow": true,
"since": "v1.53.0"
},
Expand Down Expand Up @@ -1500,6 +1504,7 @@
],
"originalURL": "https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md",
"internal": false,
"canAutoFix": true,
"isSlow": false,
"since": "v1.26.0"
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/bidichk.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
)

func NewBiDiChkFuncName(cfg *config.BiDiChkSettings) *goanalysis.Linter {
func NewBiDiChk(cfg *config.BiDiChkSettings) *goanalysis.Linter {
a := bidichk.NewAnalyzer()

cfgMap := map[string]map[string]any{}
Expand Down
6 changes: 4 additions & 2 deletions pkg/golinters/bodyclose.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
)

func NewBodyclose() *goanalysis.Linter {
a := bodyclose.Analyzer

return goanalysis.NewLinter(
"bodyclose",
a.Name,
"checks whether HTTP response body is closed successfully",
[]*analysis.Analyzer{bodyclose.Analyzer},
[]*analysis.Analyzer{a},
nil,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}
2 changes: 1 addition & 1 deletion pkg/golinters/errchkjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
)

func NewErrChkJSONFuncName(cfg *config.ErrChkJSONSettings) *goanalysis.Linter {
func NewErrChkJSON(cfg *config.ErrChkJSONSettings) *goanalysis.Linter {
a := errchkjson.NewAnalyzer()

cfgMap := map[string]map[string]any{}
Expand Down
8 changes: 5 additions & 3 deletions pkg/golinters/grouper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import (
)

func NewGrouper(settings *config.GrouperSettings) *goanalysis.Linter {
a := grouper.New()

linterCfg := map[string]map[string]any{}
if settings != nil {
linterCfg["grouper"] = map[string]any{
linterCfg[a.Name] = map[string]any{
"const-require-single-const": settings.ConstRequireSingleConst,
"const-require-grouping": settings.ConstRequireGrouping,
"import-require-single-import": settings.ImportRequireSingleImport,
Expand All @@ -24,9 +26,9 @@ func NewGrouper(settings *config.GrouperSettings) *goanalysis.Linter {
}

return goanalysis.NewLinter(
"grouper",
a.Name,
"Analyze expression groups.",
[]*analysis.Analyzer{grouper.New()},
[]*analysis.Analyzer{a},
linterCfg,
).WithLoadMode(goanalysis.LoadModeSyntax)
}
9 changes: 7 additions & 2 deletions pkg/lint/lintersdb/builder_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithPresets(linter.PresetBugs, linter.PresetStyle).
WithURL("https://github.com/tdakkota/asciicheck"),

linter.NewConfig(golinters.NewBiDiChkFuncName(&cfg.LintersSettings.BiDiChk)).
linter.NewConfig(golinters.NewBiDiChk(&cfg.LintersSettings.BiDiChk)).
WithSince("1.43.0").
WithPresets(linter.PresetBugs).
WithURL("https://github.com/breml/bidichk"),
Expand Down Expand Up @@ -117,7 +117,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithPresets(linter.PresetBugs, linter.PresetError).
WithURL("https://github.com/kisielk/errcheck"),

linter.NewConfig(golinters.NewErrChkJSONFuncName(&cfg.LintersSettings.ErrChkJSON)).
linter.NewConfig(golinters.NewErrChkJSON(&cfg.LintersSettings.ErrChkJSON)).
WithSince("1.44.0").
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
Expand Down Expand Up @@ -189,6 +189,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
linter.NewConfig(golinters.NewGci(&cfg.LintersSettings.Gci)).
WithSince("v1.30.0").
WithPresets(linter.PresetFormatting, linter.PresetImport).
WithAutoFix().
WithURL("https://github.com/daixiang0/gci"),

linter.NewConfig(golinters.NewGinkgoLinter(&cfg.LintersSettings.GinkgoLinter)).
Expand Down Expand Up @@ -232,6 +233,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithSince("v1.12.0").
WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
WithLoadForGoAnalysis().
WithAutoFix().
WithURL("https://github.com/go-critic/go-critic"),

linter.NewConfig(golinters.NewGocyclo(&cfg.LintersSettings.Gocyclo)).
Expand Down Expand Up @@ -271,6 +273,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
linter.NewConfig(golinters.NewGoHeader(&cfg.LintersSettings.Goheader)).
WithSince("v1.28.0").
WithPresets(linter.PresetStyle).
WithAutoFix().
WithURL("https://github.com/denis-tingaikin/go-header"),

linter.NewConfig(golinters.NewGoimports(&cfg.LintersSettings.Goimports)).
Expand Down Expand Up @@ -419,6 +422,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithSince("v1.53.0").
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithAutoFix().
WithURL("https://github.com/butuzov/mirror"),

linter.NewConfig(golinters.NewMisspell(&cfg.LintersSettings.Misspell)).
Expand Down Expand Up @@ -706,6 +710,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
linter.NewConfig(golinters.NewNoLintLint(&cfg.LintersSettings.NoLintLint)).
WithSince("v1.26.0").
WithPresets(linter.PresetStyle).
WithAutoFix().
WithURL("https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md"),
}, nil
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions test/testdata/decorder.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
//golangcitest:args -Edecorder
//golangcitest:config_path testdata/configs/decorder.yml
//golangcitest:expected_exitcode 0
package testdata

import "math"

const (
decoc = math.MaxInt64
decod = 1
decoh = math.MaxInt64
decoi = 1
)

var decoa = 1
var decob = 1 // want "multiple \"var\" declarations are not allowed; use parentheses instead"
var decoj = 1
var decok = 1

type decoe int // want "type must not be placed after const"
type decol int

func decof() {
const decog = 1
func decom() {
const decon = 1
}

func init() {} // want "init func must be the first function in file"
func init() {}
21 changes: 21 additions & 0 deletions test/testdata/decorder_custom.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//golangcitest:args -Edecorder
//golangcitest:config_path testdata/configs/decorder_custom.yml
package testdata

import "math"

const (
decoc = math.MaxInt64
decod = 1
)

var decoa = 1
var decob = 1 // want "multiple \"var\" declarations are not allowed; use parentheses instead"

type decoe int // want "type must not be placed after const"

func decof() {
const decog = 1
}

func init() {} // want "init func must be the first function in file"
21 changes: 0 additions & 21 deletions test/testdata/decorder_default.go

This file was deleted.

2 changes: 1 addition & 1 deletion test/testdata/errcheck_exclude_functions.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//golangcitest:args -Eerrcheck
//golangcitest:config_path testdata/configs/exclude_functions.yml
//golangcitest:config_path testdata/configs/errcheck_exclude_functions.yml
package testdata

import (
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/errcheck_ignore.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//golangcitest:args -Eerrcheck
//golangcitest:config_path testdata/configs/ignore_config.yml
//golangcitest:config_path testdata/configs/errcheck_ignore_config.yml
package testdata

import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

//golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml
//golangcitest:config_path testdata/configs/goheader-fix.yml
package p
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Use of this source code is governed */

//golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml
//golangcitest:config_path testdata/configs/goheader-fix.yml
package p
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Use of this source code is governed by LICENSE

//golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml
//golangcitest:config_path testdata/configs/goheader-fix.yml
package p
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

//golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml
//golangcitest:config_path testdata/configs/goheader-fix.yml
package p
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Use of this source code is governed by LICENSE */

//golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml
//golangcitest:config_path testdata/configs/goheader-fix.yml
package p
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Use of this source code is governed by LICENSE

//golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml
//golangcitest:config_path testdata/configs/goheader-fix.yml
package p
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*MY TITLE!*/ // want `Expected:TITLE\., Actual: TITLE!`

//golangcitest:args -Egoheader
//golangcitest:config_path testdata/configs/go-header.yml
//golangcitest:config_path testdata/configs/goheader.yml
package testdata
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*MY TITLE.*/

//golangcitest:args -Egoheader
//golangcitest:config_path testdata/configs/go-header.yml
//golangcitest:config_path testdata/configs/goheader.yml
//golangcitest:expected_exitcode 0
package testdata
File renamed without changes.
2 changes: 1 addition & 1 deletion test/testdata/ireturn_allow.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//golangcitest:args -Eireturn
//golangcitest:config_path testdata/configs/ireturn.yml
//golangcitest:config_path testdata/configs/ireturn_allow.yml
//golangcitest:expected_exitcode 0
package testdata

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/testdata/nonamedreturns_custom.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//golangcitest:args -Enonamedreturns
//golangcitest:config_path testdata/configs/nonamedreturns.yml
//golangcitest:config_path testdata/configs/nonamedreturns_custom.yml
package testdata

import "fmt"
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/paralleltest_custom.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//golangcitest:args -Eparalleltest
//golangcitest:config_path testdata/configs/paralleltest.yml
//golangcitest:config_path testdata/configs/paralleltest_custom.yml
//golangcitest:expected_exitcode 0
package testdata

Expand Down
2 changes: 1 addition & 1 deletion test/testdata/predeclared_custom.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//golangcitest:args -Epredeclared
//golangcitest:config_path testdata/configs/predeclared.yml
//golangcitest:config_path testdata/configs/predeclared_custom.yml
package testdata

func hello() {
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/spancheck/spancheck_enable_all.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//golangcitest:config_path configs/enable_all.yml
//golangcitest:config_path configs/spancheck_enable_all.yml
//golangcitest:args -Espancheck
package spancheck

Expand Down
2 changes: 0 additions & 2 deletions test/testdata/tenv_go118.go → test/testdata/tenv_fuzz.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.18

//golangcitest:args -Etenv
package testdata

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.18

//golangcitest:args -Ethelper
package testdata

Expand Down

0 comments on commit 085ac85

Please sign in to comment.