Add versions, improve deprecation system, improve linters page (#1854)
This commit is contained in:
parent
b6a6faa982
commit
8db518cee0
@ -9,31 +9,35 @@ from scratch and integrate it into `golangci-lint`.
|
|||||||
|
|
||||||
## How to add a public linter to `golangci-lint`
|
## How to add a public linter to `golangci-lint`
|
||||||
|
|
||||||
You need to implement a new linter using `go/analysis` API. We don't accept not `go/analysis` linters.
|
You need to implement a new linter using `go/analysis` API.
|
||||||
|
We don't accept not `go/analysis` linters.
|
||||||
|
|
||||||
After that:
|
After that:
|
||||||
|
|
||||||
1. Implement functional tests for the linter: add one file into directory [`test/testdata`](https://github.com/golangci/golangci-lint/tree/master/test/testdata).
|
1. Implement functional tests for the linter:
|
||||||
Run `T=yourlintername.go make test_linters` to ensure that test fails.
|
- Add one file into directory [`test/testdata`](https://github.com/golangci/golangci-lint/tree/master/test/testdata).
|
||||||
2. Add a new file `pkg/golinters/{yourlintername}.go`. Look at other linters in this directory. Implement linter integration and check that test passes.
|
- Run `T=yourlintername.go make test_linters` to ensure that test fails.
|
||||||
|
- Run `go run ./cmd/golangci-lint/ run --no-config --disable-all --enable=yourlintername ./test/testdata/yourlintername.go`
|
||||||
|
2. Add a new file `pkg/golinters/{yourlintername}.go`.
|
||||||
|
Look at other linters in this directory.
|
||||||
|
Implement linter integration and check that test passes.
|
||||||
3. Add the new struct for the linter (which you've implemented in `pkg/golinters/{yourlintername}.go`) to the
|
3. Add the new struct for the linter (which you've implemented in `pkg/golinters/{yourlintername}.go`) to the
|
||||||
list of all supported linters in [`pkg/lint/lintersdb/manager.go`](https://github.com/golangci/golangci-lint/blob/master/pkg/lint/lintersdb/manager.go)
|
list of all supported linters in [`pkg/lint/lintersdb/manager.go`](https://github.com/golangci/golangci-lint/blob/master/pkg/lint/lintersdb/manager.go)
|
||||||
to the function `GetAllSupportedLinterConfigs`. Enable it by default only if you are sure.
|
to the function `GetAllSupportedLinterConfigs`.
|
||||||
4. Find out what options do you need to configure for the linter. For example, `nakedret` has
|
- Add `WithSince("next_version")`, where `next_version` must be replaced by the next minor version. (ex: v1.2.0 if the current version is v1.1.0)
|
||||||
only 1 option: [`max-func-lines`](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml).
|
4. Find out what options do you need to configure for the linter.
|
||||||
|
For example, `nakedret` has only 1 option: [`max-func-lines`](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml).
|
||||||
Choose default values to not being annoying for users of golangci-lint. Add configuration options to:
|
Choose default values to not being annoying for users of golangci-lint. Add configuration options to:
|
||||||
|
- [.golangci.example.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml) - the example of a configuration file.
|
||||||
- [.golangci.example.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml) - the example of a configuration file. You can also add
|
You can also add them to [.golangci.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.yml)
|
||||||
them to [.golangci.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.yml) if you think
|
if you think that this project needs not default values.
|
||||||
that this project needs not default values.
|
- [config struct](https://github.com/golangci/golangci-lint/blob/master/pkg/config/config.go) -
|
||||||
- [config struct](https://github.com/golangci/golangci-lint/blob/master/pkg/config/config.go) - don't forget
|
don't forget about `mapstructure` tag for proper configuration files parsing by [pflag](https://github.com/spf13/pflag).
|
||||||
about `mapstructure` tag for proper configuration files parsing by [pflag](https://github.com/spf13/pflag).
|
5. Take a look at the example of [Pull Request with new linter support](https://github.com/golangci/golangci-lint/pulls?q=is%3Apr+is%3Amerged+label%3A%22linter%3A+new%22).
|
||||||
|
|
||||||
5. Take a look at the example of [Pull Request with new linter support](https://github.com/golangci/golangci-lint/pull/850).
|
|
||||||
|
|
||||||
## How to add a private linter to `golangci-lint`
|
## How to add a private linter to `golangci-lint`
|
||||||
|
|
||||||
Some people and organizations may choose to have custom made linters run as a part of `golangci-lint`.
|
Some people and organizations may choose to have custom-made linters run as a part of `golangci-lint`.
|
||||||
Typically, these linters can't be open-sourced or too specific.
|
Typically, these linters can't be open-sourced or too specific.
|
||||||
Such linters can be added through Go's plugin library.
|
Such linters can be added through Go's plugin library.
|
||||||
|
|
||||||
|
@ -20,6 +20,12 @@ const (
|
|||||||
PresetUnused = "unused" // Related to the detection of unused code.
|
PresetUnused = "unused" // Related to the detection of unused code.
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Deprecation struct {
|
||||||
|
Since string
|
||||||
|
Message string
|
||||||
|
Replacement string
|
||||||
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Linter Linter
|
Linter Linter
|
||||||
EnabledByDefault bool
|
EnabledByDefault bool
|
||||||
@ -33,7 +39,9 @@ type Config struct {
|
|||||||
CanAutoFix bool
|
CanAutoFix bool
|
||||||
IsSlow bool
|
IsSlow bool
|
||||||
DoesChangeTypes bool
|
DoesChangeTypes bool
|
||||||
DeprecatedMessage string
|
|
||||||
|
Since string
|
||||||
|
Deprecation *Deprecation
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lc *Config) ConsiderSlow() *Config {
|
func (lc *Config) ConsiderSlow() *Config {
|
||||||
@ -82,13 +90,22 @@ func (lc *Config) WithChangeTypes() *Config {
|
|||||||
return lc
|
return lc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lc *Config) Deprecated(message string) *Config {
|
func (lc *Config) WithSince(version string) *Config {
|
||||||
lc.DeprecatedMessage = message
|
lc.Since = version
|
||||||
|
return lc
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lc *Config) Deprecated(message, version, replacement string) *Config {
|
||||||
|
lc.Deprecation = &Deprecation{
|
||||||
|
Since: version,
|
||||||
|
Message: message,
|
||||||
|
Replacement: replacement,
|
||||||
|
}
|
||||||
return lc
|
return lc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lc *Config) IsDeprecated() bool {
|
func (lc *Config) IsDeprecated() bool {
|
||||||
return lc.DeprecatedMessage != ""
|
return lc.Deprecation != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lc *Config) AllNames() []string {
|
func (lc *Config) AllNames() []string {
|
||||||
|
@ -112,6 +112,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
|
|||||||
var cyclopCfg *config.Cyclop
|
var cyclopCfg *config.Cyclop
|
||||||
var importAsCfg *config.ImportAsSettings
|
var importAsCfg *config.ImportAsSettings
|
||||||
var goModDirectivesCfg *config.GoModDirectivesSettings
|
var goModDirectivesCfg *config.GoModDirectivesSettings
|
||||||
|
|
||||||
if m.cfg != nil {
|
if m.cfg != nil {
|
||||||
govetCfg = &m.cfg.LintersSettings.Govet
|
govetCfg = &m.cfg.LintersSettings.Govet
|
||||||
testpackageCfg = &m.cfg.LintersSettings.Testpackage
|
testpackageCfg = &m.cfg.LintersSettings.Testpackage
|
||||||
@ -126,40 +127,50 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
|
|||||||
importAsCfg = &m.cfg.LintersSettings.ImportAs
|
importAsCfg = &m.cfg.LintersSettings.ImportAs
|
||||||
goModDirectivesCfg = &m.cfg.LintersSettings.GoModDirectives
|
goModDirectivesCfg = &m.cfg.LintersSettings.GoModDirectives
|
||||||
}
|
}
|
||||||
|
|
||||||
const megacheckName = "megacheck"
|
const megacheckName = "megacheck"
|
||||||
|
|
||||||
lcs := []*linter.Config{
|
lcs := []*linter.Config{
|
||||||
linter.NewConfig(golinters.NewGovet(govetCfg)).
|
linter.NewConfig(golinters.NewGovet(govetCfg)).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetBugs, linter.PresetMetaLinter).
|
WithPresets(linter.PresetBugs, linter.PresetMetaLinter).
|
||||||
WithAlternativeNames("vet", "vetshadow").
|
WithAlternativeNames("vet", "vetshadow").
|
||||||
WithURL("https://golang.org/cmd/vet/"),
|
WithURL("https://golang.org/cmd/vet/"),
|
||||||
linter.NewConfig(golinters.NewBodyclose()).
|
linter.NewConfig(golinters.NewBodyclose()).
|
||||||
|
WithSince("v1.18.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetPerformance, linter.PresetBugs).
|
WithPresets(linter.PresetPerformance, linter.PresetBugs).
|
||||||
WithURL("https://github.com/timakin/bodyclose"),
|
WithURL("https://github.com/timakin/bodyclose"),
|
||||||
linter.NewConfig(golinters.NewNoctx()).
|
linter.NewConfig(golinters.NewNoctx()).
|
||||||
|
WithSince("v1.28.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetPerformance, linter.PresetBugs).
|
WithPresets(linter.PresetPerformance, linter.PresetBugs).
|
||||||
WithURL("https://github.com/sonatard/noctx"),
|
WithURL("https://github.com/sonatard/noctx"),
|
||||||
linter.NewConfig(golinters.NewErrcheck()).
|
linter.NewConfig(golinters.NewErrcheck()).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetBugs, linter.PresetError).
|
WithPresets(linter.PresetBugs, linter.PresetError).
|
||||||
WithURL("https://github.com/kisielk/errcheck"),
|
WithURL("https://github.com/kisielk/errcheck"),
|
||||||
linter.NewConfig(golinters.NewGolint()).
|
linter.NewConfig(golinters.NewGolint()).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/golang/lint"),
|
WithURL("https://github.com/golang/lint"),
|
||||||
linter.NewConfig(golinters.NewRowsErrCheck()).
|
linter.NewConfig(golinters.NewRowsErrCheck()).
|
||||||
|
WithSince("v1.23.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetBugs, linter.PresetSQL).
|
WithPresets(linter.PresetBugs, linter.PresetSQL).
|
||||||
WithURL("https://github.com/jingyugao/rowserrcheck"),
|
WithURL("https://github.com/jingyugao/rowserrcheck"),
|
||||||
|
|
||||||
linter.NewConfig(golinters.NewStaticcheck()).
|
linter.NewConfig(golinters.NewStaticcheck()).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetBugs, linter.PresetMetaLinter).
|
WithPresets(linter.PresetBugs, linter.PresetMetaLinter).
|
||||||
WithAlternativeNames(megacheckName).
|
WithAlternativeNames(megacheckName).
|
||||||
WithURL("https://staticcheck.io/"),
|
WithURL("https://staticcheck.io/"),
|
||||||
linter.NewConfig(golinters.NewUnused()).
|
linter.NewConfig(golinters.NewUnused()).
|
||||||
|
WithSince("v1.20.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetUnused).
|
WithPresets(linter.PresetUnused).
|
||||||
WithAlternativeNames(megacheckName).
|
WithAlternativeNames(megacheckName).
|
||||||
@ -167,255 +178,321 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
|
|||||||
WithChangeTypes().
|
WithChangeTypes().
|
||||||
WithURL("https://github.com/dominikh/go-tools/tree/master/unused"),
|
WithURL("https://github.com/dominikh/go-tools/tree/master/unused"),
|
||||||
linter.NewConfig(golinters.NewGosimple()).
|
linter.NewConfig(golinters.NewGosimple()).
|
||||||
|
WithSince("v1.20.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithAlternativeNames(megacheckName).
|
WithAlternativeNames(megacheckName).
|
||||||
WithURL("https://github.com/dominikh/go-tools/tree/master/simple"),
|
WithURL("https://github.com/dominikh/go-tools/tree/master/simple"),
|
||||||
|
|
||||||
linter.NewConfig(golinters.NewStylecheck()).
|
linter.NewConfig(golinters.NewStylecheck()).
|
||||||
|
WithSince("v1.20.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/dominikh/go-tools/tree/master/stylecheck"),
|
WithURL("https://github.com/dominikh/go-tools/tree/master/stylecheck"),
|
||||||
|
|
||||||
linter.NewConfig(golinters.NewGosec()).
|
linter.NewConfig(golinters.NewGosec()).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetBugs).
|
WithPresets(linter.PresetBugs).
|
||||||
WithURL("https://github.com/securego/gosec").
|
WithURL("https://github.com/securego/gosec").
|
||||||
WithAlternativeNames("gas"),
|
WithAlternativeNames("gas"),
|
||||||
linter.NewConfig(golinters.NewStructcheck()).
|
linter.NewConfig(golinters.NewStructcheck()).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetUnused).
|
WithPresets(linter.PresetUnused).
|
||||||
WithURL("https://github.com/opennota/check"),
|
WithURL("https://github.com/opennota/check"),
|
||||||
linter.NewConfig(golinters.NewVarcheck()).
|
linter.NewConfig(golinters.NewVarcheck()).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetUnused).
|
WithPresets(linter.PresetUnused).
|
||||||
WithURL("https://github.com/opennota/check"),
|
WithURL("https://github.com/opennota/check"),
|
||||||
linter.NewConfig(golinters.NewInterfacer()).
|
linter.NewConfig(golinters.NewInterfacer()).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/mvdan/interfacer").
|
WithURL("https://github.com/mvdan/interfacer").
|
||||||
Deprecated("The repository of the linter has been archived by the owner."),
|
Deprecated("The repository of the linter has been archived by the owner.", "v1.38.0", ""),
|
||||||
linter.NewConfig(golinters.NewUnconvert()).
|
linter.NewConfig(golinters.NewUnconvert()).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/mdempsky/unconvert"),
|
WithURL("https://github.com/mdempsky/unconvert"),
|
||||||
linter.NewConfig(golinters.NewIneffassign()).
|
linter.NewConfig(golinters.NewIneffassign()).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetUnused).
|
WithPresets(linter.PresetUnused).
|
||||||
WithURL("https://github.com/gordonklaus/ineffassign"),
|
WithURL("https://github.com/gordonklaus/ineffassign"),
|
||||||
linter.NewConfig(golinters.NewDupl()).
|
linter.NewConfig(golinters.NewDupl()).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/mibk/dupl"),
|
WithURL("https://github.com/mibk/dupl"),
|
||||||
linter.NewConfig(golinters.NewGoconst()).
|
linter.NewConfig(golinters.NewGoconst()).
|
||||||
|
WithSince("").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/jgautheron/goconst"),
|
WithURL("https://github.com/jgautheron/goconst"),
|
||||||
linter.NewConfig(golinters.NewDeadcode()).
|
linter.NewConfig(golinters.NewDeadcode()).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetUnused).
|
WithPresets(linter.PresetUnused).
|
||||||
WithURL("https://github.com/remyoudompheng/go-misc/tree/master/deadcode"),
|
WithURL("https://github.com/remyoudompheng/go-misc/tree/master/deadcode"),
|
||||||
linter.NewConfig(golinters.NewGocyclo()).
|
linter.NewConfig(golinters.NewGocyclo()).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithPresets(linter.PresetComplexity).
|
WithPresets(linter.PresetComplexity).
|
||||||
WithURL("https://github.com/fzipp/gocyclo"),
|
WithURL("https://github.com/fzipp/gocyclo"),
|
||||||
linter.NewConfig(golinters.NewCyclop(cyclopCfg)).
|
linter.NewConfig(golinters.NewCyclop(cyclopCfg)).
|
||||||
|
WithSince("v1.37.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetComplexity).
|
WithPresets(linter.PresetComplexity).
|
||||||
WithURL("https://github.com/bkielbasa/cyclop"),
|
WithURL("https://github.com/bkielbasa/cyclop"),
|
||||||
linter.NewConfig(golinters.NewGocognit()).
|
linter.NewConfig(golinters.NewGocognit()).
|
||||||
|
WithSince("v1.20.0").
|
||||||
WithPresets(linter.PresetComplexity).
|
WithPresets(linter.PresetComplexity).
|
||||||
WithURL("https://github.com/uudashr/gocognit"),
|
WithURL("https://github.com/uudashr/gocognit"),
|
||||||
linter.NewConfig(golinters.NewTypecheck()).
|
linter.NewConfig(golinters.NewTypecheck()).
|
||||||
|
WithSince("v1.3.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetBugs).
|
WithPresets(linter.PresetBugs).
|
||||||
WithURL(""),
|
WithURL(""),
|
||||||
linter.NewConfig(golinters.NewAsciicheck()).
|
linter.NewConfig(golinters.NewAsciicheck()).
|
||||||
|
WithSince("v1.26.0").
|
||||||
WithPresets(linter.PresetBugs, linter.PresetStyle).
|
WithPresets(linter.PresetBugs, linter.PresetStyle).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/tdakkota/asciicheck"),
|
WithURL("https://github.com/tdakkota/asciicheck"),
|
||||||
|
|
||||||
linter.NewConfig(golinters.NewGofmt()).
|
linter.NewConfig(golinters.NewGofmt()).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithPresets(linter.PresetFormatting).
|
WithPresets(linter.PresetFormatting).
|
||||||
WithAutoFix().
|
WithAutoFix().
|
||||||
WithURL("https://golang.org/cmd/gofmt/"),
|
WithURL("https://golang.org/cmd/gofmt/"),
|
||||||
linter.NewConfig(golinters.NewGofumpt()).
|
linter.NewConfig(golinters.NewGofumpt()).
|
||||||
|
WithSince("v1.28.0").
|
||||||
WithPresets(linter.PresetFormatting).
|
WithPresets(linter.PresetFormatting).
|
||||||
WithAutoFix().
|
WithAutoFix().
|
||||||
WithURL("https://github.com/mvdan/gofumpt"),
|
WithURL("https://github.com/mvdan/gofumpt"),
|
||||||
linter.NewConfig(golinters.NewGoimports()).
|
linter.NewConfig(golinters.NewGoimports()).
|
||||||
|
WithSince("v1.20.0").
|
||||||
WithPresets(linter.PresetFormatting, linter.PresetImport).
|
WithPresets(linter.PresetFormatting, linter.PresetImport).
|
||||||
WithAutoFix().
|
WithAutoFix().
|
||||||
WithURL("https://godoc.org/golang.org/x/tools/cmd/goimports"),
|
WithURL("https://godoc.org/golang.org/x/tools/cmd/goimports"),
|
||||||
linter.NewConfig(golinters.NewGoHeader()).
|
linter.NewConfig(golinters.NewGoHeader()).
|
||||||
|
WithSince("v1.28.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/denis-tingajkin/go-header"),
|
WithURL("https://github.com/denis-tingajkin/go-header"),
|
||||||
linter.NewConfig(golinters.NewGci()).
|
linter.NewConfig(golinters.NewGci()).
|
||||||
|
WithSince("v1.30.0").
|
||||||
WithPresets(linter.PresetFormatting, linter.PresetImport).
|
WithPresets(linter.PresetFormatting, linter.PresetImport).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithAutoFix().
|
WithAutoFix().
|
||||||
WithURL("https://github.com/daixiang0/gci"),
|
WithURL("https://github.com/daixiang0/gci"),
|
||||||
linter.NewConfig(golinters.NewMaligned()).
|
linter.NewConfig(golinters.NewMaligned()).
|
||||||
|
WithSince("v1.0.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetPerformance).
|
WithPresets(linter.PresetPerformance).
|
||||||
WithURL("https://github.com/mdempsky/maligned").
|
WithURL("https://github.com/mdempsky/maligned").
|
||||||
Deprecated("The repository of the linter has been archived by the owner. Use govet 'fieldalignment' instead."),
|
Deprecated("The repository of the linter has been archived by the owner.", "v1.38.0", "govet 'fieldalignment'"),
|
||||||
linter.NewConfig(golinters.NewDepguard()).
|
linter.NewConfig(golinters.NewDepguard()).
|
||||||
|
WithSince("v1.4.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
|
WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
|
||||||
WithURL("https://github.com/OpenPeeDeeP/depguard"),
|
WithURL("https://github.com/OpenPeeDeeP/depguard"),
|
||||||
linter.NewConfig(golinters.NewMisspell()).
|
linter.NewConfig(golinters.NewMisspell()).
|
||||||
|
WithSince("v1.8.0").
|
||||||
WithPresets(linter.PresetStyle, linter.PresetComment).
|
WithPresets(linter.PresetStyle, linter.PresetComment).
|
||||||
WithAutoFix().
|
WithAutoFix().
|
||||||
WithURL("https://github.com/client9/misspell"),
|
WithURL("https://github.com/client9/misspell"),
|
||||||
linter.NewConfig(golinters.NewLLL()).
|
linter.NewConfig(golinters.NewLLL()).
|
||||||
|
WithSince("v1.8.0").
|
||||||
WithPresets(linter.PresetStyle),
|
WithPresets(linter.PresetStyle),
|
||||||
linter.NewConfig(golinters.NewUnparam()).
|
linter.NewConfig(golinters.NewUnparam()).
|
||||||
|
WithSince("v1.9.0").
|
||||||
WithPresets(linter.PresetUnused).
|
WithPresets(linter.PresetUnused).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/mvdan/unparam"),
|
WithURL("https://github.com/mvdan/unparam"),
|
||||||
linter.NewConfig(golinters.NewDogsled()).
|
linter.NewConfig(golinters.NewDogsled()).
|
||||||
|
WithSince("v1.19.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/alexkohler/dogsled"),
|
WithURL("https://github.com/alexkohler/dogsled"),
|
||||||
linter.NewConfig(golinters.NewNakedret()).
|
linter.NewConfig(golinters.NewNakedret()).
|
||||||
|
WithSince("v1.19.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/alexkohler/nakedret"),
|
WithURL("https://github.com/alexkohler/nakedret"),
|
||||||
linter.NewConfig(golinters.NewPrealloc()).
|
linter.NewConfig(golinters.NewPrealloc()).
|
||||||
|
WithSince("v1.19.0").
|
||||||
WithPresets(linter.PresetPerformance).
|
WithPresets(linter.PresetPerformance).
|
||||||
WithURL("https://github.com/alexkohler/prealloc"),
|
WithURL("https://github.com/alexkohler/prealloc"),
|
||||||
linter.NewConfig(golinters.NewScopelint()).
|
linter.NewConfig(golinters.NewScopelint()).
|
||||||
|
WithSince("v1.12.0").
|
||||||
WithPresets(linter.PresetBugs).
|
WithPresets(linter.PresetBugs).
|
||||||
WithURL("https://github.com/kyoh86/scopelint").
|
WithURL("https://github.com/kyoh86/scopelint").
|
||||||
Deprecated("The repository of the linter has been deprecated by the owner. Use 'exportloopref' instead."),
|
Deprecated("The repository of the linter has been deprecated by the owner.", "v1.39.0", "exportloopref"),
|
||||||
linter.NewConfig(golinters.NewGocritic()).
|
linter.NewConfig(golinters.NewGocritic()).
|
||||||
|
WithSince("v1.12.0").
|
||||||
WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
|
WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/go-critic/go-critic"),
|
WithURL("https://github.com/go-critic/go-critic"),
|
||||||
linter.NewConfig(golinters.NewGochecknoinits()).
|
linter.NewConfig(golinters.NewGochecknoinits()).
|
||||||
|
WithSince("v1.12.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/leighmcculloch/gochecknoinits"),
|
WithURL("https://github.com/leighmcculloch/gochecknoinits"),
|
||||||
linter.NewConfig(golinters.NewGochecknoglobals()).
|
linter.NewConfig(golinters.NewGochecknoglobals()).
|
||||||
|
WithSince("v1.12.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/leighmcculloch/gochecknoglobals"),
|
WithURL("https://github.com/leighmcculloch/gochecknoglobals"),
|
||||||
linter.NewConfig(golinters.NewGodox()).
|
linter.NewConfig(golinters.NewGodox()).
|
||||||
|
WithSince("v1.19.0").
|
||||||
WithPresets(linter.PresetStyle, linter.PresetComment).
|
WithPresets(linter.PresetStyle, linter.PresetComment).
|
||||||
WithURL("https://github.com/matoous/godox"),
|
WithURL("https://github.com/matoous/godox"),
|
||||||
linter.NewConfig(golinters.NewFunlen()).
|
linter.NewConfig(golinters.NewFunlen()).
|
||||||
|
WithSince("v1.18.0").
|
||||||
WithPresets(linter.PresetComplexity).
|
WithPresets(linter.PresetComplexity).
|
||||||
WithURL("https://github.com/ultraware/funlen"),
|
WithURL("https://github.com/ultraware/funlen"),
|
||||||
linter.NewConfig(golinters.NewWhitespace()).
|
linter.NewConfig(golinters.NewWhitespace()).
|
||||||
|
WithSince("v1.19.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithAutoFix().
|
WithAutoFix().
|
||||||
WithURL("https://github.com/ultraware/whitespace"),
|
WithURL("https://github.com/ultraware/whitespace"),
|
||||||
linter.NewConfig(golinters.NewWSL()).
|
linter.NewConfig(golinters.NewWSL()).
|
||||||
|
WithSince("v1.20.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/bombsimon/wsl"),
|
WithURL("https://github.com/bombsimon/wsl"),
|
||||||
linter.NewConfig(golinters.NewGoPrintfFuncName()).
|
linter.NewConfig(golinters.NewGoPrintfFuncName()).
|
||||||
|
WithSince("v1.23.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/jirfag/go-printf-func-name"),
|
WithURL("https://github.com/jirfag/go-printf-func-name"),
|
||||||
linter.NewConfig(golinters.NewGoMND(m.cfg)).
|
linter.NewConfig(golinters.NewGoMND(m.cfg)).
|
||||||
|
WithSince("v1.22.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/tommy-muehle/go-mnd"),
|
WithURL("https://github.com/tommy-muehle/go-mnd"),
|
||||||
linter.NewConfig(golinters.NewGoerr113()).
|
linter.NewConfig(golinters.NewGoerr113()).
|
||||||
|
WithSince("v1.26.0").
|
||||||
WithPresets(linter.PresetStyle, linter.PresetError).
|
WithPresets(linter.PresetStyle, linter.PresetError).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/Djarvur/go-err113"),
|
WithURL("https://github.com/Djarvur/go-err113"),
|
||||||
linter.NewConfig(golinters.NewGomodguard()).
|
linter.NewConfig(golinters.NewGomodguard()).
|
||||||
|
WithSince("v1.25.0").
|
||||||
WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
|
WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/ryancurrah/gomodguard"),
|
WithURL("https://github.com/ryancurrah/gomodguard"),
|
||||||
linter.NewConfig(golinters.NewGodot()).
|
linter.NewConfig(golinters.NewGodot()).
|
||||||
|
WithSince("v1.25.0").
|
||||||
WithPresets(linter.PresetStyle, linter.PresetComment).
|
WithPresets(linter.PresetStyle, linter.PresetComment).
|
||||||
WithAutoFix().
|
WithAutoFix().
|
||||||
WithURL("https://github.com/tetafro/godot"),
|
WithURL("https://github.com/tetafro/godot"),
|
||||||
linter.NewConfig(golinters.NewTestpackage(testpackageCfg)).
|
linter.NewConfig(golinters.NewTestpackage(testpackageCfg)).
|
||||||
|
WithSince("v1.25.0").
|
||||||
WithPresets(linter.PresetStyle, linter.PresetTest).
|
WithPresets(linter.PresetStyle, linter.PresetTest).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/maratori/testpackage"),
|
WithURL("https://github.com/maratori/testpackage"),
|
||||||
linter.NewConfig(golinters.NewNestif()).
|
linter.NewConfig(golinters.NewNestif()).
|
||||||
|
WithSince("v1.25.0").
|
||||||
WithPresets(linter.PresetComplexity).
|
WithPresets(linter.PresetComplexity).
|
||||||
WithURL("https://github.com/nakabonne/nestif"),
|
WithURL("https://github.com/nakabonne/nestif"),
|
||||||
linter.NewConfig(golinters.NewExportLoopRef()).
|
linter.NewConfig(golinters.NewExportLoopRef()).
|
||||||
|
WithSince("v1.28.0").
|
||||||
WithPresets(linter.PresetBugs).
|
WithPresets(linter.PresetBugs).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/kyoh86/exportloopref"),
|
WithURL("https://github.com/kyoh86/exportloopref"),
|
||||||
linter.NewConfig(golinters.NewExhaustive(exhaustiveCfg)).
|
linter.NewConfig(golinters.NewExhaustive(exhaustiveCfg)).
|
||||||
|
WithSince(" v1.28.0").
|
||||||
WithPresets(linter.PresetBugs).
|
WithPresets(linter.PresetBugs).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/nishanths/exhaustive"),
|
WithURL("https://github.com/nishanths/exhaustive"),
|
||||||
linter.NewConfig(golinters.NewSQLCloseCheck()).
|
linter.NewConfig(golinters.NewSQLCloseCheck()).
|
||||||
|
WithSince("v1.28.0").
|
||||||
WithPresets(linter.PresetBugs, linter.PresetSQL).
|
WithPresets(linter.PresetBugs, linter.PresetSQL).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/ryanrolds/sqlclosecheck"),
|
WithURL("https://github.com/ryanrolds/sqlclosecheck"),
|
||||||
linter.NewConfig(golinters.NewNLReturn()).
|
linter.NewConfig(golinters.NewNLReturn()).
|
||||||
|
WithSince("v1.30.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/ssgreg/nlreturn"),
|
WithURL("https://github.com/ssgreg/nlreturn"),
|
||||||
linter.NewConfig(golinters.NewWrapcheck()).
|
linter.NewConfig(golinters.NewWrapcheck()).
|
||||||
|
WithSince("v1.32.0").
|
||||||
WithPresets(linter.PresetStyle, linter.PresetError).
|
WithPresets(linter.PresetStyle, linter.PresetError).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/tomarrell/wrapcheck"),
|
WithURL("https://github.com/tomarrell/wrapcheck"),
|
||||||
linter.NewConfig(golinters.NewThelper(thelperCfg)).
|
linter.NewConfig(golinters.NewThelper(thelperCfg)).
|
||||||
|
WithSince("v1.34.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/kulti/thelper"),
|
WithURL("https://github.com/kulti/thelper"),
|
||||||
linter.NewConfig(golinters.NewTparallel()).
|
linter.NewConfig(golinters.NewTparallel()).
|
||||||
|
WithSince("v1.32.0").
|
||||||
WithPresets(linter.PresetStyle, linter.PresetTest).
|
WithPresets(linter.PresetStyle, linter.PresetTest).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/moricho/tparallel"),
|
WithURL("https://github.com/moricho/tparallel"),
|
||||||
linter.NewConfig(golinters.NewExhaustiveStruct(exhaustiveStructCfg)).
|
linter.NewConfig(golinters.NewExhaustiveStruct(exhaustiveStructCfg)).
|
||||||
|
WithSince("v1.32.0").
|
||||||
WithPresets(linter.PresetStyle, linter.PresetTest).
|
WithPresets(linter.PresetStyle, linter.PresetTest).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/mbilski/exhaustivestruct"),
|
WithURL("https://github.com/mbilski/exhaustivestruct"),
|
||||||
linter.NewConfig(golinters.NewErrorLint(errorlintCfg)).
|
linter.NewConfig(golinters.NewErrorLint(errorlintCfg)).
|
||||||
|
WithSince("v1.32.0").
|
||||||
WithPresets(linter.PresetBugs, linter.PresetError).
|
WithPresets(linter.PresetBugs, linter.PresetError).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/polyfloyd/go-errorlint"),
|
WithURL("https://github.com/polyfloyd/go-errorlint"),
|
||||||
linter.NewConfig(golinters.NewParallelTest()).
|
linter.NewConfig(golinters.NewParallelTest()).
|
||||||
|
WithSince("v1.33.0").
|
||||||
WithPresets(linter.PresetStyle, linter.PresetTest).
|
WithPresets(linter.PresetStyle, linter.PresetTest).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/kunwardeep/paralleltest"),
|
WithURL("https://github.com/kunwardeep/paralleltest"),
|
||||||
linter.NewConfig(golinters.NewMakezero()).
|
linter.NewConfig(golinters.NewMakezero()).
|
||||||
|
WithSince("v1.34.0").
|
||||||
WithPresets(linter.PresetStyle, linter.PresetBugs).
|
WithPresets(linter.PresetStyle, linter.PresetBugs).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/ashanbrown/makezero"),
|
WithURL("https://github.com/ashanbrown/makezero"),
|
||||||
linter.NewConfig(golinters.NewForbidigo()).
|
linter.NewConfig(golinters.NewForbidigo()).
|
||||||
|
WithSince("v1.34.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/ashanbrown/forbidigo"),
|
WithURL("https://github.com/ashanbrown/forbidigo"),
|
||||||
linter.NewConfig(golinters.NewIfshort(ifshortCfg)).
|
linter.NewConfig(golinters.NewIfshort(ifshortCfg)).
|
||||||
|
WithSince("v1.36.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/esimonov/ifshort"),
|
WithURL("https://github.com/esimonov/ifshort"),
|
||||||
linter.NewConfig(golinters.NewPredeclared(predeclaredCfg)).
|
linter.NewConfig(golinters.NewPredeclared(predeclaredCfg)).
|
||||||
|
WithSince("v1.35.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/nishanths/predeclared"),
|
WithURL("https://github.com/nishanths/predeclared"),
|
||||||
linter.NewConfig(golinters.NewRevive(reviveCfg)).
|
linter.NewConfig(golinters.NewRevive(reviveCfg)).
|
||||||
|
WithSince("v1.37.0").
|
||||||
WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
|
WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
|
||||||
ConsiderSlow().
|
ConsiderSlow().
|
||||||
WithURL("https://github.com/mgechev/revive"),
|
WithURL("https://github.com/mgechev/revive"),
|
||||||
linter.NewConfig(golinters.NewDurationCheck()).
|
linter.NewConfig(golinters.NewDurationCheck()).
|
||||||
|
WithSince("v1.37.0").
|
||||||
WithPresets(linter.PresetBugs).
|
WithPresets(linter.PresetBugs).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/charithe/durationcheck"),
|
WithURL("https://github.com/charithe/durationcheck"),
|
||||||
linter.NewConfig(golinters.NewWastedAssign()).
|
linter.NewConfig(golinters.NewWastedAssign()).
|
||||||
|
WithSince("v1.38.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/sanposhiho/wastedassign"),
|
WithURL("https://github.com/sanposhiho/wastedassign"),
|
||||||
linter.NewConfig(golinters.NewImportAs(importAsCfg)).
|
linter.NewConfig(golinters.NewImportAs(importAsCfg)).
|
||||||
|
WithSince("v1.38.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/julz/importas"),
|
WithURL("https://github.com/julz/importas"),
|
||||||
linter.NewConfig(golinters.NewNilErr()).
|
linter.NewConfig(golinters.NewNilErr()).
|
||||||
|
WithSince("v1.38.0").
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetBugs).
|
WithPresets(linter.PresetBugs).
|
||||||
WithURL("https://github.com/gostaticanalysis/nilerr"),
|
WithURL("https://github.com/gostaticanalysis/nilerr"),
|
||||||
linter.NewConfig(golinters.NewForceTypeAssert()).
|
linter.NewConfig(golinters.NewForceTypeAssert()).
|
||||||
|
WithSince("v1.38.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/gostaticanalysis/forcetypeassert"),
|
WithURL("https://github.com/gostaticanalysis/forcetypeassert"),
|
||||||
linter.NewConfig(golinters.NewGoModDirectives(goModDirectivesCfg)).
|
linter.NewConfig(golinters.NewGoModDirectives(goModDirectivesCfg)).
|
||||||
|
WithSince("v1.39.0").
|
||||||
WithPresets(linter.PresetStyle, linter.PresetModule).
|
WithPresets(linter.PresetStyle, linter.PresetModule).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/ldez/gomoddirectives"),
|
WithURL("https://github.com/ldez/gomoddirectives"),
|
||||||
|
|
||||||
// nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives
|
// nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives
|
||||||
linter.NewConfig(golinters.NewNoLintLint()).
|
linter.NewConfig(golinters.NewNoLintLint()).
|
||||||
|
WithSince("v1.26.0").
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md"),
|
WithURL("https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md"),
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,16 @@ func NewRunner(cfg *config.Config, log logutils.Log, goenv *goutil.Env, es *lint
|
|||||||
// print deprecated messages
|
// print deprecated messages
|
||||||
if !cfg.InternalCmdTest {
|
if !cfg.InternalCmdTest {
|
||||||
for name, lc := range enabledLinters {
|
for name, lc := range enabledLinters {
|
||||||
if lc.IsDeprecated() {
|
if !lc.IsDeprecated() {
|
||||||
log.Warnf("The linter '%s' is deprecated due to: %s", name, lc.DeprecatedMessage)
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var extra string
|
||||||
|
if lc.Deprecation.Replacement != "" {
|
||||||
|
extra = fmt.Sprintf(" Replaced by %s.", lc.Deprecation.Replacement)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Warnf("The linter '%s' is deprecated (since %s) due to: %s %s", name, lc.Deprecation.Since, lc.Deprecation.Message, extra)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,8 +227,8 @@ func getLintersListMarkdown(enabled bool) string {
|
|||||||
})
|
})
|
||||||
|
|
||||||
lines := []string{
|
lines := []string{
|
||||||
"|Name|Description|Presets|AutoFix|Deprecated|",
|
"|Name|Description|Presets|AutoFix|Since|",
|
||||||
"|---|---|---|---|---|",
|
"|---|---|---|---|---|---|",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, lc := range neededLcs {
|
for _, lc := range neededLcs {
|
||||||
@ -237,7 +237,7 @@ func getLintersListMarkdown(enabled bool) string {
|
|||||||
getDesc(lc),
|
getDesc(lc),
|
||||||
strings.Join(lc.InPresets, ", "),
|
strings.Join(lc.InPresets, ", "),
|
||||||
check(lc.CanAutoFix, "Auto fix supported"),
|
check(lc.CanAutoFix, "Auto fix supported"),
|
||||||
check(lc.DeprecatedMessage != "", "Deprecated"),
|
lc.Since,
|
||||||
)
|
)
|
||||||
lines = append(lines, line)
|
lines = append(lines, line)
|
||||||
}
|
}
|
||||||
@ -252,17 +252,25 @@ func getName(lc *linter.Config) string {
|
|||||||
name = fmt.Sprintf("[%s](%s)", lc.Name(), lc.OriginalURL)
|
name = fmt.Sprintf("[%s](%s)", lc.Name(), lc.OriginalURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
if lc.DeprecatedMessage != "" {
|
if !lc.IsDeprecated() {
|
||||||
name += ` <span title="deprecated">⚠</span>`
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
return name
|
title := "deprecated"
|
||||||
|
if lc.Deprecation.Replacement != "" {
|
||||||
|
title += fmt.Sprintf(" since %s", lc.Deprecation.Since)
|
||||||
|
}
|
||||||
|
|
||||||
|
return name + " " + span(title, "⚠")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDesc(lc *linter.Config) string {
|
func getDesc(lc *linter.Config) string {
|
||||||
desc := lc.Linter.Desc()
|
desc := lc.Linter.Desc()
|
||||||
if lc.DeprecatedMessage != "" {
|
if lc.IsDeprecated() {
|
||||||
desc = lc.DeprecatedMessage
|
desc = lc.Deprecation.Message
|
||||||
|
if lc.Deprecation.Replacement != "" {
|
||||||
|
desc += fmt.Sprintf(" Replaced by %s.", lc.Deprecation.Replacement)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.ReplaceAll(desc, "\n", "<br/>")
|
return strings.ReplaceAll(desc, "\n", "<br/>")
|
||||||
@ -270,11 +278,15 @@ func getDesc(lc *linter.Config) string {
|
|||||||
|
|
||||||
func check(b bool, title string) string {
|
func check(b bool, title string) string {
|
||||||
if b {
|
if b {
|
||||||
return `<span title="` + title + `">✔</span>`
|
return span(title, "✔")
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func span(title, icon string) string {
|
||||||
|
return fmt.Sprintf(`<span title="%s">%s</span>`, title, icon)
|
||||||
|
}
|
||||||
|
|
||||||
func getThanksList() string {
|
func getThanksList() string {
|
||||||
var lines []string
|
var lines []string
|
||||||
addedAuthors := map[string]bool{}
|
addedAuthors := map[string]bool{}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user