You can try following these steps:
1. Correct the Path to lcov.info in pom.xml:
Ensure the path to lcov.info is accurate. If your project structure is:
project-root/
├── ui.frontend/
│ ├── coverage/
│ │ └── lcov.info
└── pom.xml
Update the path in your root pom.xml to:
<sonar.javascript.lcov.reportPaths>${project.basedir}/ui.frontend/coverage/lcov.info</sonar.javascript.lcov.reportPaths>
2. Remove or Update Obsolete Properties:
- Remove <sonar.dynamic>reuseReports</sonar.dynamic> as it's deprecated.
- Ensure you’re using SonarQube JavaScript/TypeScript plugin compatible with SonarQube 9.9 LTS.
3. In jest.config.js or package.json, ensure coverage paths are relative to the project root. Example Jest config:
module.exports = {
//...
coverageReporters: ['lcov', 'json', 'text'],
collectCoverageFrom: ['src//*.tsx'],
coverageDirectory: 'coverage',
};
4. In your pom.xml or Sonar properties, define:
<sonar.sources>ui.frontend/src</sonar.sources>
5. After running the SonarScanner, check logs for:
INFO: Analyzing coverage report: /path/to/lcov.info
INFO: Coverage statistics were loaded from 1 file
Sample Working Configuration in pom.xml:
<properties>
<sonar.sources>ui.frontend/src</sonar.sources>
<sonar.tests>ui.frontend/src</sonar.tests>
<sonar.test.inclusions>/*.test.tsx</sonar.test.inclusions>
<sonar.javascript.lcov.reportPaths>ui.frontend/coverage/lcov.info</sonar.javascript.lcov.reportPaths>
</properties>
Troubleshooting:
- Paths in lcov.info: Ensure they’re relative to the project root (e.g., ui.frontend/src/App.tsx → src/App.tsx).
- Confirm JavaScript/TypeScript plugin versions support LCOV.
- If you're using Maven multi-module setup, configure the sonar.javascript.lcov.reportPaths in the respective module’s POM.
For information about the Code Editor plugin, you can visit the official SonarQube page, which offers plugins for various IDEs: https://www.sonarsource.com/products/sonarlint/