Skip to content

Commit

Permalink
feat: deprecation step 2 of execinquery and gomnd (#5110)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Nov 7, 2024
1 parent 6ba5f63 commit 874a8ba
Show file tree
Hide file tree
Showing 10 changed files with 4 additions and 115 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ require (
github.com/ldez/gomoddirectives v0.2.4
github.com/ldez/tagliatelle v0.5.0
github.com/leonklingele/grouper v1.1.2
github.com/lufeee/execinquery v1.2.1
github.com/macabu/inamedparam v0.1.3
github.com/maratori/testableexamples v1.0.0
github.com/maratori/testpackage v1.1.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@
"contextcheck",
"copyloopvar",
"cyclop",
"deadcode",
"decorder",
"depguard",
"dogsled",
Expand All @@ -330,9 +329,7 @@
"errchkjson",
"errname",
"errorlint",
"execinquery",
"exhaustive",
"exhaustivestruct",
"exhaustruct",
"exportloopref",
"fatcontext",
Expand All @@ -356,7 +353,6 @@
"gofumpt",
"goheader",
"goimports",
"golint",
"gomoddirectives",
"gomodguard",
"goprintffuncname",
Expand All @@ -366,19 +362,16 @@
"govet",
"grouper",
"iface",
"ifshort",
"importas",
"inamedparam",
"ineffassign",
"interfacebloat",
"interfacer",
"intrange",
"ireturn",
"lll",
"loggercheck",
"maintidx",
"makezero",
"maligned",
"mirror",
"misspell",
"mnd",
Expand All @@ -391,7 +384,6 @@
"noctx",
"nolintlint",
"nonamedreturns",
"nosnakecase",
"nosprintfhostport",
"paralleltest",
"perfsprint",
Expand All @@ -403,11 +395,9 @@
"recvcheck",
"revive",
"rowserrcheck",
"scopelint",
"sloglint",
"sqlclosecheck",
"staticcheck",
"structcheck",
"stylecheck",
"tagalign",
"tagliatelle",
Expand All @@ -421,7 +411,6 @@
"unparam",
"unused",
"usestdlibvars",
"varcheck",
"varnamelen",
"wastedassign",
"whitespace",
Expand Down
9 changes: 0 additions & 9 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ type LintersSettings struct {
Gofumpt GofumptSettings
Goheader GoHeaderSettings
Goimports GoImportsSettings
Gomnd GoMndSettings
GoModDirectives GoModDirectivesSettings
Gomodguard GoModGuardSettings
Gosec GoSecSettings
Expand Down Expand Up @@ -570,14 +569,6 @@ type GoImportsSettings struct {
LocalPrefixes string `mapstructure:"local-prefixes"`
}

// Deprecated: use MndSettings.
type GoMndSettings struct {
MndSettings `mapstructure:",squash"`

// Deprecated: use root level settings instead.
Settings map[string]map[string]any
}

type GoModDirectivesSettings struct {
ReplaceAllowList []string `mapstructure:"replace-allow-list"`
ReplaceLocal bool `mapstructure:"replace-local"`
Expand Down
6 changes: 0 additions & 6 deletions pkg/config/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,6 @@ func (l *Loader) handleLinterOptionDeprecations() {
l.log.Warnf("The configuration option `linters.godot.check-all` is deprecated, please use `linters.godot.scope: all`.")
}

// Deprecated since v1.44.0.
if len(l.cfg.LintersSettings.Gomnd.Settings) > 0 {
l.log.Warnf("The configuration option `linters.gomnd.settings` is deprecated. Please use the options " +
"`linters.gomnd.checks`,`linters.gomnd.ignored-numbers`,`linters.gomnd.ignored-files`,`linters.gomnd.ignored-functions`.")
}

// Deprecated since v1.47.0
if l.cfg.LintersSettings.Gofumpt.LangVersion != "" {
l.log.Warnf("The configuration option `linters.gofumpt.lang-version` is deprecated, please use global `run.go`.")
Expand Down
19 changes: 0 additions & 19 deletions pkg/golinters/execinquery/execinquery.go

This file was deleted.

11 changes: 0 additions & 11 deletions pkg/golinters/execinquery/execinquery_integration_test.go

This file was deleted.

30 changes: 0 additions & 30 deletions pkg/golinters/execinquery/testdata/execinquery.go

This file was deleted.

21 changes: 0 additions & 21 deletions pkg/golinters/mnd/mnd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,6 @@ func New(settings *config.MndSettings) *goanalysis.Linter {
return newMND(mnd.Analyzer, settings, nil)
}

func NewGoMND(settings *config.GoMndSettings) *goanalysis.Linter {
// shallow copy because mnd.Analyzer is a global variable.
a := new(analysis.Analyzer)
*a = *mnd.Analyzer

// Used to force the analyzer name to use the same name as the linter.
// This is required to avoid displaying the analyzer name inside the issue text.
a.Name = "gomnd"

var linterCfg map[string]map[string]any

if settings != nil && len(settings.Settings) > 0 {
// Convert deprecated setting.
linterCfg = map[string]map[string]any{
a.Name: settings.Settings["mnd"],
}
}

return newMND(a, &settings.MndSettings, linterCfg)
}

func newMND(a *analysis.Analyzer, settings *config.MndSettings, linterCfg map[string]map[string]any) *goanalysis.Linter {
if len(linterCfg) == 0 && settings != nil {
cfg := make(map[string]any)
Expand Down
9 changes: 4 additions & 5 deletions pkg/lint/lintersdb/builder_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/errchkjson"
"github.com/golangci/golangci-lint/pkg/golinters/errname"
"github.com/golangci/golangci-lint/pkg/golinters/errorlint"
"github.com/golangci/golangci-lint/pkg/golinters/execinquery"
"github.com/golangci/golangci-lint/pkg/golinters/exhaustive"
"github.com/golangci/golangci-lint/pkg/golinters/exhaustruct"
"github.com/golangci/golangci-lint/pkg/golinters/exportloopref"
Expand Down Expand Up @@ -250,12 +249,12 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithLoadForGoAnalysis().
WithURL("https://github.com/polyfloyd/go-errorlint"),

linter.NewConfig(execinquery.New()).
linter.NewConfig(linter.NewNoopDeprecated("execinquery", cfg, linter.DeprecationError)).
WithSince("v1.46.0").
WithPresets(linter.PresetSQL).
WithLoadForGoAnalysis().
WithURL("https://github.com/1uf3/execinquery").
DeprecatedWarning("The repository of the linter has been archived by the owner.", "v1.58.0", ""),
DeprecatedError("The repository of the linter has been archived by the owner.", "v1.58.0", ""),

linter.NewConfig(exhaustive.New(&cfg.LintersSettings.Exhaustive)).
WithSince(" v1.28.0").
Expand Down Expand Up @@ -418,11 +417,11 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithPresets(linter.PresetStyle).
WithURL("https://github.com/tommy-muehle/go-mnd"),

linter.NewConfig(mnd.NewGoMND(&cfg.LintersSettings.Gomnd)).
linter.NewConfig(linter.NewNoopDeprecated("gomnd", cfg, linter.DeprecationError)).
WithSince("v1.22.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/tommy-muehle/go-mnd").
DeprecatedWarning("The linter has been renamed.", "v1.58.0", "mnd"),
DeprecatedError("The linter has been renamed.", "v1.58.0", "mnd"),

linter.NewConfig(gomoddirectives.New(&cfg.LintersSettings.GoModDirectives)).
WithSince("v1.39.0").
Expand Down

0 comments on commit 874a8ba

Please sign in to comment.