-
Notifications
You must be signed in to change notification settings - Fork 42
feat: update VGA for Dart v3.8.0 #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe changes update Dart SDK constraints to 3.8.0 in multiple configuration files, upgrade the analysis options to use very_good_analysis 9.0.0, and add a new strict analysis configuration file. Additionally, two linter rules are removed from exclusion lists in documentation and configuration files. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Analyzer
participant Linter
Developer->>Analyzer: Trigger analysis (now uses very_good_analysis 9.0.0)
Analyzer->>Linter: Apply updated rules (from analysis_options.9.0.0.yaml)
Linter-->>Analyzer: Report results (with stricter and updated rule set)
Analyzer-->>Developer: Output analysis/lint results
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
.github/workflows/tool_linter_rules.yaml
(1 hunks)README.md
(0 hunks)lib/analysis_options.9.0.0.yaml
(1 hunks)lib/analysis_options.yaml
(1 hunks)pubspec.yaml
(1 hunks)tool/linter_rules/exclusion_reasons.json
(0 hunks)tool/linter_rules/pubspec.yaml
(1 hunks)
💤 Files with no reviewable changes (2)
- tool/linter_rules/exclusion_reasons.json
- README.md
🧰 Additional context used
🪛 GitHub Actions: ci
lib/analysis_options.yaml
[warning] 1-1: 'switch_on_type' is not a recognized lint rule in the included options file.
[warning] 1-1: 'unnecessary_unawaited' is not a recognized lint rule in the included options file.
🔇 Additional comments (5)
pubspec.yaml (1)
10-12
: Align Dart SDK constraint
Updated the SDK constraint to^3.8.0
, which aligns with the PR objective and is consistent with other tool and CI configurations..github/workflows/tool_linter_rules.yaml (1)
17-21
: Update CI Dart version
The GitHub Actions workflow’s Dart setup step now usessdk: 3.8.0
, matching the root and tool SDK constraints.tool/linter_rules/pubspec.yaml (1)
6-8
: Sync tool SDK environment
Thelinter_rules
tool’spubspec.yaml
now specifiessdk: ^3.8.0
, maintaining consistency across the repo.lib/analysis_options.yaml (1)
1-2
: Reference new analysis options
This file now includesanalysis_options.9.0.0.yaml
(v9.0.0). Pipeline warnings indicate unrecognized rules (e.g.,switch_on_type
,unnecessary_unawaited
). Please verify that the included file defines these rules correctly and that their names match the official lint rule names.🧰 Tools
🪛 GitHub Actions: ci
[warning] 1-1: 'switch_on_type' is not a recognized lint rule in the included options file.
[warning] 1-1: 'unnecessary_unawaited' is not a recognized lint rule in the included options file.
lib/analysis_options.9.0.0.yaml (1)
197-197
:❌ Incorrect review comment
Unrecognized lint rule:
unnecessary_unawaited
The analyzer flagsunnecessary_unawaited
as invalid—consider replacing it with the correct rule (unawaited_futures
?) or removing it to clear CI errors.
To verify whether
unnecessary_unawaited
is actually defined in your analysis options file, let’s inspect the rules around line 197:
🏁 Script executed:
#!/usr/bin/env bash # Locate the analysis options file file=$(fd -t f analysis_options.9.0.0.yaml | head -n 1) echo "Inspecting: $file" # Show context around the reported line sed -n '180,220p' "$file"Length of output: 1540
🌐 Web query:
Is 'unnecessary_unawaited' a valid Dart lint rule?
💡 Result:
Yes,
unnecessary_unawaited
is a valid Dart lint rule.This rule flags unnecessary uses of the
unawaited()
function when calling an asynchronous method or function that is annotated with@awaitNotRequired
. When such a method is annotated this way, wrapping it withunawaited()
is redundant and should be avoided.Example from official documentation:
BAD:
@awaitNotRequired Future<LogMessage> log(String message) { ... } void f() { unawaited(log('Message.')); }GOOD:
@awaitNotRequired Future<LogMessage> log(String message) { ... } void f() { log('Message.'); }How to enable:
To enable this rule, add it to your
analysis_options.yaml
file underlinter > rules
:linter: rules: - unnecessary_unawaitedor using map syntax:
linter: rules: unnecessary_unawaited: trueThe official documentation confirms that
unnecessary_unawaited
is available in Dart as of version 3.8.0 and provides clear guidelines on its use and configuration[7].Citations:
- 1: https://dart.dev/tools/linter-rules
- 2: https://dart.dev/tools/linter-rules/all
- 3: https://github.com/dart-lang/lints
- 4: https://gist.github.com/rydmike/fa5c991118ab712f35d2285e7b8a82cb
- 5: https://dart-ko.dev/tools/linter-rules
- 6: https://pub.dev/documentation/lint/latest/
- 7: https://dart.dev/tools/linter-rules/unnecessary_unawaited
- 8: https://pub.dev/packages/lint
- 9: https://www.thedroidsonroids.com/blog/development/how-to-create-dart-lint-rule-for-flutter
- 10: https://pub.dev/packages/lints/versions/2.1.1
Incorrect lint rule warning –
unnecessary_unawaited
is valid
The ruleunnecessary_unawaited
has been part of the Dart linter since version 3.8.0 and is correctly listed in youranalysis_options.yaml
. The CI errors you’re seeing are likely due to an older SDK or linter package that doesn’t yet include this rule. No change is needed in your rules list—please upgrade your Dart analyzer/linter in CI to a version that supportsunnecessary_unawaited
.Likely an incorrect or invalid review comment.
- sort_unnamed_constructors_first | ||
- specify_nonobvious_property_types | ||
- strict_top_level_inference | ||
- switch_on_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Unrecognized lint rule: switch_on_type
CI reports switch_on_type
as unrecognized. Confirm this rule exists in Dart’s linter or the v9.0.0 analysis package; otherwise, remove or correct it to resolve the warning.
🌐 Web query:
Does Dart’s official linter include a `switch_on_type` rule?
💡 Result:
As of Dart 3.0, the official Dart linter includes a rule named avoid_switch_on_runtimeType
. This rule advises against using switch
statements on an object's runtimeType
, recommending instead the use of type checks with pattern-matching expressions like String _
or int()
. The rationale is that switching on runtimeType
can lead to code that is prone to breaking when class hierarchies change or new types are added, and it doesn't take full advantage of Dart’s strong static typing system. (github.com)
To enable this rule, add avoid_switch_on_runtimeType
under the linter > rules
section in your analysis_options.yaml
file:
linter:
rules:
- avoid_switch_on_runtimeType
This configuration will activate the lint, helping you identify and refactor instances where switch
statements are used on runtimeType
, thereby promoting more maintainable and type-safe code.
Citations:
Replace unrecognized switch_on_type
rule with avoid_switch_on_runtimeType
The Dart linter does not include a switch_on_type
rule. To enforce avoiding switches on an object’s runtimeType
, use the built-in avoid_switch_on_runtimeType
rule instead.
• lib/analysis_options.9.0.0.yaml:165
- - switch_on_type
+ - avoid_switch_on_runtimeType
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
- switch_on_type | |
- avoid_switch_on_runtimeType |
🤖 Prompt for AI Agents
In lib/analysis_options.9.0.0.yaml at line 165, the lint rule `switch_on_type`
is unrecognized by Dart’s linter. Replace `switch_on_type` with the correct rule
name `avoid_switch_on_runtimeType` under the `linter > rules` section to enable
the intended lint check and remove the CI warning.
Status
READY
Description
Getting ready for v3.8 of Dart. This also includes @spydon's changes from #151 (that I stole with his permission)
Type of Change
Summary by CodeRabbit
Chores
Documentation