Repository navigation
[DO NOT MERGE] Add project-wide semantic analysis report - #6306
alban-auzeill wants to merge 9 commits into
Conversation
| context.config().get(SonarComponents.SONAR_SEMANTIC_REPORT) | ||
| .ifPresent(path -> semanticReportScanner.writeReport(Path.of(path), context.fileSystem().baseDir().toPath())); | ||
| recordSpringTelemetry(); |
There was a problem hiding this comment.
💡 Quality: Report write failure fails the analysis and skips telemetry
ProjectEndOfAnalysisSensor.execute calls writeReport before recordSpringTelemetry() and before telemetry is sent. writeReport turns any IOException into an UncheckedIOException. The path comes from Path.of(path), so a relative path resolves against the JVM working directory rather than the project base dir, and a parent directory that doesn't exist makes Files.newBufferedWriter throw. In either case, a misconfigured optional internal diagnostic property fails the whole project analysis and drops all telemetry. Catch the exception and log it, or write the report after telemetry. Resolving relative paths against baseDir would also help.
Resolve against the base dir and log failures instead of propagating them:
context.config().get(SonarComponents.SONAR_SEMANTIC_REPORT).ifPresent(path -> {
Path baseDir = context.fileSystem().baseDir().toPath();
try {
semanticReportScanner.writeReport(baseDir.resolve(path), baseDir);
} catch (UncheckedIOException e) {
LOG.warn("Unable to write semantic report", e);
}
});
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
This comment has been minimized.
This comment has been minimized.
Code Review 👍 Approved with suggestions 2 closed / 3 findings🟡 Medium risk · Adds opt-in project-wide identifier analysis and JSON report generation Adds project-wide semantic analysis reporting with path normalization and filtering for unnamed variables. Consider catching report write exceptions and ensuring they don't suppress telemetry or fail analysis—handle relative path resolution and ensure robust error handling. 💡 Quality: Report write failure fails the analysis and skips telemetry📄 sonar-java-plugin/src/main/java/org/sonar/plugins/java/ProjectEndOfAnalysisSensor.java:62-64 📄 java-frontend/src/main/java/org/sonar/java/SemanticReportScanner.java:61 📄 java-frontend/src/main/java/org/sonar/java/SemanticReportScanner.java:79-81
Resolve against the base dir and log failures instead of propagating them✅ 2 closed✅ Edge Case: Root and file paths are normalized differently before relativize
✅ Edge Case: Unnamed variables
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
|




Summary by Gitar
SemanticReportScannerto generate project-wide semantic analysis reports in JSON format viasonar.java.internal.semantic.reportproperty.This will update automatically on new commits.