Overall Analsysis of Java Project on Sonar Cloud

We are able to run analysis on our pr with sonar cloud however an analysis for complete code is missing.
Before switching to the automatic analysis we were getting the warning that the main branch has not been analyzed.
We did try switching on automatic analysis but it only analyzed XML files.
The project is built on Java and uses maven as a build tool.

Hey there.

How are you triggering your PR analyses? Using a specific CI tool (GitHub actions, Bitbucket Pipelines, GitLab CI…)?

Hi Colin,
Yes we are using Circle CI for our build process

Thanks. What does your .circleci/config.yml look like, and what’s the name of your default (main) branch?

Likely – the CircleCI workflow that includes SonarCloud analysis hasn’t been run on that default (main) branch yet.

Hey Colin,
In config.yml we have a command mvn verify sonar:sonar, which runs on each branch push.
Our default branch is develop. When we create a pr to merge develop to main, it does run analysis on sonar cloud.

Thanks @exilent-vij.

What branches (if any) do you see in this menu?

Hi @Colin
I see develop which is my main branch in Long-Lived Branches

And is there a full analysis of all your code in that develop branch?

Yes, it’s there but it has just evaluated XML file. Also, it happened when we switch to Automatic Analysis.

We are unable to find any button or option to trigger full code analysis on develop branch.

Hey there.

  • Using Automatic Analysis in all cases will not allow you to analyze Java files. Make sure it is turned off.
  • You need to make sure that you are running analysis in your CI (CircleCI)
  • You need to make sure that a SonarCloud analysis is being run (in your CI) on each push to your develop and main branches – you should also take care to confirm in the logs that the analysis was successful.
[ **INFO** ] ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=asfasdfs&branch=develop&resolved=false
[ **INFO** ] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[ **INFO** ] More about the report processing at https://sonarcloud.io/api/ce/task?id=AX5tRnI2mrGMer4Ft1ye
[ **INFO** ] Analysis total time: 4.736 s
[ **INFO** ] **------------------------------------------------------------------------**
[ **INFO** ] **------------------------------------------------------------------------**
[ **INFO** ] Total time: 5.791 s
[ **INFO** ] Finished at: 2022-01-18T14:00:40+01:00
[ **INFO** ] **------------------------------------------------------------------------**

If this is already the case, take a step back and check that your Java files are actually being indexed. It can be helpful to add -X to your Maven command for some DEBUG logging.

[ **DEBUG** ] 14:02:39.474 6 non excluded files in this Git repository
[ **DEBUG** ] 14:02:39.478 'pom.xml' indexed with language 'xml'
[ **DEBUG** ] 14:02:39.482 'src/main/java/com/acme/basic/HelloWorld.java' indexed with language 'java'
[ **DEBUG** ] 14:02:39.484 'src/test/java/com/acme/basic/HelloWorldTest.java' indexed as test with language 'java'
[ **INFO** ] 14:02:39.485 3 files indexed

I made a direct push to develop branch.
The command that we are executing in circle ci is
mvn verify sonar:sonar -Dsonar.projectKey=exilent-systems_exilent-bills
Logs are very large so won’t be posting here. But here are some logs that I received
‘src/main/java/exilent/systems/exilentbills/ExilentBillsApplication.java’ indexed with language ‘java’
‘src/main/java/exilent/systems/exilentbills/appversion/controller/AppVersionController.java’ indexed with language ‘java’
and there are many others.
However still if I go to Overall Tab I still don’t see any change.
Is it possible to jump over a call to rectify this issue?

any update on how we can fix this??