SLE - Analyzer Properties sonar.exclusions doesn't work

2,495 views
Skip to first unread message

gilbert...@googlemail.com

unread,
Jun 13, 2016, 4:17:49 PM6/13/16
to SonarLint
Hi,

using Sonarlint 2.1.0.20160603-1122-RELEASE with Eclipse Mars 4.5.1
Neither Window | Preferences | SonarLint | Analyzer Properties | sonar.exclusions
nor Project | Properties | SonarLint | Analyzer Properties | sonar.exclusions works.
Whereas using @SuppressWarnings("...") for deactivating all or specific rules
works fine - didn't work in Sonarlint 2.0.0

//Gilbert

Julien HENRY

unread,
Jun 17, 2016, 4:03:30 AM6/17/16
to SonarLint
Hi Gilbert,

That's expected. SonarLint has its own way to determine what are the files to analyze. For example in Eclipse generated files are marked as "derived" so we can automatically ignore them while on SonarQube side it has to be a manual configuration.
Again we are trying as much as possible to keep SonarLint simple without need to do some extra configuration.

Can you share the reason why you would need to manually exclude some files?

++

Julien

gilbert...@googlemail.com

unread,
Jun 17, 2016, 2:04:26 PM6/17/16
to SonarLint
Hi Julien,

keep it simple (KISS) is great, but what about finetuning ?
Git has .gitignore, how to adjust the in- and excludes for Sonarlint ?
Does Sonarlint 2.1.0 already take the in/exclude settings from Sonarqube server
into account ? If yes, how to adjust for projects without a binding ?
And what' the purpose of Sonarlint | Analyzer Properties after all ?

//Gilbert

Julien HENRY

unread,
Jun 20, 2016, 9:51:10 AM6/20/16
to SonarLint
Hi Gilbert,


keep it simple (KISS) is great, but what about finetuning ?
Git has .gitignore, how to adjust the in- and excludes for Sonarlint ?

Currently there is no way.
Ā 
Does Sonarlint 2.1.0 already take the in/exclude settings from Sonarqube server
into account ?

No.Ā 
Ā 
If yes, how to adjust for projects without a binding ?
And what' the purpose of Sonarlint | Analyzer Properties after all ?

This can be used to pass properties to analyzers. But there are very few of them currently.
Ā 
I'm still interested to know what are the files you want to exclude (and why).

++

gilbert...@googlemail.com

unread,
Jun 20, 2016, 2:07:49 PM6/20/16
to SonarLint
Hi Julien,

for example there are files generated by a gui mapping framework
and other generated files.
IMO the ignore settings from Sonarqube server should be respected, it's just
like issues marked as false positives should be recognized by Sonarlint - which
is already in work i believe.
What are those properties that might be passed via preferences ?

//Gilbert

Julien HENRY

unread,
Jun 21, 2016, 2:17:43 AM6/21/16
to gilbert...@googlemail.com, SonarLint
2016-06-20 20:07 GMT+02:00 gilbert.rebhan via SonarLint <sona...@googlegroups.com>:
for example there are files generated by a gui mapping framework
and other generated files.

Generated files are usually marked as "derived" in Eclipse and SonarLint will properly ignore such files.
Ā 
IMO the ignore settings from Sonarqube server should be respected, it's just
like issues marked as false positives should be recognized by Sonarlint - which
is already in work i believe.

For connected mode that's another story. We may indeed consider to import exclusion settings in SonarLint.
Ā 
What are those properties that might be passed via preferences ?

As I said there are very few for non commercial analyzers. One example:Ā sonar.javascript.jQueryObjectAliasesĀ for theĀ JavaScript analyzer.

gilbert...@googlemail.com

unread,
Jun 29, 2016, 9:38:42 AM6/29/16
to SonarLint, gilbert...@googlemail.com
Hi Julien,


for example there are files generated by a gui mapping framework
and other generated files.

Generated files are usually marked as "derived" in Eclipse and SonarLint will properly ignore such files.
Ā 
Actually it's moreĀ  tricky. ThatĀ GUI Mapping isĀ our own plugin, which works like that :
Started in context of an Eclipse Project, it creates some Java skeletonclasses under /src
and also some Java UI classes and XML descriptions under /gen.

At first i thought of a possible workaround = Setting the "Derived" property onĀ  those generated files
inĀ /gen via Eclipse API or manually, because those files need no inspection.
But that revealed a problem, the Eclipse EGit plugin automatically adds all derived files to .gitignore
which is bad,Ā  because those files are needed at runtime and must be pushed to GIT repository.
IMO Sonarlint should provide a Feature to exclude/include files via Preferences with global and project scope.

//Gilbert

Julien HENRY

unread,
Jun 29, 2016, 9:47:08 AM6/29/16
to gilbert...@googlemail.com, SonarLint

--
You received this message because you are subscribed to the Google Groups "SonarLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarlint+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarlint/f83a64fe-e79a-4767-84ce-94888f3843d9%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

gilbert...@googlemail.com

unread,
Jun 29, 2016, 10:06:57 AM6/29/16
to SonarLint, gilbert...@googlemail.com
Hi Julien,

yes disabling that EGit feature is possible, but it is a very helpful behaviour, otherwise you'll
have all those bin folders in your GIT repository .. etc. because there is always someone who
forgets to adjust his .gitignore
Having toĀ use Ā the "Derived" attribute as workaround for sonar.exclusions ain't a clean
solution it's more like a hack.

