@@ -7,7 +7,7 @@ import 'package:analyzer_testing/utilities/utilities.dart';
77import 'package:linter/src/lint_codes.dart' ;
88import 'package:test_reflective_loader/test_reflective_loader.dart' ;
99
10- import '../src/dart/resolution/context_collection_resolution.dart' ;
10+ import '../../ src/dart/resolution/context_collection_resolution.dart' ;
1111
1212main () {
1313 defineReflectiveSuite (() {
@@ -30,7 +30,7 @@ class ErrorSuppressionTest extends PubPackageResolutionTest {
3030 );
3131 }
3232
33- test_error_code_mismatch () async {
33+ test_codeMismatch () async {
3434 await assertErrorsInCode (
3535 '''
3636// ignore: $ignoredCode
@@ -44,7 +44,7 @@ int _y = 0; //INVALID_ASSIGNMENT
4444 );
4545 }
4646
47- test_ignore_first () async {
47+ test_ignoreFirstOfMultiple () async {
4848 await assertErrorsInCode (
4949 '''
5050// ignore: unnecessary_cast
@@ -56,7 +56,7 @@ var y = x + ''; //ARGUMENT_TYPE_NOT_ASSIGNABLE
5656 );
5757 }
5858
59- test_ignore_first_trailing () async {
59+ test_ignoreFirstOfMultipleWithTrailingComment () async {
6060 await assertErrorsInCode (
6161 '''
6262int x = (0 as int); // ignore: unnecessary_cast
@@ -67,7 +67,7 @@ var y = x + ''; //ARGUMENT_TYPE_NOT_ASSIGNABLE
6767 );
6868 }
6969
70- test_ignore_for_file () async {
70+ test_ignoreForFile () async {
7171 await assertErrorsInCode (
7272 '''
7373int x = (0 as int); //UNNECESSARY_CAST
@@ -78,21 +78,55 @@ var y = x + ''; //ARGUMENT_TYPE_NOT_ASSIGNABLE
7878 );
7979 }
8080
81- test_ignore_for_file_whitespace_variant () async {
81+ test_ignoreForFileWithMuchWhitespace () async {
8282 await assertNoErrorsInCode ('''
8383//ignore_for_file: unused_element , unnecessary_cast
8484int x = (0 as int); //UNNECESSARY_CAST
8585String _foo = ''; //UNUSED_ELEMENT
8686''' );
8787 }
8888
89- test_ignore_only_trailing () async {
89+ test_ignoreForFileWithTypeMatchesLint () async {
90+ await assertNoErrorsInCode ('''
91+ // ignore_for_file: type=lint
92+ void f(arg1(int)) {} // AVOID_TYPES_AS_PARAMETER_NAMES
93+ ''' );
94+ }
95+
96+ test_ignoreForFileWithTypeMatchesUpperCase () async {
97+ await assertNoErrorsInCode ('''
98+ // ignore_for_file: TYPE=LINT
99+ void f(arg1(int)) {} // AVOID_TYPES_AS_PARAMETER_NAMES
100+ ''' );
101+ }
102+
103+ test_ignoreForFileWithTypeMatchesWarning () async {
104+ await assertNoErrorsInCode ('''
105+ // ignore_for_file: type=warning
106+ void f() {
107+ var x = 1;
108+ }
109+ ''' );
110+ }
111+
112+ test_ignoreForFileWithTypeMismatchLintVsWarning () async {
113+ await assertErrorsInCode (
114+ '''
115+ // ignore_for_file: type=lint
116+ int a = 0;
117+ int _x = 1;
118+ ''' ,
119+ [error (WarningCode .UNUSED_ELEMENT , 45 , 2 )],
120+ );
121+ }
122+
123+ test_ignoreOnlyDiagnosticWithTrailingComment () async {
90124 await assertNoErrorsInCode ('''
91125int x = (0 as int); // ignore: unnecessary_cast
92126''' );
93127 }
94128
95- test_ignore_second () async {
129+ test_ignoreSecondDiagnostic () async {
96130 await assertErrorsInCode (
97131 '''
98132//UNNECESSARY_CAST
@@ -104,7 +138,7 @@ String _foo = ''; //UNUSED_ELEMENT
104138 );
105139 }
106140
107- test_ignore_second_trailing () async {
141+ test_ignoreSecondDiagnosticWithTrailingComment () async {
108142 await assertErrorsInCode (
109143 '''
110144//UNNECESSARY_CAST
@@ -115,7 +149,40 @@ String _foo = ''; // ignore: $ignoredCode
115149 );
116150 }
117151
118- test_ignore_uniqueName () async {
152+ test_ignoreTypeMatches () async {
153+ await assertNoErrorsInCode ('''
154+ // ignore: type=lint
155+ void f(arg1(int)) {} // AVOID_TYPES_AS_PARAMETER_NAMES
156+ ''' );
157+ }
158+
159+ test_ignoreTypeMismatchLintVsWarning () async {
160+ await assertErrorsInCode (
161+ '''
162+ // ignore: type=lint
163+ int _x = 1;
164+ ''' ,
165+ [error (WarningCode .UNUSED_ELEMENT , 25 , 2 )],
166+ );
167+ }
168+
169+ test_ignoreTypeWithBadType () async {
170+ await assertErrorsInCode (
171+ '''
172+ // ignore: type=wrong
173+ void f(arg1(int)) {} // AVOID_TYPES_AS_PARAMETER_NAMES
174+ ''' ,
175+ [
176+ error (
177+ LinterLintCode .avoid_types_as_parameter_names_formal_parameter,
178+ 34 ,
179+ 3 ,
180+ ),
181+ ],
182+ );
183+ }
184+
185+ test_ignoreUniqueName () async {
119186 writeTestPackageConfigWithMeta ();
120187 await assertNoErrorsInCode ('''
121188import 'package:meta/meta.dart';
@@ -127,13 +194,13 @@ int x = f();
127194''' );
128195 }
129196
130- test_ignore_upper_case () async {
197+ test_ignoreUpperCase () async {
131198 await assertNoErrorsInCode ('''
132199int x = (0 as int); // ignore: UNNECESSARY_CAST
133200''' );
134201 }
135202
136- test_invalid_error_code () async {
203+ test_invalidCode () async {
137204 await assertErrorsInCode (
138205 '''
139206// ignore: right_format_wrong_code
@@ -147,7 +214,7 @@ var y = x + ''; //ARGUMENT_TYPE_NOT_ASSIGNABLE
147214 );
148215 }
149216
150- test_missing_error_codes () async {
217+ test_missingCodes () async {
151218 await assertErrorsInCode (
152219 '''
153220int x = 3;
@@ -161,7 +228,7 @@ String y = x + ''; //INVALID_ASSIGNMENT, ARGUMENT_TYPE_NOT_ASSIGNABLE
161228 );
162229 }
163230
164- test_missing_metadata_suffix () async {
231+ test_missingMetadataSuffix () async {
165232 await assertErrorsInCode (
166233 '''
167234// ignore invalid_assignment
@@ -171,41 +238,41 @@ String y = 3; //INVALID_ASSIGNMENT
171238 );
172239 }
173240
174- test_multiple_comments () async {
175- await assertErrorsInCode (
176- '''
177- int x = (0 as int); //This is the first comment...
178- // ignore: $ignoredCode
179- String _foo = ''; //UNUSED_ELEMENT
180- ''' ,
181- [error (WarningCode .UNNECESSARY_CAST , 9 , 8 )],
182- );
241+ test_multipleCodesInIgnore () async {
242+ await assertNoErrorsInCode ('''
243+ int x = 3;
244+ // ignore: unnecessary_cast, $ignoredCode
245+ int _y = x as int; //UNNECESSARY_CAST, UNUSED_ELEMENT
246+ ''' );
183247 }
184248
185- test_multiple_ignore_for_files () async {
249+ test_multipleCodesInIgnoreForFile () async {
186250 await assertNoErrorsInCode ('''
187251int x = (0 as int); //UNNECESSARY_CAST
188252String _foo = ''; //UNUSED_ELEMENT
189253// ignore_for_file: unnecessary_cast,$ignoredCode
190254''' );
191255 }
192256
193- test_multiple_ignores () async {
257+ test_multipleCodesInIgnoreTrailingComment () async {
194258 await assertNoErrorsInCode ('''
195259int x = 3;
196- // ignore: unnecessary_cast, $ignoredCode
197- int _y = x as int; //UNNECESSARY_CAST, UNUSED_ELEMENT
260+ int _y = x as int; // ignore: unnecessary_cast, $ignoredCode
198261''' );
199262 }
200263
201- test_multiple_ignores_trailing () async {
202- await assertNoErrorsInCode ('''
203- int x = 3;
204- int _y = x as int; // ignore: unnecessary_cast, $ignoredCode
205- ''' );
264+ test_multipleCommentsPreceding () async {
265+ await assertErrorsInCode (
266+ '''
267+ int x = (0 as int); //This is the first comment...
268+ // ignore: $ignoredCode
269+ String _foo = ''; //UNUSED_ELEMENT
270+ ''' ,
271+ [error (WarningCode .UNNECESSARY_CAST , 9 , 8 )],
272+ );
206273 }
207274
208- test_no_ignores () async {
275+ test_noIgnores () async {
209276 await assertErrorsInCode (
210277 '''
211278int x = ''; //INVALID_ASSIGNMENT
@@ -218,7 +285,7 @@ var y = x + ''; //ARGUMENT_TYPE_NOT_ASSIGNABLE
218285 );
219286 }
220287
221- test_trailing_not_above () async {
288+ test_trailingCommentDoesNotCountAsAbove () async {
222289 await assertErrorsInCode (
223290 '''
224291int x = (0 as int); // ignore: unnecessary_cast
@@ -228,81 +295,14 @@ int y = (0 as int);
228295 );
229296 }
230297
231- test_type_ignore_badType () async {
232- await assertErrorsInCode (
233- '''
234- // ignore: type=wrong
235- void f(arg1(int)) {} // AVOID_TYPES_AS_PARAMETER_NAMES
236- ''' ,
237- [
238- error (
239- LinterLintCode .avoid_types_as_parameter_names_formal_parameter,
240- 34 ,
241- 3 ,
242- ),
243- ],
244- );
245- }
246-
247- test_type_ignore_match () async {
248- await assertNoErrorsInCode ('''
249- // ignore: type=lint
250- void f(arg1(int)) {} // AVOID_TYPES_AS_PARAMETER_NAMES
251- ''' );
252- }
253-
254- test_type_ignore_mismatch_lintVsWarning () async {
255- await assertErrorsInCode (
256- '''
257- // ignore: type=lint
258- int _x = 1;
259- ''' ,
260- [error (WarningCode .UNUSED_ELEMENT , 25 , 2 )],
261- );
262- }
263-
264- test_type_ignoreForFile_match_lint () async {
265- await assertNoErrorsInCode ('''
266- // ignore_for_file: type=lint
267- void f(arg1(int)) {} // AVOID_TYPES_AS_PARAMETER_NAMES
268- ''' );
269- }
270-
271- test_type_ignoreForFile_match_upperCase () async {
272- await assertNoErrorsInCode ('''
273- // ignore_for_file: TYPE=LINT
274- void f(arg1(int)) {} // AVOID_TYPES_AS_PARAMETER_NAMES
275- ''' );
276- }
277-
278- test_type_ignoreForFile_match_warning () async {
279- await assertNoErrorsInCode ('''
280- // ignore_for_file: type=warning
281- void f() {
282- var x = 1;
283- }
284- ''' );
285- }
286-
287- test_type_ignoreForFile_mismatch_lintVsWarning () async {
288- await assertErrorsInCode (
289- '''
290- // ignore_for_file: type=lint
291- int a = 0;
292- int _x = 1;
293- ''' ,
294- [error (WarningCode .UNUSED_ELEMENT , 45 , 2 )],
295- );
296- }
297-
298- test_undefined_function_within_flutter_can_be_ignored () async {
298+ test_undefinedFunctionWithinFlutterCanBeIgnored () async {
299299 await assertErrorsInFile ('$workspaceRootPath /flutterlib/flutter.dart' , '''
300300// ignore: undefined_function
301301f() => g();
302302''' , []);
303303 }
304304
305- test_undefined_function_within_flutter_without_ignore () async {
305+ test_undefinedFunctionWithinFlutterWithoutIgnore () async {
306306 await assertErrorsInFile (
307307 '$workspaceRootPath /flutterlib/flutter.dart' ,
308308 '''
@@ -312,7 +312,7 @@ f() => g();
312312 );
313313 }
314314
315- test_undefined_prefixed_name_within_flutter_can_be_ignored () async {
315+ test_undefinedPrefixedNameWithinFlutterCanBeIgnored () async {
316316 await assertErrorsInFile ('$workspaceRootPath /flutterlib/flutter.dart' , '''
317317import 'dart:collection' as c;
318318// ignore: undefined_prefixed_name
0 commit comments