Analysis successful but source code is missing from the report?


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.

Here is the public SonarCloud project:

As you can see, all my *.java files are not showing, yet the build mentions this
ANALYSIS SUCCESSFUL, you can find the results at:


Hi @FJBDev, welcome to the community!

Usually, missing source code comes from unusual source folders.
I need more information to be able to investigate further:

  • how do you run the analysis? Which CI, and the scanner command
  • the full logs of the last Scanner execution

You can also configure the analysis scope, to tell SonarCloud which files to include or exclude from the analysis:

Bonjour Claire,

I run the analysis with “GitHub actions”
This is the command that my build.yml runs
run: ./build/ mt_0_Build sonarqube --settings-file=./build/ --warning-mode all --stacktrace --info

I have attached the full log of the last execution (201.7 KB)

Those are my sonar settings

property "sonar.projectBaseDir", "D:/a/mytourbook/mytourbook/bundles"
    property "sonar.sources", "."
    property "sonar.exclusions", "build/**/*,bundles/net.tourbook.chart/src/net/tourbook/chart/,bundles/net.tourbook.ext.jars/**/*,features,LANGUAGE-FRAGMENTS"
    property "", "."

Let me know if you need anything else


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/ 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.

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 :slight_smile:
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 ?

Thank you again

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?


1 Like

Thanks for all your details, that is very helpful.

It was my misunderstanding that I thought at first, a branch would be analyzed right off the bat but now I understand.

It works now for me, though I have some wrinkles to address and documentation to read to educate myself.

Thanks again for your time and help, I really appreciate it as I was “blocked”


PS: I have marked your post as a solution, let me know if I need to do anything else as I am new to this community.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.