Skip to content

Add Dart and Flutter - #13

Open
MaurizioSodano wants to merge 5 commits into
unclebob:masterfrom
Engage-srl:dart-support
Open

MaurizioSodano wants to merge 5 commits into
unclebob:masterfrom
Engage-srl:dart-support

Conversation

@MaurizioSodano

Copy link
Copy Markdown

Adds Dart (and Flutter) to crapper.

  • .dart files are scored: top-level functions, methods of classes, mixins, extensions, extension types and enums, getters (size), setters (size=), operators (operator +) and factory constructors. Generative constructors, abstract and external members are not entries; local functions and closures count toward the function that holds them.
  • Complexity counts if, for, while, do, catch/on, ?:, each switch case, &&, ||, ??, ?. and collection if/for.
  • Namespace is the package name from pubspec.yaml plus the path under lib/.
  • Coverage is LCOV: flutter test --coverage when the package depends on sdk: flutter, otherwise dart test, once per package. Relative SF: paths are made absolute. --use-existing-coverage also reads each package's coverage/lcov.info.
  • Generated files (*.g.dart, *.freezed.dart, *.mocks.dart, ...), .dart_tool, test/, integration_test/ and *_test.dart are skipped.
  • Includes a fix for _coverage_report raising ValueError when a package is outside --root.

Tested on a Flutter monorepo (680 Dart files, 3,786 functions, no parse errors, 4.8 s without coverage) and with a real flutter test --coverage run.

Tests: tests/test_dart.py, tests/test_dart_coverage.py; suite 169 pass. The one failure, test_project_snapshot_is_readable_as_crap4clj_edn, and the parse_args CRAP 16 are on master already.

Sibling PRs: unclebob/dryer and unclebob/mutator. mutator imports crapper.dart_coverage, so merge this one first.

https://claude.ai/code/session_01L2LePAtan3pdyUWbr64gpS

_coverage_report raised ValueError when the package was not under
--root. The report now goes under target/coverage/<language>/external__<path>/.
README documents it and the pubspec.lock rewrite by flutter test.

Claude-Session: https://claude.ai/code/session_01L2LePAtan3pdyUWbr64gpS

Closes #5
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.

1 participant