Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SonarLint Eclipse : Does it also analyze source code in "src/test"?

In my company, we are currently using SonarLint Eclipse (version 3.1) in connected mode to SonarQube server (version 5.6), with SonarJava (version 4.7.1).

We have some plugins and some test plugins that we want to analyze from SonarLint Eclipse :

1.If the source code is in "src/java", SonarLint works well and displays some issues detected according the rules defined from the SonarQube profile of our SonarQube server.

2.But if the source code is in "src/test/", SonarLint does not display any issue in the view "SonarLint On The Fly". In this case, SonarLint logs show:

    ...src/test/..../MyClassTest.java
    1 files indexed
    Execute Sensor: JavaSquidSensor
    Configured Java source version (sonar.java.source): 8
    JavaClasspath initialization
    JavaClasspath initialization (done) | time=17ms
    JavaTestClasspath initialization
    JavaTestClasspath initialization (done) | time=15ms
    Java Main Files AST scan
    0 source files to be analyzed
    Java Main Files AST scan (done) | time=0ms
    Java Test Files AST scan
    1 source files to be analyzed
    0/0 source files have been analyzed

SonatLint seems to work differently between Java Main Files and Java Test Files.

Does there is a way to configure SonarLint in order that it works on the same way for Java Main Files and Java Test Files in connected mode?

like image 368
lpa Avatar asked Oct 17 '22 12:10

lpa


1 Answers

In SonarLint for Eclipse, you can configure which files are considered to be test sources.

Go to:

Preferences -> SonarLint

And change the "Test file regular expressions".

like image 53
Duarte Meneses Avatar answered Oct 27 '22 22:10

Duarte Meneses