Sitelet https://github.com/flutter/flutter/pull/191159
Skip to content

[analysis] Filter analyzer rule AST visitor registration by target file path - #191159

Merged
auto-submit[bot] merged 15 commits into
flutter:masterfrom
bkonyi:optimize_rule_registration
Aug 16, 2026
Merged

auto-submit[bot] merged 15 commits into
flutter:masterfrom
bkonyi:optimize_rule_registration

Conversation

@bkonyi

@bkonyi bkonyi commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Description

This PR optimizes static analysis performance in dev/flutter_analyzer_plugin by early-exiting in registerNodeProcessors based on file path for rules that only target specific files:

  • IssueLinkSyntax: Early exits for unit tests (_test.dart) and the rule's definition file (issue_link_syntax.dart), removing _shouldSkip() from the visitor.
  • IntegrationTestTimeouts: Early exits for non-integration-test files (files not containing test_driver or test.dart), removing the redundant per-invocation file path check in visitMethodInvocation.
  • NoBadImportsInFlutter: Early exits for files not in packages/flutter/lib/src/, removing redundant path checks in visitImportDirective.

This avoids unnecessary AST visitor registration and listener callbacks across non-applicable files in the repository.

Addresses feedback from @srawlins in #191127.

Related Issues

Tests

  • All existing tests in dev/flutter_analyzer_plugin/test/ continue to pass.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 15, 2026
@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Aug 15, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request migrates several custom analysis rules from the dev/bots script to the dev/flutter_analyzer_plugin as proper analyzer plugin rules, specifically adding IssueLinkSyntax and RepositoryLinkSyntax. It also removes the legacy custom rules and their associated tests. The feedback suggests removing an unused context parameter and field from the _Visitor class in the newly introduced RepositoryLinkSyntax rule.


@override
void registerNodeProcessors(RuleVisitorRegistry registry, RuleContext context) {
final visitor = _Visitor(this, context);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The context parameter is not used by _Visitor and can be removed.

Suggested change
final visitor = _Visitor(this, context);
final visitor = _Visitor(this);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +65 to +68
_Visitor(this.rule, this.context);

final AnalysisRule rule;
final RuleContext context;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Remove the unused context parameter and field from _Visitor.

Suggested change
_Visitor(this.rule, this.context);
final AnalysisRule rule;
final RuleContext context;
_Visitor(this.rule);
final AnalysisRule rule;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

bkonyi added 3 commits August 15, 2026 16:30
…tration

# Conflicts:
#	dev/bots/test/analyze_test.dart
#	dev/flutter_analyzer_plugin/lib/src/rules/issue_link_syntax.dart
#	dev/flutter_analyzer_plugin/lib/src/rules/repository_link_syntax.dart
@bkonyi
bkonyi requested a review from srawlins August 16, 2026 00:31
@github-actions github-actions Bot removed framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Aug 16, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 16, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Aug 16, 2026
Merged via the queue into flutter:master with commit 4abfc5d Aug 16, 2026
22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants