SonarLint Eclipse:是否还会分析"src/test"中的源代码? [英] SonarLint Eclipse : Does it also analyze source code in "src/test"?

查看:79
本文介绍了SonarLint Eclipse:是否还会分析"src/test"中的源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我公司中,我们目前正在以连接模式 SonarLint Eclipse (版本3.1)与SonarJava(版本4.7.1)一起用于SonarQube服务器(版本5.6).

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

我们想从SonarLint Eclipse中分析一些插件和一些测试插件:

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

1.如果源代码在"src/java" 中,则SonarLint效果很好,并且显示根据从中定义的规则检测到的一些问题SonarQube服务器的SonarQube配置文件.

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.但是,如果源代码在"src/test/" 中,则SonarLint在"SonarLint On The Fly"视图中不会显示任何问题.在这种情况下,SonarLint日志显示:

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在Java主文件和Java测试文件之间的工作方式似乎有所不同.

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

是否有一种配置SonarLint的方法,以便它在连接模式下对Java主文件和Java测试文件的工作方式相同?

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?

推荐答案

在SonarLint for Eclipse中,您可以配置将哪些文件视为测试源.

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

转到:

首选项-> SonarLint

Preferences -> SonarLint

并更改测试文件正则表达式".

And change the "Test file regular expressions".

这篇关于SonarLint Eclipse:是否还会分析"src/test"中的源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