I am using GitHub and gradle and have been trying for days now to have my code source analyzed by Sonarqube.
After a lot of needed tweaks and self learning I have successfully fixed the build to analyze all my *java files 2251/2251 source files have been analyzed
However, the final report doesn’t contain a single of my .java files.
I run the analysis with “GitHub actions”
This is the command that my build.yml runs run: ./build/build.net.tourbook/gradlew mt_0_Build sonarqube --settings-file=./build/build.net.tourbook/settings.gradle --warning-mode all --stacktrace --info
I have attached the full log of the last execution
Thanks for the details.
In the logs, I notice a lot of errors like this:
Invalid character encountered in file D:/a/mytourbook/mytourbook/MESSAGES-EDITOR/MT-version/org.eclipse.babel.editor/src/org/eclipse/pde/nls/internal/ui/editor/LocalizationEditor.java at line 2 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
Even if it is not the cause of the issue, I suggest to configure the sonar.sourceEncoding property to make the Scanner use the appropriate encoding.
I think the missing code comes from the branch setup.
The fb-sonarcloud branch has no changes on the Java code compared to the main branch, and is a short branch.
SonarCloud filters the issues and the code displayed on short branches and pull requests, to only show those related to changed code. Since there is no changed code, there is nothing to show. For more details about branch analysis, you can look at that documentation.
To fix that, I suggest to change temporarily your branch configuration on SonarCloud side, to make it consider your feature branch as a long-living branch. To do that, you can use the documentation about Branch name patterns. For example you can use fb-sonarcloud as a pattern during your tests, and then revert it to the default one or one that matches your branch workflow when the feature will be merged on main.
After that change, you will have to delete your branch on SonarCloud, and analyze it again to get the results.
@Claire_Villard
Thank you for your time and review.
I think when I signed up for Sonarcloud through GitHub action, this is not the impression I had as I thought that it would scan ANY branch with the setup they made me do (as mentioned here, it says " Set it up in just one click." It was way more than one click!
Indeed, I have renamed my branch from fb-sonarcloud to branch-sonarcloud (following the branch name patterns documentation you attached) and I can see that analysis now
I think I was mislead by the GitHub action as I thought that I could analyze my main branch in 1 build and not show those related to change code only.
So is there a way I can analyze my main branch just like I did for my branch-sonarcloud branch ?
or will it get analyzed over time when I do pull requests ?
I think when I signed up for Sonarcloud through GitHub action, this is not the impression I had as I thought that it would scan ANY branch with the setup they made me do (as mentioned here, it says " Set it up in just one click." It was way more than one click!
Let me just clarify this part. Your branch was analyzed, and any branch matching your Github action trigger will be.
About the main branch, it will get analyzed when code will be pushed to it or merged into it, after the merge of the branch-sonarcloud branch, if it matches your GitHub Action trigger. It is the main branch of your project, all code will be taken into account.
One of our core principles is to show the information that is relevant, and to carry our “Clean as you code” methodology. It means that any changed code should match your quality criteria to improve the quality of the overall code as time goes. If you changed file A to implement a feature, then you don’t want to be blocked because there is an issue in another file that has nothing to do with your feature. That’s why issues are filtered on short branches and pull requests.
The files changed on your branch were not considered as code, because they are not in a supported language. That’s why the results were empty. Your setup of SonarCloud and your project was correct.
If your problem is solved, could you please mark the relevant post as solution?