java - 计算存储库中忽略抑制文件的检查样式错误数
问题描述
我有一个 Maven 应用程序。在 pom.xml 它有一个maven-checkstyle-plugin
3.1.1 配置的suppressions.xml
文件。
我需要计算代码中检查样式错误的数量,而忽略了 suppresss.xml文件。
有没有办法通过命令行来做到这一点?
现在我想出了以下几点:
mvn clean checkstyle:checkstyle
-Dcheckstyle.config.location=http://example.com/checkstyle.xml
-Dcheckstyle.config.logViolationsToConsole=true
-Dcheckstyle.includeResources=false
-Dcheckstyle.includeTestResources=false
或者
mvn clean org.apache.maven.plugins:maven-checkstyle-plugin:3.1.1:checkstyle
-Dcheckstyle.config.location=http://example.com/checkstyle.xml
-Dcheckstyle.config.logViolationsToConsole=true
-Dcheckstyle.includeResources=false
-Dcheckstyle.includeTestResources=false
但它仍然考虑到 suppresss.xml。
解决方案
没有好的方法可以做到这一点,但是有一个解决方法
- 用属性替换 checkstyle 抑制文件位置(例如 checkstyle.suppressions)
- 创建具有 0 个抑制的抑制文件,例如
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
</suppressions>
- 将步骤 1 中的属性设置为此“空”文件的路径。Cli 选项覆盖 pom.xml 中的值
此外,您可以在 checkstyle 配置中替换抑制文件的路径,并以相同的方式用属性覆盖它。
推荐阅读
- twitter-bootstrap - 如何在不使用“font awesome”的情况下更改 Bootstrap 导航栏的下拉插入符号图标?
- json - 升级到 Jersey 2.29.1 时找不到媒体类型 = 应用程序/json 的异常 MessageBodyReader
- arrays - 查找、更新元素并更改其在对象数组中的索引
- c++ - Arduino/C++ 一个带有引用的指针数组
- html - 元素的边距溢出父级
- reactjs - 如何将 this.setState({ [section]: y }) 转换为 useState 钩子?
- node.js - 使用 node.js 传递多个参数时的错误值 NaN
- linux - ubuntu 16.04上的Openstack安装错误
- html - CSS 将元素的宽度设置为前一个子元素的 110%
- javascript - 带有 express/reactjs/nextjs 的 SSR - 最佳方法