dart_code_quality 0.3.0
dart_code_quality: ^0.3.0 copied to clipboard
A collection of analyzer rules for Dart and Flutter development.
0.3.0 #
- Performance improvements
// ignore:and// ignore_for_file:directives now work correctly in the analyzer plugin
0.2.0 #
Bug Fixes #
- avoid-ref-read-inside-build: No longer flags non-Riverpod
.read()calls - use-ref-read-synchronously: No longer flags non-Riverpod
.read()calls - avoid-duplicate-collection-elements: No longer flags Widget constructors in collections
- avoid-collection-equality-checks: No longer flags const collection comparisons
- avoid-unnecessary-compare-to: No longer flags
.compareTo() < 0and> 0(only== 0and!= 0) - avoid-unassigned-fields: Restricted to private fields per spec
- avoid-unassigned-late-fields: Restricted to private fields per spec
- avoid-suspicious-super-overrides: Rewritten to detect getter overriding field passed to super constructor
- avoid-unsafe-reduce: No longer flags when guarded by
isNotEmptyor!isEmpty - prefer-conditional-expressions: No longer flags if-else-if chains
New Detection (50 rules improved) #
- avoid-async-call-in-sync-function:
.ignore()exemption for fire-and-forget futures - avoid-bitwise-operators-with-booleans:
&=/|=compound assignment detection - avoid-duplicate-switch-case-conditions: Switch expression and when clause support
- avoid-equal-expressions:
==,<<,>>operator detection - avoid-future-tostring: String interpolation detection
- avoid-high-cyclomatic-complexity:
??and??=complexity counting - avoid-long-records: Record literal detection
- avoid-misused-set-literals: Lambda/FunctionExpression detection
- avoid-mixing-named-and-positional-fields: Record type annotation support
- avoid-negated-conditions: Ternary and
is!detection - avoid-nested-futures:
FutureOrhandling - avoid-nested-streams-and-futures:
FutureOrhandling - avoid-non-null-assertion: Null-assert pattern support
- avoid-one-field-records: Record type annotation support
- avoid-recursive-tostring:
$this/${this}interpolation detection - avoid-redundant-pragma-inline: async/try/sync*/async* method detection
- avoid-single-field-destructuring: ObjectPattern class destructuring
- avoid-stream-tostring: String interpolation detection
- avoid-throw-in-catch-block: Nested throws in control flow
- avoid-top-level-members-in-tests: Typedef support, public-only filtering
- avoid-type-casts: Cast pattern support
- avoid-unconditional-break: Unconditional continue, return, throw detection
- avoid-unnecessary-block: Variable shadowing exemption
- avoid-unnecessary-continue: Else-block detection
- avoid-unnecessary-negations:
!true/!falseand double-negation patterns - avoid-unsafe-collection-methods:
firstWhere/lastWhere/singleWheredetection - double-literal-format: Redundant leading zeros check
- prefer-conditional-expressions: Return-in-if-else detection
- prefer-for-in:
i += 1increment pattern - prefer-null-aware-spread:
...x ?? []pattern detection - prefer-pushing-conditional-expressions: Constructor call support
- prefer-returning-condition: No-else pattern detection
Flutter #
- avoid-missing-controller: Accept
onChanged, addEditableText - avoid-single-child-column-or-row: Check
FlexandWrap - avoid-unnecessary-setstate: Flag
setStateinbuild - prefer-center-over-align: Flag
Align()with no alignment - avoid-flexible-outside-flex: Remove
Wrapfrom valid parents - use-setstate-synchronously: Support
context.mounted - avoid-mounted-in-setstate: Support
context.mounted
Riverpod #
- use-ref-and-state-synchronously: Support
context.mounted/ref.mounted
Config System (Breaking) #
- Rules are opt-in: off by default, enabled via
recommended.yamlor explicit config - Config follows
include:directives (includingpackage:URIs) - Plugin and standalone produce identical results
- Rules read config per-file at check time, not from CWD at startup
- Removed
fromOptionsconstructors from all configurable rules
Testing #
- Parity test suite: 10 fixtures verifying
dart analyzeanddcqagreement - All 389 rules reviewed against DCM specs
0.1.0 #
- Initial public release.
- 375+ lint rules across Common, Flutter, Riverpod, Equatable, Mocktail, Easy Localization, Intl, and Fake Async categories.
- Recommended preset via
package:dart_code_quality/recommended.yaml. - Built on
analysis_server_plugin(requires Dart SDK >=3.11.1).