36

I was assigned to use SonarQube for code quality. But while I'm downloading it's plugin to Eclipse I understood it is deprecated and new one is SonarLint.

But as so far I couldn't find any good documentation to how to use SonarLint. How to check java project using that. I only got touch with Youtube videos. But sadly they are really really unclear to me.

If can direct me to a good place to gain clear knowledge on this I'll be really grateful to you.

Dil.
  • 1,996
  • 7
  • 41
  • 68
  • This pops up in the Close Votes Review. I think one should clarify if this is Offtopic or not. I'm afraid it is... :/ – hellow Jan 22 '19 at 12:12
  • @hellow why would this be off topic? – Dil. Jan 23 '19 at 07:34
  • *"Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it."* 3 votes so far for this. – hellow Jan 23 '19 at 07:41

4 Answers4

19

You can install SonarLint from the Eclipse Marketplace and read the official SonarLint documentation

Sumit Singh
  • 15,743
  • 6
  • 59
  • 89
  • 21
    I installed the plugin. Problem is how to use it. – Dil. Jan 22 '16 at 06:09
  • 9
    @pippilongstocking The first things is to enable it for a project: you right click over a project (in the project view), Configure -> Enable SonarLint. Then, files should be automatically analyse when opening them or saving them. You can also analyze all the project with right click over it -> SonarLint -> Analyze all files. Issues are marked in the editor and also appear in the "SonarLint Issues" view (Window -> Show View -> SonarLint Issues). – Duarte Meneses Jan 26 '16 at 07:41
  • @Duarte-SonarSourceTeam : is there any way (eg through maven's pom.xml) to make the "enable SonarLint for the project" step automatic? I mean: if I import an existing Maven project into Eclipse, with SonarLint plugin already installed, what could I do to have the SonarLint plugin activated for that project automatically? – François POYER Feb 01 '16 at 09:28
  • 3
    @duarte-sonarsource-team : I cannot see any option to analyze all files in SonarLint 2.1.0 plugin. Was that purposefully removed? If yes, then how are we supposed to analyse entire project? – saylee Jul 15 '16 at 10:51
  • Analyzing a full project is not a task for SonarLint. This is was SonarQube is made for. – Julien H. - SonarSource Team Sep 07 '16 at 10:00
  • Hmmm. So basically I have to go to SonarQube to see what files have issues and then individually search those files in Eclipse? I don't want to *only* avoid adding new issues, I'd like to also easily find and remove old ones... – dokaspar Oct 31 '16 at 14:51
  • @JulienH.-SonarSourceTeam how do you configure rules if you aren't using sonarqube then? – Mike D Nov 15 '17 at 15:50
  • 4
    We have now changed our mind, and recent versions of SonarLint for Eclipse and IntelliJ offer a way to run a full analysis. – Julien H. - SonarSource Team Nov 16 '17 at 11:09
  • @MikeD This is currently not possible to tune rules with SonarLint only. This is still an open subject. – Julien H. - SonarSource Team Nov 16 '17 at 11:11
  • I have installed sonarlint from eclipse marketplace , but I couldn't find any option to configure it.. I am using Eclipse Juno.. any help will be appreciated for how sonarlint works in eclipse. – Shilpi Jaiswal Jan 10 '19 at 06:16
  • while installing I get an error ```Unable to read repository at https://eclipse-uc.sonarlint.org/content.xml. sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target``` – Sridivakar Jul 04 '19 at 16:59
2

If you want to analyze a complete project with the Sonar Lint plugin, you can trick the plugin by searching all Java files with a text editor and replacing "package" with " package". This will cause SVN or git changes. Open the "Sonar Lint Report" view and run the analysis on the "Current project". Afterwards, revert all your SVN changes. Do not run the analysis again as the Sonar Lint Plugin only analyzes changed files.

I found this helpful when I had no project on the Sonar server available.

Matthias T
  • 1,230
  • 2
  • 10
  • 24
1

You can install SonarLint as described by Sumit Singh. Then you can link your project to a sonarqube server as described here

After that just make a change and save it. Sonarlint will automatically analyze the project for you. Cause analyzing is enabled by default (as far as i know)

Naxos84
  • 1,890
  • 1
  • 22
  • 34
0

Maybe I'm late but try looking at this doc/wiki about SonarLint for Eclipse:
https://github.com/SonarSource/sonarlint-eclipse/wiki

Giac1
  • 23
  • 6