Sonar-project.properties

Hi guys,

In my current properties file I have a very very long line of code for the exclusions.
Example, sonar.exclusions=src/main/scala/**/**/**/**/Main.scala,src/main/scala/**/**/**/**/Local.scala,src/main/scala/**/**/**/**/pa.scala,src/main/scala/**/**/**/**/infrato/*.scala,src/main/scala/**/**/**/**/dominate/settings/*.scala,src/main/scala/**/**/**/**/BotAppCall.scala,src/main/scala/**/**/**/**/**/**/**/**/com/*.scala

Is there a better way to format this instead of having this long line of code?
It just a horizontal scroll in my file, is there a way to concatenate it to be better formated?

That’s… a lot of wildcards. And there’s no reason for them, because just one ** looks through all directories. So if you really need to keep the initial source directory…

sonar.exclusions=src/main/scala/**/Main.scala,src/main/scala/**/Local.scala,src/main/scala/**/pa.scala,src/main/scala/**/infrato/*.scala,src/main/scala/**/dominate/settings/*.scala,src/main/scala/**/BotAppCall.scala,src/main/scala/**/com/*.scala

Which is already easier to read.

And, there’s a good chance you don’t need to specify src/main/scala, which means this could be reduced to:

sonar.exclusions=**/Main.scala,**/Local.scala,**/pa.scala,**/infrato/*.scala,**/dominate/settings/*.scala,**/BotAppCall.scala,**/com/*.scala

Which is much more manageable.

And, it’s not possible to break this up on different lines. However you can specify these in your Project Settings as well, under Analysis Scope, which accepts these on different lines. It ultimately is just sent to the scanner as comma separated values.

Awesome thank you so much! Can the same be done if the directory is specific to a module or would I need to keep the initial source directory?

If you’re analyzing with the SonarScanner CLI you don’t have to worry much about modules.

If you’re saying that within the repository there is another /dominate/ folder indexed as source you don’t want to exclude, yes you’ll need to still specify /src/main/scala/

Does that make sense? Happy to clarify if you have questions.