What are the arguments against supporting sonar.exclusions in Sonarlint ?
When Sonarqube server settings are included for connected projects,Ā it's required only
for projects without a binding,

//Gilbert

Julien HENRY

unread,
Jun 29, 2016, 4:09:17 PM6/29/16
to SonarLint, gilbert...@googlemail.com
First, I don't think tagging generated code as derived is a hack. This is exactly the meaning of this feature. Also I didn't said all files that you don't want to be analyzed should be marked as derived.

Another question to better understand your concern: what is the problem of SonarLint analyzing those files? Is is a performance issue? Since you are never manually editing those files, it should not be a big concern.

I would like to avoid as long as possible to introduce "per file" preference since this is difficult to store and maintain. If SonarLint can be smarter, that's better. For Java code one option would be to mark you generated code with @Generated annotation, and make SonarLint use that to skip analysis on such files.

Johannes Becker

unread,
Aug 16, 2017, 6:51:04 AM8/16/17
to SonarLint, gilbert...@googlemail.com
Hi Julien,

I'm using the latest Eclipse SonarLint plugin (v3.2.x). I personally would like to see "sonar.exlusions" being supported. We have a lot of files which are copied from an other repo and slightly modified. Since these copied files are not "of very good quality" and we are not able to refactor them (because of future merging processes) these findings are bloating my view.

Regards
Johannes

haiy...@gmail.com

unread,
Oct 19, 2017, 2:56:05 PM10/19/17
to SonarLint
Hi,

I have an issue where I need to set excludes in sonarlint because I don't want it to scan all of the node_modules directory that is all libraries that I can't do anything about.

Julien HENRY

unread,
Oct 20, 2017, 3:02:06 AM10/20/17
to haiy...@gmail.com, SonarLint
Hi,

Please open a new thread instead of replying to an existing one.

Are you in connected mode?

For standalone mode, I suggest to follow/vote for:
and/or

Regards,

Julien Henry | SonarSource

Developer

https://sonarsource.com


--
You received this message because you are subscribed to the Google Groups "SonarLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarlint+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarlint/1c0d9c7a-d52b-4797-a96c-7c6a64f215fd%40googlegroups.com.

T3rm1

unread,
Nov 8, 2017, 10:12:54 AM11/8/17
to SonarLint
Why create a new one when this one is about the same problem?

I'm here because I also need a way to ignore certain files. We trigger our analysis in a Jenkins pipeline. The configuration is located in sonar-project.properties. This file is under version control and has all the configuration for Sonar. I can't understand why SonarLint ignores these settings (sonar.exclusions).
To unsubscribe from this group and stop receiving emails from it, send an email to sonarlint+...@googlegroups.com.

Jonathan Jensen

unread,
Nov 8, 2017, 10:33:42 AM11/8/17
to T3rm1, SonarLint
I agree why create a new thread when this is a discussion about the same problem.

Julien, to answer your question I am trying to run this in connected mode. I will try to up vote that issue thank you.

--
You received this message because you are subscribed to a topic in the Google Groups "SonarLint" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarlint/aBxnpn-yLbg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarlint+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarlint/064f334b-42b1-4305-a543-3727b88cff2e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
~ JonĀ 

Julien HENRY

unread,
Nov 8, 2017, 10:37:08 AM11/8/17
to T3rm1, SonarLint
Hi,

I think it is usually better to open a new thread when previous message is 1 year old, but here that's more personal taste so let's continue here.

I have a good news: we have decided to introduce the ability to configure SonarLint side exclusions (https://jira.sonarsource.com/browse/MMF-394). This will allow to configure exclusions globally in your IDE, or per project.

To answer your question "why SonarLint is not able to import settings from sonar-project.properties": this is because it is quite complex. First you know that there are multiple scanners (Maven, Gradle, CLI, MSBuild, Ant, ...). And many places where you can put your configuration (on the command line, in Jenkins, on SonarQube side, ...).
Taking only the example of sonar.project.properties, the file is most of the time located at the root of your project. But if you have a multi-module project, in Eclipse, you'll not have the sonar-project.properties file at the root of projects.

Then come the question of the synchronization lifecycle: should we read sonar.exclusions at IDE startup? When project is opened? Each time sonar-project.properties file is updated?

So let's first introduce the ability for SonarLint to exclude files by itself (ie not due to server side configuration), and then later we can think about adding bridges between scanners configuration and SonarLint.

++


Julien Henry | SonarSource

Developer

https://sonarsource.com


To unsubscribe from this group and stop receiving emails from it, send an email to sonarlint+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarlint/064f334b-42b1-4305-a543-3727b88cff2e%40googlegroups.com.

Jonathan Jensen

unread,
Nov 8, 2017, 10:43:28 AM11/8/17
to Julien HENRY, T3rm1, SonarLint
Julien,

That sounds like a viable solution to me. Thank you for your replies.

--
You received this message because you are subscribed to a topic in the Google Groups "SonarLint" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarlint/aBxnpn-yLbg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarlint+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarlint/CAD9wyxEP-QRjcLM78dQAqDHNofNMWkAoTu6CFkiCrsu640c-6Q%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
~ JonĀ 
Reply all
Reply to author
Forward
0 new messages