Hello, we have a TypeScript repo using SonarCloud, and I’m encountering many files that seem to have no coverage. (Using SonarSource/sonarcloud-github-action
from a GitHub Actions workflow, running on main
branch in CI.)
We generate our lcov.info files using Jest, and according to Jest CLI the files have full coverage, but then in SonarCloud folders full of files have 0% or near-0% coverage. But other, sibling folders, configured the same way, have coverage matching Jest.
Example log intro from scanner:
INFO: Indexing files...
INFO: Project configuration:
INFO: Excluded sources: **/build-wrapper-dump.json, */*/src/**/*.test.ts, */*/src/**/*.test.tsx
INFO: Included tests: */*/src/**/*.test.ts, */*/src/**/*.test.tsx
INFO: Excluded sources for coverage: */*/src/**/test/**/*.*, */*/src/**/__tests__/**/*.*, */*/src/**/__fixtures__/**/*.*, */*/src/**/__mocks__/**/*.*, */*/src/**/*.stories.tsx
INFO: Excluded sources for duplication: **
INFO: Some of the project files were automatically excluded because they looked like generated code. Enable debug logging to see which files were excluded. You can disable bundle detection by setting sonar.javascript.detectBundles=false
INFO: 9732 files indexed
INFO: 9926 files ignored because of inclusion/exclusion patterns
INFO: 133 files ignored because of scm ignore settings
I ran with debug mode on, to check if anything was being excluded accidentally, or considered a test file, or detected as a bundle, or w/e; but I don’t see anything obvious. As an example, here are two log snippets…
THIS file appears covered in SonarCloud and Jest:
2023-08-17T10:59:03.2268831Z 10:59:03.225 DEBUG: 'apps/beam-ctv-enseo/src/packlets/platform-adapter/device.ts' generated metadata with charset 'UTF-8'
2023-08-17T10:59:03.2269504Z 10:59:03.225 DEBUG: file=/github/workspace/.git/.probe-1da8ccef-3a18-4563-933a-79102e1cf8d5, isRacyClean=true, read=2023-08-17 10:59:03.225465000, lastModified=2023-08-17 10:59:03.219567000, delta=5898000 ns, racy<=2500000000 ns
2023-08-17T10:59:03.2269858Z 10:59:03.225 DEBUG: file=/github/workspace/.git/.probe-1da8ccef-3a18-4563-933a-79102e1cf8d5, is racily clean
2023-08-17T10:59:03.2270284Z 10:59:03.225 DEBUG: 'apps/beam-ctv-enseo/src/packlets/platform-adapter/device.ts' indexed with language 'ts'
2023-08-17T10:59:03.2270744Z 10:59:03.225 DEBUG: File apps/beam-ctv-enseo/src/packlets/platform-adapter/device.ts excluded for duplication
But this file, although fully covered in Jest, has 0% coverage in Sonar:
2023-08-17T10:59:03.7709640Z 10:59:03.770 DEBUG: 'apps/beam-ctv-x1/src/packlets/platform-adapter/device.ts' generated metadata with charset 'UTF-8'
2023-08-17T10:59:03.7710274Z 10:59:03.770 DEBUG: 'apps/beam-ctv-x1/src/packlets/platform-adapter/device.ts' indexed with language 'ts'
2023-08-17T10:59:03.7710905Z 10:59:03.770 DEBUG: File apps/beam-ctv-x1/src/packlets/platform-adapter/device.ts excluded for duplication
Anyone have any idea what to investigate next? (The result today is developers are rapidly learning to ignore Sonar’s coverage suggestions which is not ideal.)