Skip to content

Commit 950f08f

Browse files
pqCommit Queue
authored andcommitted
[element model] migrate no_solo_tests check
Bug: https://github.com/dart-lang/linter/issues/5099 Change-Id: I3659da3539f07072e8ecabfccb5f472818510017 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389141 Auto-Submit: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent a1c7ce3 commit 950f08f

File tree

3 files changed

+316
-13
lines changed

3 files changed

+316
-13
lines changed

pkg/linter/analyzer_use_new_elements.txt

Lines changed: 301 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
lib/src/analyzer.dart
2+
lib/src/lint_names.dart
3+
lib/src/linter_lint_codes.dart
4+
lib/src/rules.dart
15
lib/src/rules/always_declare_return_types.dart
26
lib/src/rules/always_put_control_body_on_new_line.dart
37
lib/src/rules/always_put_required_named_parameters_first.dart
@@ -163,3 +167,300 @@ lib/src/rules/use_test_throws_matchers.dart
163167
lib/src/rules/use_to_and_as_if_applicable.dart
164168
lib/src/rules/use_truncating_division.dart
165169
lib/src/rules/valid_regexps.dart
170+
lib/src/test_utilities/analyzer_utils.dart
171+
lib/src/test_utilities/annotation.dart
172+
lib/src/test_utilities/formatter.dart
173+
lib/src/test_utilities/test_linter.dart
174+
lib/src/test_utilities/test_resource_provider.dart
175+
lib/src/util/ascii_utils.dart
176+
lib/src/util/charcodes.dart
177+
lib/src/utils.dart
178+
test/all.dart
179+
test/annotation_test.dart
180+
test/ascii_utils_test.dart
181+
test/canonicalization_test.dart
182+
test/directives_ordering_test.dart
183+
test/doc_test.dart
184+
test/engine_test.dart
185+
test/formatter_test.dart
186+
test/integration_test.dart
187+
test/lint_code_test.dart
188+
test/mocks.dart
189+
test/pubspec_test.dart
190+
test/rule_test.dart
191+
test/rule_test_support.dart
192+
test/rules/all.dart
193+
test/rules/always_declare_return_types_test.dart
194+
test/rules/always_put_control_body_on_new_line_test.dart
195+
test/rules/always_put_required_named_parameters_first_test.dart
196+
test/rules/always_specify_types_test.dart
197+
test/rules/always_use_package_imports_test.dart
198+
test/rules/analyzer_use_new_elements_test.dart
199+
test/rules/annotate_overrides_test.dart
200+
test/rules/annotate_redeclares_test.dart
201+
test/rules/avoid_annotating_with_dynamic_test.dart
202+
test/rules/avoid_bool_literals_in_conditional_expressions_test.dart
203+
test/rules/avoid_catches_without_on_clauses_test.dart
204+
test/rules/avoid_catching_errors_test.dart
205+
test/rules/avoid_classes_with_only_static_members_test.dart
206+
test/rules/avoid_double_and_int_checks_test.dart
207+
test/rules/avoid_dynamic_calls_test.dart
208+
test/rules/avoid_empty_else_test.dart
209+
test/rules/avoid_equals_and_hash_code_on_mutable_classes_test.dart
210+
test/rules/avoid_escaping_inner_quotes_test.dart
211+
test/rules/avoid_field_initializers_in_const_classes_test.dart
212+
test/rules/avoid_field_initializers_in_non_const_classes_test.dart
213+
test/rules/avoid_final_parameters_test.dart
214+
test/rules/avoid_function_literals_in_foreach_calls_test.dart
215+
test/rules/avoid_futureor_void_test.dart
216+
test/rules/avoid_implementing_value_types_test.dart
217+
test/rules/avoid_init_to_null_test.dart
218+
test/rules/avoid_js_rounded_ints_test.dart
219+
test/rules/avoid_multiple_declarations_per_line_test.dart
220+
test/rules/avoid_null_checks_in_equality_operators_test.dart
221+
test/rules/avoid_positional_boolean_parameters_test.dart
222+
test/rules/avoid_print_test.dart
223+
test/rules/avoid_private_typedef_functions_test.dart
224+
test/rules/avoid_redundant_argument_values_test.dart
225+
test/rules/avoid_relative_lib_imports_test.dart
226+
test/rules/avoid_renaming_method_parameters_test.dart
227+
test/rules/avoid_return_types_on_setters_test.dart
228+
test/rules/avoid_returning_null_for_void_test.dart
229+
test/rules/avoid_returning_null_test.dart
230+
test/rules/avoid_returning_this_test.dart
231+
test/rules/avoid_setters_without_getters_test.dart
232+
test/rules/avoid_shadowing_type_parameters_test.dart
233+
test/rules/avoid_single_cascade_in_expression_statements_test.dart
234+
test/rules/avoid_slow_async_io_test.dart
235+
test/rules/avoid_type_to_string_test.dart
236+
test/rules/avoid_types_as_parameter_names_test.dart
237+
test/rules/avoid_types_on_closure_parameters_test.dart
238+
test/rules/avoid_unnecessary_containers_test.dart
239+
test/rules/avoid_unused_constructor_parameters_test.dart
240+
test/rules/avoid_void_async_test.dart
241+
test/rules/avoid_web_libraries_in_flutter_test.dart
242+
test/rules/await_only_futures_test.dart
243+
test/rules/camel_case_extensions_test.dart
244+
test/rules/camel_case_types_test.dart
245+
test/rules/cancel_subscriptions_test.dart
246+
test/rules/cascade_invocations_test.dart
247+
test/rules/cast_nullable_to_non_nullable_test.dart
248+
test/rules/close_sinks_test.dart
249+
test/rules/collection_methods_unrelated_type_test.dart
250+
test/rules/combinators_ordering_test.dart
251+
test/rules/comment_references_test.dart
252+
test/rules/conditional_uri_does_not_exist_test.dart
253+
test/rules/constant_identifier_names_test.dart
254+
test/rules/control_flow_in_finally_test.dart
255+
test/rules/curly_braces_in_flow_control_structures_test.dart
256+
test/rules/dangling_library_doc_comments_test.dart
257+
test/rules/depend_on_referenced_packages_test.dart
258+
test/rules/deprecated_consistency_test.dart
259+
test/rules/deprecated_member_use_from_same_package_test.dart
260+
test/rules/diagnostic_describe_all_properties_test.dart
261+
test/rules/directives_ordering_test.dart
262+
test/rules/discarded_futures_test.dart
263+
test/rules/do_not_use_environment_test.dart
264+
test/rules/document_ignores_test.dart
265+
test/rules/empty_catches_test.dart
266+
test/rules/empty_constructor_bodies_test.dart
267+
test/rules/empty_statements_test.dart
268+
test/rules/eol_at_end_of_file_test.dart
269+
test/rules/erase_dart_type_extension_types_test.dart
270+
test/rules/exhaustive_cases_test.dart
271+
test/rules/file_names_test.dart
272+
test/rules/flutter_style_todos_test.dart
273+
test/rules/hash_and_equals_test.dart
274+
test/rules/implementation_imports_test.dart
275+
test/rules/implicit_call_tearoffs_test.dart
276+
test/rules/implicit_reopen_test.dart
277+
test/rules/invalid_case_patterns_test.dart
278+
test/rules/invalid_runtime_check_with_js_interop_types_test.dart
279+
test/rules/join_return_with_assignment_test.dart
280+
test/rules/leading_newlines_in_multiline_strings_test.dart
281+
test/rules/library_annotations_test.dart
282+
test/rules/library_names_test.dart
283+
test/rules/library_prefixes_test.dart
284+
test/rules/library_private_types_in_public_api_test.dart
285+
test/rules/lines_longer_than_80_chars_test.dart
286+
test/rules/literal_only_boolean_expressions_test.dart
287+
test/rules/matching_super_parameters_test.dart
288+
test/rules/missing_code_block_language_in_doc_comment_test.dart
289+
test/rules/missing_whitespace_between_adjacent_strings_test.dart
290+
test/rules/no_adjacent_strings_in_list_test.dart
291+
test/rules/no_duplicate_case_values_test.dart
292+
test/rules/no_leading_underscores_for_library_prefixes_test.dart
293+
test/rules/no_leading_underscores_for_local_identifiers_test.dart
294+
test/rules/no_literal_bool_comparisons_test.dart
295+
test/rules/no_logic_in_create_state_test.dart
296+
test/rules/no_runtimeType_toString_test.dart
297+
test/rules/no_self_assignments_test.dart
298+
test/rules/no_wildcard_variable_uses_test.dart
299+
test/rules/non_constant_identifier_names_test.dart
300+
test/rules/noop_primitive_operations_test.dart
301+
test/rules/null_check_on_nullable_type_parameter_test.dart
302+
test/rules/null_closures_test.dart
303+
test/rules/omit_local_variable_types_test.dart
304+
test/rules/omit_obvious_local_variable_types_test.dart
305+
test/rules/one_member_abstracts_test.dart
306+
test/rules/only_throw_errors_test.dart
307+
test/rules/overridden_fields_test.dart
308+
test/rules/package_api_docs_test.dart
309+
test/rules/package_names_test.dart
310+
test/rules/package_prefixed_library_names_test.dart
311+
test/rules/parameter_assignments_test.dart
312+
test/rules/prefer_adjacent_string_concatenation_test.dart
313+
test/rules/prefer_asserts_in_initializer_lists_test.dart
314+
test/rules/prefer_asserts_with_message_test.dart
315+
test/rules/prefer_collection_literals_test.dart
316+
test/rules/prefer_conditional_assignment_test.dart
317+
test/rules/prefer_const_constructors_in_immutables_test.dart
318+
test/rules/prefer_const_constructors_test.dart
319+
test/rules/prefer_const_declarations_test.dart
320+
test/rules/prefer_const_literals_to_create_immutables_test.dart
321+
test/rules/prefer_constructors_over_static_methods_test.dart
322+
test/rules/prefer_contains_test.dart
323+
test/rules/prefer_double_quotes_test.dart
324+
test/rules/prefer_expression_function_bodies_test.dart
325+
test/rules/prefer_final_fields_test.dart
326+
test/rules/prefer_final_in_for_each_test.dart
327+
test/rules/prefer_final_locals_test.dart
328+
test/rules/prefer_final_parameters_test.dart
329+
test/rules/prefer_for_elements_to_map_fromIterable_test.dart
330+
test/rules/prefer_foreach_test.dart
331+
test/rules/prefer_function_declarations_over_variables_test.dart
332+
test/rules/prefer_generic_function_type_aliases_test.dart
333+
test/rules/prefer_if_elements_to_conditional_expressions_test.dart
334+
test/rules/prefer_if_null_operators_test.dart
335+
test/rules/prefer_initializing_formals_test.dart
336+
test/rules/prefer_inlined_adds_test.dart
337+
test/rules/prefer_int_literals_test.dart
338+
test/rules/prefer_interpolation_to_compose_strings_test.dart
339+
test/rules/prefer_is_empty_test.dart
340+
test/rules/prefer_iterable_whereType_test.dart
341+
test/rules/prefer_mixin_test.dart
342+
test/rules/prefer_null_aware_method_calls_test.dart
343+
test/rules/prefer_null_aware_operators_test.dart
344+
test/rules/prefer_relative_imports_test.dart
345+
test/rules/prefer_single_quotes_test.dart
346+
test/rules/prefer_spread_collections_test.dart
347+
test/rules/prefer_typing_uninitialized_variables_test.dart
348+
test/rules/prefer_void_to_null_test.dart
349+
test/rules/provide_deprecation_message_test.dart
350+
test/rules/public_member_api_docs_test.dart
351+
test/rules/recursive_getters_test.dart
352+
test/rules/require_trailing_commas_test.dart
353+
test/rules/secure_pubspec_urls_test.dart
354+
test/rules/sized_box_for_whitespace_test.dart
355+
test/rules/sized_box_shrink_expand_test.dart
356+
test/rules/slash_for_doc_comments_test.dart
357+
test/rules/sort_child_properties_last_test.dart
358+
test/rules/sort_constructors_first_test.dart
359+
test/rules/sort_pub_dependencies_test.dart
360+
test/rules/sort_unnamed_constructors_first_test.dart
361+
test/rules/specify_nonobvious_local_variable_types_test.dart
362+
test/rules/test_types_in_equals_test.dart
363+
test/rules/throw_in_finally_test.dart
364+
test/rules/tighten_type_of_initializing_formals_test.dart
365+
test/rules/type_annotate_public_apis_test.dart
366+
test/rules/type_init_formals_test.dart
367+
test/rules/type_literal_in_constant_pattern_test.dart
368+
test/rules/unawaited_futures_test.dart
369+
test/rules/unintended_html_in_doc_comment_test.dart
370+
test/rules/unnecessary_await_in_return_test.dart
371+
test/rules/unnecessary_brace_in_string_interps_test.dart
372+
test/rules/unnecessary_breaks_test.dart
373+
test/rules/unnecessary_const_test.dart
374+
test/rules/unnecessary_constructor_name_test.dart
375+
test/rules/unnecessary_final_test.dart
376+
test/rules/unnecessary_getters_setters_test.dart
377+
test/rules/unnecessary_lambdas_test.dart
378+
test/rules/unnecessary_late_test.dart
379+
test/rules/unnecessary_library_directive_test.dart
380+
test/rules/unnecessary_library_name_test.dart
381+
test/rules/unnecessary_new_test.dart
382+
test/rules/unnecessary_null_aware_assignments_test.dart
383+
test/rules/unnecessary_null_aware_operator_on_extension_on_nullable_test.dart
384+
test/rules/unnecessary_null_checks_test.dart
385+
test/rules/unnecessary_null_in_if_null_operators_test.dart
386+
test/rules/unnecessary_nullable_for_final_variable_declarations_test.dart
387+
test/rules/unnecessary_overrides_test.dart
388+
test/rules/unnecessary_parenthesis_test.dart
389+
test/rules/unnecessary_raw_strings_test.dart
390+
test/rules/unnecessary_statements_test.dart
391+
test/rules/unnecessary_string_escapes_test.dart
392+
test/rules/unnecessary_string_interpolations_test.dart
393+
test/rules/unnecessary_this_test.dart
394+
test/rules/unnecessary_to_list_in_spreads_test.dart
395+
test/rules/unreachable_from_main_test.dart
396+
test/rules/unrelated_type_equality_checks_test.dart
397+
test/rules/unsafe_html_test.dart
398+
test/rules/use_colored_box_test.dart
399+
test/rules/use_decorated_box_test.dart
400+
test/rules/use_enums_test.dart
401+
test/rules/use_full_hex_values_for_flutter_colors_test.dart
402+
test/rules/use_function_type_syntax_for_parameters_test.dart
403+
test/rules/use_if_null_to_convert_nulls_to_bools_test.dart
404+
test/rules/use_is_even_rather_than_modulo_test.dart
405+
test/rules/use_key_in_widget_constructors_test.dart
406+
test/rules/use_late_for_private_fields_and_variables_test.dart
407+
test/rules/use_named_constants_test.dart
408+
test/rules/use_raw_strings_test.dart
409+
test/rules/use_rethrow_when_possible_test.dart
410+
test/rules/use_setters_to_change_properties_test.dart
411+
test/rules/use_string_buffers_test.dart
412+
test/rules/use_string_in_part_of_directives_test.dart
413+
test/rules/use_super_parameters_test.dart
414+
test/rules/use_test_throws_matchers_test.dart
415+
test/rules/use_to_and_as_if_applicable_test.dart
416+
test/rules/use_truncating_division_test.dart
417+
test/rules/valid_regexps_test.dart
418+
test/rules/void_checks_test.dart
419+
test/test_constants.dart
420+
test/unmocked_sdk_rule_test.dart
421+
test/util/annotation.dart
422+
test/util/annotation_matcher.dart
423+
test/util/rule_debug.dart
424+
test/util/test_resource_provider.dart
425+
test/util/test_utils.dart
426+
test/utils_test.dart
427+
test/validate_incompatible_rules_test.dart
428+
test/validate_no_rule_description_references_test.dart
429+
test/validate_rule_description_format_test.dart
430+
test/verify_checks_test.dart
431+
test/verify_generated_codes_test.dart
432+
test/verify_reflective_test_suites_test.dart
433+
test_data/rules/no_default_cases.dart
434+
test_data/rules/overridden_fields.dart
435+
test_data/rules/prefer_const_declarations.dart
436+
test_data/rules/prefer_final_fields.dart
437+
test_data/rules/prefer_is_not_empty.dart
438+
test_data/rules/prefer_is_not_operator.dart
439+
test_data/rules/prefer_void_to_null.dart
440+
test_data/rules/require_trailing_commas.dart
441+
test_data/rules/type_init_formals.dart
442+
test_data/rules/unawaited_futures.dart
443+
test_data/rules/unmocked/unsafe_html.dart
444+
test_data/rules/unnecessary_lambdas.dart
445+
test_data/rules/unnecessary_parenthesis.dart
446+
test_data/rules/void_checks.dart
447+
tool/changelog.dart
448+
tool/checks/check_all_yaml.dart
449+
tool/checks/check_messages_yaml.dart
450+
tool/checks/driver.dart
451+
tool/checks/rules/no_solo_tests.dart
452+
tool/checks/rules/no_trailing_spaces.dart
453+
tool/cli.dart
454+
tool/codes/generate.dart
455+
tool/labeler/issue_config.dart
456+
tool/labeler/pr_config.dart
457+
tool/legacy_test_move.dart
458+
tool/lint_sets.dart
459+
tool/machine.dart
460+
tool/messages_info.dart
461+
tool/migrate.dart
462+
tool/parse.dart
463+
tool/rule.dart
464+
tool/scorecard.dart
465+
tool/spelunk.dart
466+
tool/util/path_utils.dart

