Skip to content

Migrate avoid unnecessary set state rule and its tests#238

Merged
daria-trusca-solid merged 16 commits into
analysis_server_migrationfrom
migrate_avoid_unnecessary_set_state
Jun 4, 2026
Merged

Migrate avoid unnecessary set state rule and its tests#238
daria-trusca-solid merged 16 commits into
analysis_server_migrationfrom
migrate_avoid_unnecessary_set_state

Conversation

@daria-trusca-solid
Copy link
Copy Markdown
Collaborator

Migrated the avoid_unnecessary_set_state rule and its corresponding tests to comply with the analyzer package.

Changes

  • Rule Refactoring: Updated the implementation of avoid_unnecessary_set_state to use the current analyzer syntax.
  • Tests: Updated and verified all associated test cases to ensure the rule triggers correctly and no regressions are introduced.

Copy link
Copy Markdown

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

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 refactors the AvoidUnnecessarySetStateRule to extend AnalysisRule instead of SolidLintRule, updating its implementation to use the new analyzer APIs. The associated AvoidUnnecessarySetStateVisitor has been updated to extend SimpleAstVisitor and handle diagnostics reporting directly. Additionally, the PR removes an old test file and introduces a comprehensive unit test suite using AnalysisRuleTest. There are no review comments, so no feedback is provided.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Copy link
Copy Markdown
Contributor

@danylo-safonov-solid danylo-safonov-solid left a comment

Choose a reason for hiding this comment

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

A few final touches, otherwise looks good


/// Unnecessary setState invocations
Iterable<MethodInvocation> get setStateInvocations => _setStateInvocations;
final _setStateInvocations = <MethodInvocation>[];
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.

should be before constructor

- member_ordering:
order:
- fields
- getters_setters
- constructors
- methods

static const lintName = 'avoid_unnecessary_setstate';
class AvoidUnnecessarySetStateRule extends AnalysisRule {
/// The name of the lint rule.
static const lintName = 'avoid_unnecessary_set_state';
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.

Comment thread lib/src/lints/avoid_unnecessary_setstate/avoid_unnecessary_set_state_rule.dart Outdated

AvoidUnnecessarySetStateRule._(super.config);
/// The message shown when the lint rule is triggered.
static const lintMessage = 'Avoid calling unnecessary setState. '
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.

Doesn't look like there are references to this variable outside of this class, it shouldn't be public. Also, both lintName and lintMessage are already exposed via diagnosticCode so that should be enough for testing

Copy link
Copy Markdown
Contributor

@danylo-safonov-solid danylo-safonov-solid left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Copy Markdown
Contributor

@danylo-safonov-solid danylo-safonov-solid left a comment

Choose a reason for hiding this comment

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

Is formatting broken in parent branch too? Should we make another PR to fix that (and any other CI checks if necessary)

@daria-trusca-solid
Copy link
Copy Markdown
Collaborator Author

Yes, it looks like formatting was indeed broken on the parent branch. I just ran dart format . locally, and it modified quite a few files across the project. (I have the line length limit set to 80 characters)

@daria-trusca-solid daria-trusca-solid merged commit 5bcbbf0 into analysis_server_migration Jun 4, 2026
0 of 2 checks passed
@daria-trusca-solid daria-trusca-solid deleted the migrate_avoid_unnecessary_set_state branch June 4, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants