Skip to content

Collect Java coverage from Gradle as well as Maven - #3

Open
aminHZDEV wants to merge 2 commits into
unclebob:masterfrom
aminHZDEV:fix/gradle-java-coverage
Open

aminHZDEV wants to merge 2 commits into
unclebob:masterfrom
aminHZDEV:fix/gradle-java-coverage

Conversation

@aminHZDEV

@aminHZDEV aminHZDEV commented Oct 26, 2026 •

Copy link
Copy Markdown

Fixes #2

Problem:
Java coverage only worked with Maven. On Gradle projects every method got
0% coverage, so CRAP scores were too high.

Fix:

  • Detect Gradle modules (build.gradle or build.gradle.kts). Maven wins if both exist.
  • A multi-project build runs once, from its outermost selected module; a
    folder with its own settings file stays a separate build.
  • Run gradlew (or gradle) with a temporary init script that adds JaCoCo,
    so the project's build file is not changed.
  • Read build/reports/jacoco/test/jacocoTestReport.xml, also with --use-existing-coverage.
  • README and --help mention Gradle.

Tested:

  • 14 new tests, no Gradle needed to run them. 158 pass; the 2 failures were
    there before (they need bb and uml-viewer).
  • Real Gradle run: f went from 0% / CRAP 12.0 to 100% / CRAP 3.0.

realgenekim pushed a commit to realgenekim/crapper that referenced this pull request Oct 31, 2026
…ionals

Review fixes for the defmethod / record-method units.

Names are now unique and derived from the value as written:
- defmethod: `multi dispatch`, the dispatch source with whitespace,
  commas, comments, and #_ discards collapsed outside strings only. A
  string keeps its contents (a raw newline is written as \n, the same
  value). Tagged literals keep their payload (`#inst "2020"`). `::kw`
  resolves to `:ns/kw`, `::alias/kw` through the ns form's :as /
  :as-alias aliases, else stays literal.
- Record, type, and extend-* methods: `Type.Protocol.method`, so the
  same method of two protocols no longer collides. ^hints and metadata
  stay out of the name.
- Top-level reify: `var.Interface.method`; proxy: `var.method`.
- Any name repeated in a file gets unclebob#2, unclebob#3 in source order, for
  defmethods as for methods. defn names are unchanged.

Coverage: a method's first or last line, when shared with another
method or the enclosing form's own code, is left out of its score
(Function.cover_start / cover_end). A method with no line of its own
falls back to its whole range. Documented in the README.

Methods inside #? and #?@ in type and reify bodies are units, from
every branch. A method name such as `when` no longer counts as a
decision. Commas end symbols when reading children.

Cleanup: the unused _ANON_HEADS, the unused `line` parameter, the list
subclass that carried the namespace, _reify_units/_renumber, and
_first_symbol_in_vector are gone. _dispatch_end no longer has a #?
branch, which _child_end's prefix handling made unreachable.

Co-Authored-By: Gene Kim <genek@itrevolution.com>
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.

Java coverage not support Gradle projects

1 participant