Skip to content

Commit d8edde1

Browse files
committed
chore: drop go-critic
because it panic at the start of golangci-lint and then don't allow to check the go1.18 compatibility.
1 parent 44474a1 commit d8edde1

5 files changed

+76
-0
lines changed

pkg/config/linters_settings_gocritic.go

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build go1.16 && !go1.18
2+
// +build go1.16,!go1.18
3+
14
package config
25

36
import (
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//go:build go1.18
2+
// +build go1.18
3+
4+
package config
5+
6+
import (
7+
"github.com/golangci/golangci-lint/pkg/logutils"
8+
)
9+
10+
type GocriticCheckSettings map[string]interface{}
11+
12+
type GocriticSettings struct {
13+
EnabledChecks []string `mapstructure:"enabled-checks"`
14+
DisabledChecks []string `mapstructure:"disabled-checks"`
15+
EnabledTags []string `mapstructure:"enabled-tags"`
16+
DisabledTags []string `mapstructure:"disabled-tags"`
17+
SettingsPerCheck map[string]GocriticCheckSettings `mapstructure:"settings"`
18+
}
19+
20+
func (s *GocriticSettings) InferEnabledChecks(_ logutils.Log) {}
21+
22+
func (s *GocriticSettings) Validate(_ logutils.Log) error {
23+
return nil
24+
}
25+
26+
func (s *GocriticSettings) IsCheckEnabled(_ string) bool {
27+
return false
28+
}
29+
30+
func (s *GocriticSettings) GetLowercasedParams() map[string]GocriticCheckSettings {
31+
return map[string]GocriticCheckSettings{}
32+
}

pkg/config/linters_settings_gocritic_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build go1.16 && !go1.18
2+
// +build go1.16,!go1.18
3+
14
package config
25

36
import (

pkg/golinters/gocritic.go

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build go1.16 && !go1.18
2+
// +build go1.16,!go1.18
3+
14
package golinters
25

36
import (

pkg/golinters/gocritic_go1_18.go

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//go:build go1.18
2+
// +build go1.18
3+
4+
package golinters
5+
6+
import (
7+
"golang.org/x/tools/go/analysis"
8+
9+
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
10+
"github.com/golangci/golangci-lint/pkg/lint/linter"
11+
)
12+
13+
const gocriticName = "gocritic"
14+
15+
func NewGocritic() *goanalysis.Linter {
16+
analyzer := &analysis.Analyzer{
17+
Name: gocriticName,
18+
Doc: goanalysis.TheOnlyanalyzerDoc,
19+
}
20+
return goanalysis.NewLinter(
21+
gocriticName,
22+
`Provides diagnostics that check for bugs, performance and style issues.
23+
Extensible without recompilation through dynamic rules.
24+
Dynamic rules are written declaratively with AST patterns, filters, report message and optional suggestion.`,
25+
[]*analysis.Analyzer{analyzer},
26+
nil,
27+
).WithContextSetter(func(lintCtx *linter.Context) {
28+
analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
29+
lintCtx.Log.Infof("FIXME") // FIXME
30+
return nil, nil
31+
}
32+
}).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
33+
return nil
34+
}).WithLoadMode(goanalysis.LoadModeTypesInfo)
35+
}

0 commit comments

Comments
 (0)