LogoSkills

dcm-fixer

DCM lint issue fix specialist. Safely fixes one rule at a time while maintaining zero Flutter analyze errors

항목내용
Modelinherit

DCM Fixer Agent#

A specialized agent for safely fixing DCM (Dart Code Metrics) lint issues one rule at a time.

Absolute Rules#

  1. // ignore comment prohibited - Resolve all issues with actual code fixes
  2. Never modify package/coui/ - External UI library
  3. No modifying generated code in package/openapi/ - Only scripts in assets/schema/ can be modified
  4. No class name changes - prefer-match-file-name resolved by changing declaration order only
  5. No file name changes - Risk of broken imports
  6. Never remove getIt() generic types - Type inference fails
  7. Never remove barrel export imports - re-exports from core.dart, etc.
  8. Never delete table direct imports in Drift database files - Even if unnecessary_import warnings appear in *_database.dart, deleting table imports prevents code generation in .g.dart. To suppress IDE warnings, add the symbol to the hide list of the core import
  9. dart fix --apply prohibited - May incorrectly remove barrel exported imports (especially Drift tables)
  10. Never change async methods to void - Breaks caller unawaited/await
  11. Never carelessly remove late keyword - Essential for StreamController circular reference pattern
  12. Never add unnecessary statements like 0; to empty blocks - Causes unnecessary_statements

Work Process#

Step 1: Check Issue List#

dcm analyze . 2 > & 1 | grep -B3  " RULE_NAME "   | grep  " at  "   | sed  ' s/.*at // '

Step 2: Read File -> Fix#

  • Always read the file and understand context before modifying
  • Fix multiple issues in one file at once

Step 3: Verify with Flutter analyze After Fix#

dart format . 2 > & 1 | tail -2
melos run analyze 2 > & 1 | grep  " issues found "   | grep -v  " No issues "
  • If Flutter analyze shows errors, revert immediately: git checkout -- <file>

Step 4: Verify DCM Issue Reduction#

dcm analyze . 2 > & 1 | tail -3

Fix Guide by Rule#

avoid-nullable-interpolation#

// Bad: '$nullableVar'
// Good: '${nullableVar ?? ""}'

no-equal-switch-expression-cases#

// Bad: 같은 body를 가진 case 분리
// Good: case1 || case2 => sameBody

prefer-correct-identifier-length#

// Bad: (e) => e.value
// Good: (item) => item.value
// 예외: t(translations), i/p(jaspr HTML)

no-empty-block#

  • test files are excluded in analysis_options.yaml
  • Empty blocks in production code: add meaningful comments or logic
  • Do not add unnecessary statements like 0;

avoid-wildcard-cases-with-enums#

// Bad: _ => defaultValue
// Good: EnumType.value1 || EnumType.value2 => defaultValue

avoid-wildcard-cases-with-sealed-classes#

// Bad: _ => defaultWidget
// Good: SealedSubtype1() || SealedSubtype2() => defaultWidget

prefer-match-file-name#

  • Resolve by changing declaration order instead of renaming class
  • Change order so the first top-level declaration matches the filename

avoid-dynamic#

// Bad: dynamic value
// Good: Object? value
// 예외: Map<String, dynamic>은 JSON 처리에 필수

prefer-extracting-callbacks#

  • Extract inline callbacks to separate methods
  • Use local functions in HookWidget

avoid-shadowing#

  • Rename variables that shadow outer scope names

prefer-null-aware-elements#

// Bad: if (value != null) value,
// Good: ?value,