Repository navigation
♻️ Ignore generated file diagnostics by type instead of by name - #48
Merged
Merged
Conversation
The generated header now writes `// ignore_for_file: type=hint,type=lint,type=warning` instead of listing twelve diagnostic names that have to be kept in sync with the analyzer. Most of the listed names have moved out of the lint set into the analyzer itself, so `type=lint` alone would not have been enough: `unnecessary_import` is now a hint, and `duplicate_import`, `multiple_combinators`, `unused_import`, `unused_local_variable` and `unused_shown_name` are static warnings. `hint`, `lint` and `warning` are the only types an ignore comment can match; error diagnostics can not be ignored either way. Regenerated the examples. The committed `example_go_router` output is stale for unrelated reasons, so only its ignore line was updated.
Ran the generator in all eight example directories with no arguments, so each one reuses its own `ff_annotation_route_commands` (bin/ff_annotation_route.dart only reads that file when no arguments are passed): example, example/module_a, example1, example_fast_mode, example_fast_mode/module_a, example_getx, example_route_extension, example_go_router `example_go_router` was the only stale output: its ignore line was written after the license header, `// dart format off` and `// coverage:ignore-file` were missing, `import 'dart:ui';` was still emitted, and the route settings fields and indentation differed. The module packages are run before `example` / `example_fast_mode`, because those two also write the module's `*_route.dart` as a node of their package graph using their own arguments; running the modules last flips the header's `fast mode` flag to true and leaves a diff behind for anyone who only runs the `.run` configurations. Two byproducts of the module packages are deliberately not committed: `module_a/lib/module_a_routes.dart` and `module_a_fast_routes.dart`. Nothing consumes them, they were dropped in 5fc5c69, and the first one does not compile (it references `TestMode` at module_a_routes.dart:84 while the import is prefixed `as module_a`).
…ead of a list of twelve diagnostic names.
go_router 17.5.0 turned `metadata` into a required named parameter of `RouteMatchBase.buildState`, which the go_router example calls: error • The named parameter 'metadata' is required, but there's no corresponding argument • example_go_router/lib/src/router/ go_router_route_lifecycle.dart:521:16 • missing_required_argument The same call exists on master; it only started failing when the newest go_router became 17.5.0+. The merged metadata accessor (`RouteMatchList.metadataFor`) is annotated `internal`, so the metadata of the matched route itself is passed instead.
`melos bootstrap` (via the `ide.intellij` section in melos.yaml) writes platform-aware `analyzer.exclude` entries into every example's analysis_options.yaml (`build/**`, plus `web/**` or `android/**`/`ios/**` depending on the platform folders the package has). Because those nine checked-in files were left dirty, the CI step `dart pub publish --dry-run` failed with "9 checked-in files are modified in git".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Generated route files are silenced by diagnostic type instead of by a list of twelve diagnostic names:
Why
Most of the twelve names in the old list moved out of the lint set into the analyzer itself, so the list has to be kept in sync with every such move — and
type=lintalone is not enough:unnecessary_importINFO HINTduplicate_import,multiple_combinators,unused_import,unused_local_variable,unused_shown_nameWARNING STATIC_WARNINGlibrary_private_types_in_public_api,unintended_html_in_doc_comment,unnecessary_library_directive,unnecessary_library_nameINFO LINTimplementation_imports,prefer_const_literals_to_create_immutablesLINT)hint,lintandwarningare the only types an ignore comment can match (analyzer/lib/src/ignore_comments/ignore_info.dart); error diagnostics cannot be ignored this way, which is also true of the old name list.Verification
dart analyze --format machinematches the table above for the ten codes that can be triggered in this SDK.dart analyze --format machine libfor all nine example packages: byte-identical diagnostics before and after.dart format lib -o none --set-exit-if-changed,flutter analyze .,dart test,dart pub publish --dry-runas run by CI.Example regeneration
All eight example directories were regenerated by running the generator with no arguments, so each reuses its own
ff_annotation_route_commands:example_go_routeroutput was stale: the ignore line was written after the license header,// dart format offand// coverage:ignore-filewere missing,import 'dart:ui';was still emitted, and the route settings fields and indentation differed.example/example_fast_mode, because those also write the module's*_route.dartas a node of their package graph; running the modules last would flip the header'sfast modeflag.module_a/lib/module_a_routes.dartandmodule_a_fast_routes.dartare deliberately not committed: nothing consumes them, they were dropped in 5fc5c69, and the first does not compile (it referencesTestModewhile the import is prefixedas module_a).Release
pubspec.yaml→12.1.0with a matchingCHANGELOG.mdentry.