Skip to content

Migrate avoid_late_keyword rule (default behavior) and tests#231

Open
Islam-Shaaban-Ibrahim wants to merge 1 commit intoanalysis_server_migrationfrom
migrate/avoid_late_keyword
Open

Migrate avoid_late_keyword rule (default behavior) and tests#231
Islam-Shaaban-Ibrahim wants to merge 1 commit intoanalysis_server_migrationfrom
migrate/avoid_late_keyword

Conversation

@Islam-Shaaban-Ibrahim
Copy link
Copy Markdown
Collaborator

No description provided.

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 migrates the AvoidLateKeywordRule to the AnalysisRule framework, introducing a dedicated visitor and unit tests. The review highlights a regression where configuration parameters for ignoring types and allowing initializers were removed, and notes a missing import in the visitor class that will cause a compilation error.

Comment on lines +50 to +56
class AvoidLateKeywordRule extends AnalysisRule {
static const String _lintName = 'avoid_late_keyword';

AvoidLateKeywordRule._(super.config);
static const LintCode _code = LintCode(
_lintName,
'Avoid using the "late" keyword. It may result in runtime exceptions.',
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The migration to AnalysisRule has removed support for the allow_initialized and ignored_types configuration parameters that were present in the previous SolidLintRule implementation. While the PR title mentions "default behavior", this is a regression for users who rely on these settings (e.g., ignoring AnimationController). Furthermore, the class documentation (lines 15-25) still references these parameters, which is now misleading. Please consider either restoring parameter support or updating the documentation to reflect the current implementation.

Comment on lines +1 to +3
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:solid_lints/src/lints/avoid_late_keyword/avoid_late_keyword_rule.dart';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The isLate extension method used on line 15 is missing its required import. It was previously provided by package:solid_lints/src/utils/types_utils.dart. Without this import, the code will fail to compile.

Suggested change
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:solid_lints/src/lints/avoid_late_keyword/avoid_late_keyword_rule.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:solid_lints/src/lints/avoid_late_keyword/avoid_late_keyword_rule.dart';
import 'package:solid_lints/src/utils/types_utils.dart';

@solid-vovabeloded
Copy link
Copy Markdown
Collaborator

@Islam-Shaaban-Ibrahim, I believe this rule needs custom params to allow users to configure it.

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.

3 participants