dart_code_quality 0.3.0 copy "dart_code_quality: ^0.3.0" to clipboard
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() < 0 and > 0 (only == 0 and != 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 isNotEmpty or !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: FutureOr handling
  • avoid-nested-streams-and-futures: FutureOr handling
  • 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/!false and double-negation patterns
  • avoid-unsafe-collection-methods: firstWhere/lastWhere/singleWhere detection
  • double-literal-format: Redundant leading zeros check
  • prefer-conditional-expressions: Return-in-if-else detection
  • prefer-for-in: i += 1 increment 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, add EditableText
  • avoid-single-child-column-or-row: Check Flex and Wrap
  • avoid-unnecessary-setstate: Flag setState in build
  • prefer-center-over-align: Flag Align() with no alignment
  • avoid-flexible-outside-flex: Remove Wrap from 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.yaml or explicit config
  • Config follows include: directives (including package: URIs)
  • Plugin and standalone produce identical results
  • Rules read config per-file at check time, not from CWD at startup
  • Removed fromOptions constructors from all configurable rules

Testing #

  • Parity test suite: 10 fixtures verifying dart analyze and dcq agreement
  • 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).