SonarQube排除文件,目录和生成的代码? [英] SonarQube excluding files, directories, and generated code?

查看:318
本文介绍了SonarQube排除文件,目录和生成的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用的代码库有很多生成的代码.此外,我还想从SonarQube分析中排除一些不推荐使用的文件.我已经阅读了文档,并在此处查看了有关此问题的一些答案,但是这对我而言没有帮助.

The code base I am working with has a lot of generated code. In addition, there are also some deprecated files that I would want to exclude from SonarQube analysis. I've read up the documentation and looked at some answers on here about that, but it does not help in my case.

我有一个多模块Maven项目.因此,我的工作区中有多个项目,这些项目都是大型应用程序的一部分.说我要排除此文件:

I have a multi-module maven project. So I have multiple projects in my workspace that are all part of a large application. Say I want to exclude this file:

/home/username/workspace/com.mst.rtra.importing.message/bin/com/mst/rtra/importing/message/idl/parse/idlparser.java

由于文件路径的长度,我真的不知道如何在SonarQube的排除设置中编写此代码.另外,如果我想从另一个模块中排除另一个文件,怎么办:

I don't really know how to write this in the exclusions settings on SonarQube because of how long the filepath is. Also, what if I want to exclude another file, but from a different module, say :

/home/username/workspace/com.mst.rtra.interpreter.create/

我很困惑我应该在项目设置的排除框中写这个.由于该项目的多模块性质,我是否应该编写绝对文件路径?还是使用其他约定?

I am confused about I should write this in the exclusions box in project settings. Should I write the absolute file path due to the multi-module nature of this project? Or is there some other convention used?

此外,如果要从分析中排除生成的文件,则需要放入file:/generated-sources/,正如我在另一个答案中看到的那样.但是,在分析之后,当我在SonarQube仪表板中打开项目时,我仍然可以查看那些文件的分析结果.

In addition, if I want to exclude generated files from analysis, I would need to put file:/generated-sources/ as I saw in another answer. However, after analysis, I can still view the analysis results of those files when I open up the project in SonarQube dashboard.

推荐答案

我们使用ant而非maven,并使用了较早版本的Sonar ant任务.但是对我们有用的是在build.xml中设置一个sonar.exclusions属性,该属性接受文件名的通配符.例如:

We use ant rather than maven, and an older version of the Sonar ant task at that. But what works for us is setting a sonar.exclusions property in our build.xml, which accepts wildcards for filenames. For example:

<property name="sonar.exclusions" value="**/com/ex/wsdl/asvc/*.java,**/com/ex/wsdl/bsvc/*.java"/>

跳过对两个服务从wsdl文件生成的所有代码进行分析的过程.您应该能够为maven做类似的事情.

That skips analyzing all the code generated from a wsdl file for two services. You ought to be able to do something similar for maven.

这篇关于SonarQube排除文件,目录和生成的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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