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

那年仲夏 提交于 2019-12-23 20:30:25

问题


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?


回答1:


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".



来源:https://stackoverflow.com/questions/43843455/sonarlint-eclipse-does-it-also-analyze-source-code-in-src-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!