diff --git a/.github/workflows/dart_skills_lint_workflow.yaml b/.github/workflows/dart_skills_lint_workflow.yaml index fa9277c..7c322c9 100644 --- a/.github/workflows/dart_skills_lint_workflow.yaml +++ b/.github/workflows/dart_skills_lint_workflow.yaml @@ -38,7 +38,7 @@ jobs: - run: dart analyze --fatal-infos - name: Run cyclomatic complexity check - run: dart run dart_code_linter:metrics analyze lib + run: dart run dart_code_linter:metrics analyze lib test - run: dart test diff --git a/tool/dart_skills_lint/analysis_options.yaml b/tool/dart_skills_lint/analysis_options.yaml index 3b2de7f..7128ea6 100644 --- a/tool/dart_skills_lint/analysis_options.yaml +++ b/tool/dart_skills_lint/analysis_options.yaml @@ -15,8 +15,9 @@ analyzer: strict-casts: true strict-inference: true strict-raw-types: true - plugins: - - dart_code_linter + # dart_code_linter is intentionally NOT registered as an analyzer + # `plugin` here. When it was, `dart analyze` had racy false positives. + # See https://github.com/flutter/skills/issues/144 errors: # allow deprecated members (we do this because otherwise we have to annotate # every member in every test, assert, etc, when we or the Dart SDK deprecates @@ -286,11 +287,20 @@ dart_code_linter: - no-empty-block - avoid-redundant-async - avoid-passing-async-when-sync-expected - - avoid-late-keyword + # `late` for fields initialized in `setUp` is the idiomatic Dart test + # fixture pattern; enforce this rule on lib only. + - avoid-late-keyword: + exclude: + - test/** - prefer-named-record-fields # Clean up - avoid-unused-parameters - prefer-moving-to-variable - - prefer-match-file-name + # Test files must be named `*_test.dart` for the test runner, and commonly + # hold several small fixture/mock classes, so they can never match this + # rule's "file name == first class name" convention. Enforce it on lib only. + - prefer-match-file-name: + exclude: + - test/** - always-remove-listener \ No newline at end of file diff --git a/tool/dart_skills_lint/test/directory_structure_test.dart b/tool/dart_skills_lint/test/directory_structure_test.dart index 54a5faa..8d501a1 100644 --- a/tool/dart_skills_lint/test/directory_structure_test.dart +++ b/tool/dart_skills_lint/test/directory_structure_test.dart @@ -26,7 +26,7 @@ class MockInaccessibleFile implements File { } @override - dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); + Object? noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); } base class TestIOOverrides extends IOOverrides { diff --git a/tool/dart_skills_lint/test/skills_ignores_storage_test.dart b/tool/dart_skills_lint/test/skills_ignores_storage_test.dart index 398f2b8..99c10f3 100644 --- a/tool/dart_skills_lint/test/skills_ignores_storage_test.dart +++ b/tool/dart_skills_lint/test/skills_ignores_storage_test.dart @@ -12,7 +12,7 @@ void main() { late Directory tempDir; late SkillsIgnoresStorage storage; - setUp(() async { + setUp(() { tempDir = Directory.systemTemp.createTempSync('storage_test.'); storage = SkillsIgnoresStorage(); });