pkg/linter/tool/checks/rules/no_solo_tests.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import 'package:analyzer/dart/ast/ast.dart';
66
import 'package:analyzer/dart/ast/visitor.dart';
7-
import 'package:analyzer/dart/element/element.dart';
7+
import 'package:analyzer/dart/element/element2.dart';
88
import 'package:linter/src/analyzer.dart';
99

1010
const _desc = r"Don't commit soloed tests.";
@@ -58,9 +58,9 @@ class _Visitor extends SimpleAstVisitor<void> {
5858

5959
extension on Annotation {
6060
bool get isSoloTest {
61-
var element = this.element;
62-
return element is PropertyAccessorElement &&
61+
var element = element2;
62+
return element is GetterElement &&
6363
element.name == 'soloTest' &&
64-
element.library.name == 'test_reflective_loader';
64+
element.library2?.name == 'test_reflective_loader';
6565
}
6666
}

pkg/linter/tool/migrate.dart

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'package:analyzer/error/error.dart';
1010
import 'package:args/args.dart';
1111
import 'package:collection/collection.dart';
1212
import 'package:linter/src/rules/analyzer_use_new_elements.dart';
13+
import 'package:path/path.dart' as path;
1314

1415
import 'checks/driver.dart';
1516

@@ -19,15 +20,16 @@ main(List<String> args) async {
1920
..addFlag('write',
2021
abbr: 'w', help: 'Write updated `analyzer_use_new_elements.txt` file.');
2122

22-
var errors = await getOldElementModelAccesses(rulesDir.absolute.path);
23+
var errors =
24+
await getOldElementModelAccesses(directoryToMigrate.absolute.path);
2325

2426
var errorFiles = <String>{};
2527
for (var error in errors) {
2628
errorFiles.add(error.source.fullName);
2729
}
2830

2931
var migratedFiles =
30-
ruleFiles.where((rule) => !errorFiles.any((f) => f.endsWith(rule)));
32+
filesToMigrate.where((file) => !errorFiles.any((f) => f.endsWith(file)));
3133

3234
var options = parser.parse(args);
3335
if (options['write'] == true) {
@@ -44,21 +46,21 @@ main(List<String> args) async {
4446
}
4547

4648
print('Unmigrated files:\n\n');
47-
for (var rule in ruleFiles) {
48-
if (!migratedFiles.contains(rule)) {
49-
print(rule);
49+
for (var file in filesToMigrate) {
50+
if (!migratedFiles.contains(file)) {
51+
print(file);
5052
}
5153
}
5254
}
5355

54-
final List<String> ruleFiles = rulesDir
56+
final Directory directoryToMigrate = Directory.current;
57+
58+
final List<String> filesToMigrate = directoryToMigrate
5559
.listSync(recursive: true)
5660
.where((f) => f.path.endsWith('.dart'))
57-
.map((r) => r.path)
61+
.map((r) => path.relative(r.path, from: directoryToMigrate.path))
5862
.sorted();
5963

60-
final Directory rulesDir = Directory('lib/src/rules');
61-
6264
Future<List<AnalysisError>> getOldElementModelAccesses(String directory) async {
6365
var results = await Driver([AnalyzerUseNewElements(useOptInFile: false)])
6466
.analyze([directory]);

0 commit comments

Comments
 (0)