@@ -122,6 +122,41 @@ func TestNolint(t *testing.T) {
122
122
}
123
123
}
124
124
125
+ func newNolintRangeFileIssue (line int , fromLinter string ) result.Issue {
126
+ return result.Issue {
127
+ Pos : token.Position {
128
+ Filename : filepath .Join ("testdata" , "nolintrange.go" ),
129
+ Line : line ,
130
+ },
131
+ FromLinter : fromLinter ,
132
+ }
133
+ }
134
+
135
+ func TestNolintRange (t * testing.T ) {
136
+ p := newTestNolintProcessor (getMockLog ())
137
+ defer p .Finish ()
138
+
139
+ // normal nolint range
140
+ for i := 3 ; i <= 6 ; i ++ {
141
+ processAssertEmpty (t , p , newNolintRangeFileIssue (i , "gofmt" ))
142
+ }
143
+
144
+ processAssertSame (t , p , newNolintRangeFileIssue (7 , "any" ))
145
+
146
+ // nested nolint range
147
+ for i := 8 ; i <= 13 ; i ++ {
148
+ processAssertEmpty (t , p , newNolintRangeFileIssue (i , "unused" ))
149
+ }
150
+ for i := 9 ; i <= 12 ; i ++ {
151
+ processAssertEmpty (t , p , newNolintRangeFileIssue (i , "gofmt" ))
152
+ }
153
+
154
+ // nolint range without nolint-end
155
+ for i := 15 ; i <= 20 ; i ++ {
156
+ processAssertEmpty (t , p , newNolintRangeFileIssue (i , "deadcode" ))
157
+ }
158
+ }
159
+
125
160
func TestNolintInvalidLinterName (t * testing.T ) {
126
161
fileName := filepath .Join ("testdata" , "nolint_bad_names.go" )
127
162
issues := []result.Issue {
0 commit comments