SP-778: tighten content-cli SonarCloud coverage scope#363
Merged
Kastriot Salihu (ksalihu) merged 1 commit intoMay 28, 2026
Merged
Conversation
Exclude only inherently un-testable source files from the coverage calculation: type-only declaration files (*.interface.ts / *.interfaces.ts), constant / enum maps (*.constants.ts), and the CLI entry point (src/content-cli.ts). Files with real executable logic but no current tests (factories, untested module.ts wiring) stay in scope so coverage continues to surface them as gaps. Mirror the same negation set in jest.config.ts so local `jest --coverage` and SonarCloud measure the same files. Drop dead `**/*.test.ts` references from sonar-project.properties (the project uses .spec.ts only) and add `**/*.d.ts` + `dist-bundle/**` to `sonar.exclusions`. Add a register() smoke test for configuration-management/module.ts via a new chainable Configurator mock in tests/utls/configurator-mock.ts. This lifts that module from 40.30% -> 92.61% line coverage and demonstrates a pattern other modules can adopt to cover their Commander wiring without writing per-command spec scaffolding. Includes-AI-Code: true Co-authored-by: Cursor <[email protected]>
|
Buqeta (Buqeta)
approved these changes
May 28, 2026
Contributor
Author
|
Merging to see if this fixes the coverage report. Feel free to add comments, will address them as needed in follow up PR |
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.



Description
Today the SonarCloud coverage metric for
content-cliis artificially low (~52% statements / ~72% functions) because it counts files where unit-testing isn't possible or meaningful. This PR scopes the coverage measurement to source files that can actually be tested, without hiding files that have real logic but currently lack tests.What's excluded from coverage (added to
sonar.coverage.exclusions+ mirrored injest.config.tscollectCoverageFrom):**/*.interface.ts,**/*.interfaces.ts— pure type / interface declarations**/*.constants.ts— enum and constant mapssrc/content-cli.ts— CLI entry point (top-levelprogram.parse(),process.exit,uncaughtExceptionhandler — not unit-testable without spawning a subprocess)These files remain in SonarCloud analysis for bugs / smells / hotspots — only the coverage calculation skips them.
What deliberately stays in coverage (even though some have 0% today):
**/*-factory.ts/**/*.factory.ts— 7 of the 8 factories contain real FS operations, branching, and validation paths (widget.manager-factory.tsalone has 5 manifest-validation branches that throwFatalError). None have tests today. Surfacing them as gaps is the point.**/module.ts— most have untestedregister()wiring.configuration-management/module.tsalso has real handler-level validation logic that should keep being tracked.Sonar config cleanup:
**/*.test.tsreferences removed fromsonar.exclusionsandsonar.test.inclusions— the project uses.spec.tsonly (jest.testMatch: <rootDir>/tests/**/*.spec.ts).**/*.d.tsanddist-bundle/**added tosonar.exclusions.New
register()smoke-test pattern:To avoid permanently excluding
module.tsfiles (whose Commander wiring is otherwise hard to cover), this PR adds a small reusable chainable Configurator mock attests/utls/configurator-mock.tsand applies it totests/commands/configuration-management/module.spec.ts. Callingmodule.register(testContext, mockConfigurator)exercises every.command().option().action()line in the file. Result for that module: 40.30% → 92.61% line coverage. Other modules can adopt the same pattern as they're touched.Aggregate coverage:
The numbers are higher than baseline but lower than they would be if factories and module wiring were hidden. This is intentional: the metric now reflects real testable code rather than being inflated by hiding files that should have tests.
Relevant links
Checklist
Test plan
npx jest --coveragepasses (355/355 tests, was 353/353; +2 from the newregister()smoke test)coverage/lcov.infocontains source files only — verified that no*.interface.ts/*.interfaces.ts/*.constants.ts/content-cli.tslines appear in the LCOV outputMade with Cursor