You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pkg/golinters/nolintlint/README.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,17 @@
1
1
# nolintlint
2
2
3
-
nolintlint is a Go static analysis tool to find ill-formed or insufficiently explained `//nolint` directives for golangci
3
+
nolintlint is a Go static analysis tool to find ill-formed or insufficiently explained `//nolint` directives for golangci
4
4
(or any other linter, using th )
5
5
6
6
## Purpose
7
7
8
8
To ensure that lint exceptions have explanations. Consider the case below:
9
9
10
10
```Go
11
-
import"crypto/md5"//nolint
11
+
import"crypto/md5"//nolint:all
12
12
13
13
funchash(data []byte) []byte {
14
-
return md5.New().Sum(data) //nolint
14
+
return md5.New().Sum(data) //nolint:all
15
15
}
16
16
```
17
17
@@ -27,5 +27,5 @@ func hash(data []byte) []byte {
27
27
```
28
28
29
29
`nolintlint` can also identify cases where you may have written `// nolint`. Finally `nolintlint`, can also enforce that you
30
-
use the machine-readable nolint directive format `//nolint` and that you mention what linter is being suppressed, as shown above when we write `//nolint:gosec`.
30
+
use the machine-readable nolint directive format `//nolint:all` and that you mention what linter is being suppressed, as shown above when we write `//nolint:gosec`.
Copy file name to clipboardExpand all lines: pkg/golinters/nolintlint/nolintlint_test.go
+13-25
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ import (
12
12
)
13
13
14
14
//nolint:funlen
15
-
funcTestNoLintLint(t*testing.T) {
15
+
funcTestLinter_Run(t*testing.T) {
16
16
typeissueWithReplacementstruct {
17
17
issuestring
18
18
replacement*result.Replacement
@@ -80,21 +80,21 @@ package bar
80
80
func foo() {
81
81
good() //nolint:my-linter
82
82
bad() //nolint
83
-
bad() //nolint // because
83
+
bad() //nolint // because
84
84
}`,
85
85
expected: []issueWithReplacement{
86
86
{issue: "directive `//nolint` should mention specific linter such as `//nolint:my-linter` at testing.go:6:9"},
87
-
{issue: "directive `//nolint // because` should mention specific linter such as `//nolint:my-linter` at testing.go:7:9"},
87
+
{issue: "directive `//nolint // because` should mention specific linter such as `//nolint:my-linter` at testing.go:7:9"},
88
88
},
89
89
},
90
90
{
91
-
desc: "when machine-readable style isn't used",
92
-
needs: NeedsMachineOnly,
91
+
desc: "when machine-readable style isn't used",
93
92
contents: `
94
93
package bar
95
94
96
95
func foo() {
97
96
bad() // nolint
97
+
bad() // nolint
98
98
good() //nolint
99
99
}`,
100
100
expected: []issueWithReplacement{
@@ -108,25 +108,13 @@ func foo() {
108
108
},
109
109
},
110
110
},
111
-
},
112
-
},
113
-
{
114
-
desc: "extra spaces in front of directive are reported",
115
-
contents: `
116
-
package bar
117
-
118
-
func foo() {
119
-
bad() // nolint
120
-
good() // nolint
121
-
}`,
122
-
expected: []issueWithReplacement{
123
111
{
124
-
issue: "directive `// nolint` should not have more than one leading space at testing.go:5:9",
112
+
issue: "directive `// nolint` should be written without leading space as `//nolint` at testing.go:6:9",
125
113
replacement: &result.Replacement{
126
114
Inline: &result.InlineFix{
127
115
StartCol: 10,
128
-
Length: 2,
129
-
NewString: "",
116
+
Length: 3,
117
+
NewString: "",
130
118
},
131
119
},
132
120
},
@@ -138,13 +126,13 @@ func foo() {
138
126
package bar
139
127
140
128
func foo() {
141
-
good() //nolint:linter1,linter-two
142
-
bad() //nolint:linter1 linter2
143
-
good() //nolint: linter1,linter2
144
-
good() //nolint: linter1, linter2
129
+
good() //nolint:linter1,linter-two
130
+
bad() //nolint:linter1 linter2
131
+
good() //nolint: linter1,linter2
132
+
good() //nolint: linter1, linter2
145
133
}`,
146
134
expected: []issueWithReplacement{
147
-
{issue: "directive `//nolint:linter1 linter2` should match `//nolint[:<comma-separated-linters>] [// <explanation>]` at testing.go:6:9"}, //nolint:lll // this is a string
135
+
{issue: "directive `//nolint:linter1 linter2` should match `//nolint[:<comma-separated-linters>] [// <explanation>]` at testing.go:6:9"}, //nolint:lll // this is a string
0 commit comments