SONARJAVA-6518 Prevent JAVA analysis failure when missing java binaries#5712
Conversation
4ae2138 to
4baea4c
Compare
8fd25a0 to
64f0718
Compare
64f0718 to
61fbb24
Compare
|
Code Review ✅ Approved 2 resolved / 2 findingsRefactors classpath initialization to allow partial analysis without fatal failures, but introduces a regression where classpath warnings are incorrectly dropped when no undefined types are reported. ✅ 2 resolved✅ Bug: Classpath warnings dropped when no undefined types are reported
✅ Bug: Classpath warnings dropped when no undefined types collected
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |




Note
sonar-java classpath propertiesis used below to referencesonar.java.binaries,sonar.java.libraries,sonar.java.test.binaries,sonar.java.test.libraries.Technical decision part of this PR:
All the logic about properties "sonar.binaries" and "sonar.libraries" has been removed from the Java analyzer code.
An invalid element in one of the
sonar-java classpath properties:No files nor directories matching 'lib/*.jar'Invalid value for 'sonar.java.libraries', no files nor directories matching 'lib/*.jar'.Empty or missing sonar.java.libraries sonar.java.test.libraries:
Dependencies/libraries were not provided for analysis of SOURCE files. The 'sonar.java.libraries' property is empty. Verify your configuration, as you might end up with less precise results.Missing 'sonar.java.libraries' property. You might end up with less precise analysis results.Empty or missing sonar.java.binaries:
Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property.Missing 'sonar.java.binaries' property. You might end up with less precise analysis results.The logic in
logUndefinedTypes()has not changed. Warning related tosonar-java classpath propertiesare only logged/sent ifproblemsToFilePathsis not empty. So if there were no unresolved imports/types during the analysis, then there are no warnings.There is no longer a need to have a dedicated logic for SonarLint; the class ClasspathForMainForSonarLint has been removed.
Summary by Gitar
AbstractClasspath, introducing a unifiedinit()method andlogClasspathWarnings()to handle configuration validation.IllegalStateExceptionwith non-blocking analysis warnings whenbinariesorlibrariesproperties are missing or invalid.ClasspathForMainForSonarLintand streamlinedClasspathForMain/ClasspathForTestconfigurations.This will update automatically on new commits.