I am experiencing the below issue in the project I am working on (using SonarCloud) when my build tries to import the spotbugXml.xml files generated by Maven Spotbugs
No input file found for ‘myprogram/search/nls/MessagesUsed.java’. No SpotBugs issues will be imported on this file.
I dug deeper and found that the generated sputbugsXML.xml files don’t contain the absolute path of each file in the sourcePath element. Could that be the culprit ? Is there anything I can do to tell spotbugs and/or sonarcloud where those files are located for any given build ?
This is likely caused by a mismatch between the paths analysis sees and the paths in the SpotBugs reports. Your best option here is to normalize the paths in the report to match what analysis sees. E.G. if analysis starts from the myprogram directory, then edit that out of the report paths.
So what you’re saying is that I should put the absolute path of each file and modify each of those path in each XML reports before sending it to SonarCloud ?
You don’t necessarily need to provide the absolute path to each file, but you do need to make sure the report provides paths analysis understands. It’s not clear to me from our docs whether absolute paths would work here (my assumption is that they would, but you know what happens when you assume…). I would start by simply looking at the paths in the report and comparing them to the file paths that show up in the Code tab, which should match what analysis sees, E.G.
After more investigation, I do not see what Sonar doesn’t “understand” in the path analysis.
After reading lots of official documentation where it seems “easy”, I just can’t find what is missing.
Would you mind looking at one of my latest build where I tried to make work SpotBugs (the project is a public one)?
You can find it here
You can also find all the individual SpotBugsXML.xml files in the build’s uploaded artifact archive
When you open the log, you will see all the same error as below:
2024-04-03T21:50:49.4514713Z No input file found for ‘tourbook/search/nls/MessagesUsed.java’. No SpotBugs issues will be imported on this file.
Also, Sonar doesn’t specify the format of the report. SpotBugs can also generate HTML, is that suppored by SonarCloud ?
sonar.java.spotbugs.reportPaths
Comma-delimited list of paths to reports from SpotBugs
I’m not sure what you’re expecting me to see that’s different in this job log. I see lots of lines like
2024-04-03T21:50:48.6976826Z Sensor Import of SpotBugs issues [java]
2024-04-03T21:50:48.6978272Z Importing D:\a\mytourbook-BUILD-autocreated\core\net.tourbook\target\spotbugsXml.xml
2024-04-03T21:50:48.7913626Z No input file found for 'de/byteholder/geoclipse/GeoclipseExtensions.java'. No SpotBugs issues will be imported on this file.
2024-04-03T21:50:48.7919892Z No input file found for 'de/byteholder/geoclipse/map/ActionManageOfflineImages.java'. No SpotBugs issues will be imported on this file.
2024-04-03T21:50:48.7922719Z No input file found for 'de/byteholder/geoclipse/map/BoundingBoxEPSG4326.java'. No SpotBugs issues will be imported on this file.
2024-04-03T21:50:48.7925248Z No input file found for 'de/byteholder/geoclipse/map/BoundingBoxEPSG4326.java'. No SpotBugs issues will be imported on this file.
2024-04-03T21:50:48.7928552Z No input file found for 'de/byteholder/geoclipse/map/BoundingBoxEPSG4326.java'. No SpotBugs issues will be imported on this file.
2024-04-03T21:50:48.7931081Z No input file found for 'de/byteholder/geoclipse/map/BoundingBoxEPSG4326.java'. No SpotBugs issues will be imported on this file.
2024-04-03T21:50:48.7933674Z No input file found for 'de/byteholder/geoclipse/map/CylindricalProjection.java'. No SpotBugs issues will be imported on this file.
2024-04-03T21:50:48.7936244Z No input file found for 'de/byteholder/geoclipse/map/DialogManageOfflineImages.java'. No SpotBugs issues will be imported on this file.
2024-04-03T21:50:48.7939252Z No input file found for 'de/byteholder/geoclipse/map/DialogManageOfflineImages.java'. No SpotBugs issues will be imported on this file.
...
Again, analysis doesn’t recognize those paths. When you start from the directory analysis runs in, is there a de directory? In the de directory (if it exists) is there a byteholder directory? And so on.