I am trying to get SonarLint plugin working in Eclipse but I am not having much luck.
More specifically, I don't see any issues detected or highlighted in the "SonarLint On-the-fly" tab when looking at a simple Java class in a Java project.
I use the following software.
OS:
Win 10 Pro – Version 1709
Java:
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
Eclipse:
Version: Oxygen.3 Release (4.7.3)
Sonar software:
SonarLint Eclipse plugin:
org.sonarlint.eclipse.site-3.4.0
source: https://www.sonarlint.org/eclipse/
SonarQube:
SonarQube 7.0
source: https://www.sonarqube.org/downloads/
SonarScanner:
sonar-scanner-3.1.0.1141
source: https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner (Windows 64 bit – link)
I downloaded the SonarLint Eclipse plugin and successfully installed it in Eclipse. I can see all the SonarLint tabs and configuration options.
I downloaded and successfully setup SonarQube server (localhost on the default port 9000). I also downloaded and set up Sonar Scanner.
I created a simple Java project in Eclipse and I created a Java class in it. I added the sonar-project.properties file to the Java project.
sonar-project.properties
# must be unique in a given SonarQube instance
sonar.projectKey=sp
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=Simple Project
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set.
sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
My Eclipse Java project looks like this:
I have set up my project bindings successfully.
I can start the SonarQube and login without issues.
I navigated to the location of my "Simple Project" in Windows Explorer and opened a Windows PowerShell from there.
I executed the command sonar-scanner in the Windows PowerShell which successfully scanned the Simple Project and I can see the results in my SonarQube server.
So all is good so far. BUT… There is no indication of issues in Eclipse. I don't see any issues under the SonarLint On-the-fly tab in Eclipse.
I do have "Run SonarLint automatically" enabled (checked) and I also tried to manually analyze the App.java file by right-clicking on the file > SonarLint > Analyze.
I see no issues underlined in either the code or listed in the "SonarLint On-the-fly" tab. I must be missing a step somewhere. Could anyone please give me any tips how to get the automatic SonarLint issue detection working in Eclipse?
Thank you!
Best Answer
It turns out that the issue was in my package naming convention. Changing the package name from "com.test.pckg" to "com.dev.pckg" resolved the issue.
Jonathan in the SonarLint Google Group pointed out the following:
source: https://groups.google.com/forum/?pli=1#!topic/sonarlint/fw36A2H9AiI