19

We recently added SonarLint to our default Eclipse install, but only use sonarlint on some new projects. While we have been quite happy with sonarlint on these projects, having automatic analysis defaulting to on for all of our legacy projects, slows down Eclipse start-up.

I could go through the 600+ projects and add a .settings/org.sonarlint.eclipse.core.prefs file containing autoEnabled=false, but I would rather have projects default to false and add an autoEnabled=true prefs file for just the projects where we have made an effort to adhere to sonarlint rules.

Is there any way to do this?

I looked at Disable Sonarlint automatic scan for Eclipse Remote Systems Explorer, but the top voted answer just suggests doing something I'm explicitly trying to avoid having to do, i.e setting prefs on 600+ projects and the other answer doesn't seem to help either.

Mark Booth
  • 7,605
  • 2
  • 68
  • 92

4 Answers4

13

From this discussion it seems that there's no way to disable automatic analysis globally by default. But there's a workaround: you can add sonar.exclusions properties for your files in the analyzer configuration (Window->Preferences->SonarLint->Analyzer Properties).

for example sonar.exclusions=**/*.js excludes all *.js files from automatic analysis

SergeyLebedev
  • 3,673
  • 15
  • 29
  • This doesn't seem to make any difference for me, even when I add exclusions, I see progress messages saying "Initialize Language Servers for" every file, including all of the files I asked to be excluded. – Mark Booth May 15 '19 at 16:20
11

This worked for me:

Window->Preferences->SonarLint->File Exclusions Then New GLOB Pattern: "**/*"

sAGIT
  • 141
  • 1
  • 4
2

You can disable this for a project basis by unchecking "Run Sonar Automatically" in project preference.

enter image description here

kuhajeyan
  • 10,727
  • 10
  • 46
  • 71
  • 1
    this option ist not available in eclipse 2019-09 with sonarLint 5.5.0 – david Nov 17 '20 at 07:39
  • This answer just duplicates the top voted answer at [Disable Sonarlint automatic scan for Eclipse Remote Systems Explorer](https://stackoverflow.com/q/39795619/42473), and as I said, I'm explicitly trying to find a solution which doesn't require me to set prefs on 600+ projects! – Mark Booth Dec 03 '20 at 15:37
1

I was also trying to disable SonarLint across all projects within one Eclipse Workspace. The following settings did not work for me using Window->Preferences->SonarLint->Analyzer Properties sonar.exclusions=**/*.java,**/*.class

So I ended up using this setting under Window->Preferences->SonarLint which does work Test file regular expressions=**/*Test.*,**/test/**/*,**/*.java,**/*.class

I think it's an oversight on the part of the SonarLint plug-in not to support the ability to disable the plug-in, or prevent its start up at the Workspace level. My installation of Eclipse is unfortunately centrally managed and I am unable to uninstall the plug-in myself.

[Edit] another option if you don't have performance issues with sonarlint, is to allow it to run but ignore the reported issues by going to the Problems pane and selecting the Filters, there under Types you can disable SonarLint

Brad
  • 15,186
  • 11
  • 60
  • 74
  • Are test files treated differently to non test files then? Thanks for the suggestion, but this doesn't seem to make any difference on my set up (Eclipse 4.7.3a & SonarLint 3.6.02018060712). – Mark Booth May 15 '19 at 16:18
  • 1
    Yes, test files are excluded on the default install of my plugin using the value `**/*Test.*,**/test/**/*` so I just added to this path. I am on Eclipse 4.7.2, SonarLint 3.0.1.1181 – Brad May 16 '19 at 15:32