java - 通过 checkstyle-suppressions.xml 抑制 Google Checkstyle 警告
问题描述
我google_checks.xml
在我的 Gradle 项目中用作 CheckStyle 配置。
我需要能够MemberName
在我的一个课程中抑制警告,并且我可以使用@SuppressWarnings("checkstyle:MemberName")
if 且仅当我添加SuppressWarningsHolder
and SuppressWarningsFilter
to google_checks.xml
per this post时才能这样做。
问题是我google_checks.xml
定期更新,我不想记得需要重新添加这些,所以我想在单独的checkstyle-suppressions.xml
文件中处理这些抑制。这应该按照以下部分可行google_checks.xml
:
<module name="SuppressionFilter">
<property default="checkstyle-suppressions.xml" name="file"
value="${org.checkstyle.google.suppressionfilter.config}"/>
<property name="optional" value="true"/>
</module>
但是,我不知道如何让它在我的项目的根目录中而不是在默认.gradle\daemon\6.5.1\checkstyle-suppressions.xml
路径中查找此文件。如何将其指向另一个位置?
如果我设置value="${config_loc}/checkstyle-suppressions.xml"
,它会做我想要的,但我们又回到了我不想修改的问题google_style.xml
。
似乎我需要以org.checkstyle.google.suppressionfilter.config
某种方式设置系统属性,但我不确定在我的 Gradle 配置文件中的哪个位置执行此操作,或者确切设置它的位置。
解决方案
作为它的系统属性,您可以在build.gradle
下面的配置中覆盖它,假设您checkstyle-suppressions.xml
在项目根文件夹中。
注意:配置文件指向 checkstyle jar 中的 google_checks.xml,并且不是您项目的一部分。
System.setProperty( "org.checkstyle.google.suppressionfilter.config", project.projectDir.toString()+"/checkstyle-suppressions.xml" )
checkstyle {
toolVersion = checkStyleVersion
configFile = file("/google_checks.xml")
ignoreFailures = false
showViolations = false
maxWarnings = 0
}
推荐阅读
- python - 使用python进行简单的mongodb搜索
- c# - 需要通过~a id="myID" onclick=cEdit("var1","var2")>Display Text
早上好团队,我是这个网站的新手,但在过去的几个月里发现它很有帮助。我对 MVC .net core 2.2 和 c# 有一个挑战。我希望这个论坛可以提供帮助。
我需要将以下字符串传递到插件的属性中:
~a id="myID" onclick=cEdit("var1","var2")>显示文本~/a~
- r - 如何在 R 中将列表属性分配为列表名称
- mod-rewrite - 使用 apache 重写的 Angular7 无法正常工作
- filter - 过滤高幅度信号
- powershell - Powershell中优雅的词频
- amazon-web-services - 跨账户共享加密的 AMI 以启动要与 ASG 一起使用的实例
- javascript - 将输入的时间(即 PDT/PST)转换为本地时间
- protractor - 需要区分喜欢的图标和不喜欢的图标
- cypher - 需要帮助将 Neo4j Cypher 脚本转换为 Gremlin