Skip to content

Commit 91497f3

Browse files
committed
feat: add deprecation warning about disabled and deprecation linters
1 parent 0cb1418 commit 91497f3

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

docs/src/docs/product/roadmap.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ A linter can be deprecated for various reasons, e.g. the linter stops working wi
4747

4848
The deprecation of a linter will follow 3 phases:
4949

50-
1. **Display of a warning message**: The linter can still be used (unless it's completely non-functional), but it's recommended to remove it from your configuration.
51-
2. **Display of an error message**: At this point, you should remove the linter. The original implementation is replaced by a placeholder that does nothing.
50+
1. **Display of a warning message**: The linter can still be used (unless it's completely non-functional),
51+
but it's recommended to remove it from your configuration.
52+
2. **Display of an error message**: At this point, you should remove the linter.
53+
The original implementation is replaced by a placeholder that does nothing.
54+
The linter is NOT enabled when using `enable-all` and should be removed from the `disable` option.
5255
3. **Removal of the linter** from golangci-lint.
5356

5457
Each phase corresponds to a minor version:

pkg/lint/lintersdb/validator.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99

1010
"github.com/golangci/golangci-lint/pkg/config"
11+
"github.com/golangci/golangci-lint/pkg/lint/linter"
1112
"github.com/golangci/golangci-lint/pkg/logutils"
1213
)
1314

@@ -38,17 +39,30 @@ func (v Validator) Validate(cfg *config.Config) error {
3839
}
3940

4041
func (v Validator) validateLintersNames(cfg *config.Linters) error {
41-
allNames := cfg.Enable
42-
allNames = append(allNames, cfg.Disable...)
43-
4442
var unknownNames []string
4543

46-
for _, name := range allNames {
44+
for _, name := range cfg.Enable {
4745
if v.m.GetLinterConfigs(name) == nil {
4846
unknownNames = append(unknownNames, name)
4947
}
5048
}
5149

50+
for _, name := range cfg.Disable {
51+
lcs := v.m.GetLinterConfigs(name)
52+
if len(lcs) == 0 {
53+
unknownNames = append(unknownNames, name)
54+
continue
55+
}
56+
57+
for _, lc := range lcs {
58+
if lc.IsDeprecated() && lc.Deprecation.Level > linter.DeprecationWarning {
59+
v.m.log.Warnf("The linter %q is deprecated (step 2) and deactivated. "+
60+
"It should be removed from the list of disabled linters. "+
61+
"https://golangci-lint.run/product/roadmap/#linter-deprecation-cycle", lc.Name())
62+
}
63+
}
64+
}
65+
5266
if len(unknownNames) > 0 {
5367
return fmt.Errorf("unknown linters: '%v', run 'golangci-lint help linters' to see the list of supported linters",
5468
strings.Join(unknownNames, ","))

test/run_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ func TestCgoOk(t *testing.T) {
100100
WithNoConfig().
101101
WithArgs("--timeout=3m",
102102
"--enable-all",
103-
"-D",
104-
"nosnakecase",
105103
).
106104
WithArgs("--go=1.22"). // TODO(ldez) remove this line when we will run go1.23 on the CI. (related to intrange, copyloopvar)
107105
WithTargetPath(testdataDir, "cgo").

0 commit comments

Comments
 (0)