fix: show changed files without coverage data as 0% covered - #72
Closed
aGallea wants to merge 3 commits into
Closed
Conversation
Changed files in a PR that have no matching entry in the coverage report (lcov/cobertura/clover/jacoco) were silently ignored because the outer loop in getDiff iterated over coverage entries, not changed files. Invert the loop structure so changedFiles drives iteration. For each changed file, look up a matching coverage entry. If none exists, treat all changed lines as missed (0% coverage). This also reduces git blame calls from O(coverageFiles * changedFiles) to O(changedFiles). Add three tests covering: files with no coverage data, mixed coverage scenarios, and empty coverage arrays with changed files.
Tests Report 📄Tests Success ✅JUnit Details
Coverage Details (100% >= 80%) ✅Diff Cover Details
|
||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getDifffunction iterated over coverage entries (outer loop) and checked against changed files (inner loop), so files with zero coverage data were never visited.changedFilesis now the driver. For each changed file, we look up coverage data. If none exists, all changed lines are reported as missed (0% covered). This also reducesgit blamecalls from O(coverage × changed) to O(changed).Changes
src/diffCover.tsgetDiff— changedFiles as outer loop, coverage lookup per filetest/diffCover.test.tsdist/index.jsnpm run packageVerification
npm test)npm run lint)npm run build)