How set file exclusions in SonarLint in Eclipse 2021?

Eclipse 2021

Plugin SonarLint

In Jenkins’s job I has the next SonarQube Scanner I has the next settings:


sonar.exclusions=**/generated-sources/**,**/src/test/**,**/*Header.java,./.svn,**/*.css,**/*.html,**/target/**/*.*,**/Modulation.java

Nice. It’s work fine.

Now I want to set this settings in Eclipse 2021 , in plugin SonarLint .

So in Eclipse, Window-Preferences->SonarLint->File Exclusions and set this:

sonar.exclusions=**/generated-sources/**,**/src/test/**,**/*Header.java,./.svn,**/*.css,**/*.html,**/target/**/*.*,**/Modulation.java

Is it correct settings for exclusions?

P.S.
Also in Jenkins’s job has the next settings for SonarQube Scanner:

sonar.issue.ignore.multicriteria.e1.ruleKey=java:S115
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*Type.java

sonar.java.source=1.8

What about it? How I can set it in plugin SonarLint?

Hello @a_subscriber,

You should not add sonar.exclusions= at the beginning, and I recommend you use a New... entry for each item in your exclusions list.

Let me know if this helps
Damien

The sonar.java.source=1.8 property should be automatically set from the version in use in your project.

For the other properties you mention, there is a Analyzer Properties menu near File exclusions. You could add the key and the value of each property there

I set this for SonarLint in Eclipse:


and this

Is this a correct settings?

It looks ok to me yes.

But now I realize that this might not be the best way. If you are using SonarQube you should define those properties at the project level directly in the UI. This would avoid duplicating the properties both when calling the scanner and in SonarLint.

In SonarQube, you can go to your project’s page, then Project Settings > General Settings > Analysis Scope. These settings will then automatically apply for each scan (no need to configure them in Jenkins).

Now in SonarLint there is a functionality to bind a project to the server. This will automatically apply the settings (and quality profiles) you defined in SonarQube. You can have a look at this page to see how to connect SonarLint to your SonarQube instance. You could then get rid of all the settings on the SonarLint side.

Hope this helps,
Damien

1 Like

SonarQube’s rules better set on UI (not in Jenkins’s job). As result you not need to duplicate rules in Jenkins’s job and Eclipse (SonarLint plugin).

Right?

Yes it is better to configure active rules through the Quality Profile In SonarQube UI. If the rules activated in the default Quality Profile (Sonar Way) do not suit you, you can extend or copy the QP and customize it. More on that here.

And if you bind your project in SonarLint, then it will automatically apply the QP that is assigned to your project in SonarQube. So no duplication, active rules are configured at a single place, in SonarQube

1 Like

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