Fix check run reporting 0 violations when source files can't be resolved#221
Merged
Fix check run reporting 0 violations when source files can't be resolved#221
Conversation
Co-authored-by: lcollins <528874+lcollins@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Validate and resolve reported defect
Fix check run reporting 0 violations when source file paths can't be resolved
Mar 4, 2026
Co-authored-by: lcollins <528874+lcollins@users.noreply.github.com>
Copilot
AI
changed the title
Fix check run reporting 0 violations when source file paths can't be resolved
Fix check run reporting 0 violations when source files can't be resolved
Mar 4, 2026
lcollins
approved these changes
Mar 4, 2026
There was a problem hiding this comment.
Pull request overview
Fixes incorrect check run summaries that reported 0 violation(s) found when SpotBugs XML violations existed but could not be mapped to resolvable source file paths (causing annotations to be skipped).
Changes:
- Update
annotationsForPathto return both rendered annotations and the raw SpotBugsBugInstancecount (violationCount). - Update main execution flow to sum
violationCountacross reports and use it as the check run’snumErrors, independent of annotation generation success. - Rebuild the bundled action artifact (
dist/index.js) and adjust tests for the new return shape, including a case where source files don’t exist.
Reviewed changes
Copilot reviewed 3 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/annotations.ts | Returns { annotations, violationCount } so summary counts reflect XML violations even when annotations are skipped. |
| src/main.ts | Aggregates violationCount into totalViolations and uses it for check run summary/conclusion; removes unused import. |
| tests/main.test.ts | Updates existing test for new return shape; adds coverage for unresolved source paths. |
| package-lock.json | Updates dependency specifiers/lock metadata as part of rebuild/install. |
| dist/index.js | Rebuilt ncc bundle to ship the fix (includes large regenerated/vendor diffs). |
| dist/licenses.txt | Regenerated licenses file reflecting bundled dependency set. |
Comments suppressed due to low confidence (1)
tests/main.test.ts:32
- This test re-spies on
fs.existsSynceven though it’s already spied inbeforeAll, and it doesn’t restore/reset the mock afterwards. To avoid brittle inter-test coupling, reuse the existing spy and change its return value for this test (e.g.mockReturnValueOnce(false)), and/or add anafterEachthat restores mocks.
)
jest.spyOn(fs, 'existsSync').mockReturnValue(false)
const result = annotationsForPath(spotBugsXml)
expect(result.annotations).toHaveLength(0)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
When SpotBugs violations exist in the XML but their source file paths can't be resolved on the runner, annotations are silently skipped — causing the check run summary to report
0 violation(s) founddespite the workflow log correctly showing e.g.has 12 violations.Root cause
numErrorswas derived fromannotations.length(successfully annotated violations) rather than the raw violation count from the XML. When source paths don't resolve, all annotations are skipped and the count collapses to 0.Changes
src/annotations.ts—annotationsForPathnow returns{ annotations, violationCount }instead ofAnnotation[].violationCountalways reflects theBugInstancecount from the XML, regardless of source file resolution.src/main.ts— SumsviolationCountacross all result files intototalViolations, passed asnumErrorstocreateCheck. Removes unusedchainimport.dist/index.js— Rebuilt bundle (ncc build) to ship the fix. The bundle is what the action actually executes; the prior fix only updated TypeScript sources.__tests__/main.test.ts— Updated for new return shape; added a test assertingviolationCount > 0whenexistsSyncreturnsfalse.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.