How to make sonar analysis only Java and Scala code?

I am evaluating sonar cloud with 14 days trial license in private repos. I only want to analyze Java and Scala code in my private project, along with coverage.

I have setup the inclusions and exclusions like below

But I am observing that sonar is still analysing non-Java and Scala files and the excluded folders.

Can someone let me know what I am doing wrong?

Hi,

Can you share your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Ann

I have made the following changes and it is working as expected now.

I have updated the Analysis Scope like below

In my root pom.xml I have also added the below properties

     <properties>
        <sonar.exclusions>**/generated/**,**/integration-tests/**,src/**/test/**</sonar.exclusions>
        <sonar.inclusions>**/*.scala,**/*.java</sonar.inclusions>
  </properties>

ctrl-db-schema maven module I wanted to skip from analysis. So in ctrl-db-schema pom.xml I added the below

<properties>
  <sonar.skip>true</sonar.skip>
<properties>

Hi,

I’m glad you’ve worked through this.

And I’d advise putting the inclusions and exclusions in only one place. The ones in the pom override the ones set in the UI. With settings in both places you may someday find yourself adjusting what’s in the UI and wondering why the changes aren’t kicking in.

 
HTH,
Ann

1 Like

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