java - Intellij 中的 Checkstyle 扫描期间出现异常
问题描述
我安装了 Checkstyle-Idea 插件,导入了 checkstyle 文件并使用下拉列表中的规则运行扫描。我受到以下例外的欢迎:
Unexpected Exception Caught
The scan failed due to an exception: Exception was thrown while processing /dir/.../Test.java
Root cause:
'other' is different type of Path
java.lang.IllegalArgumentException: 'other' is different type of Path
at java.base/sun.nio.fs.UnixPath.relativize(UnixPath.java:429)
at java.base/sun.nio.fs.UnixPath.relativize(UnixPath.java:43)
at com.puppycrawl.tools.checkstyle.utils.CommonUtil.relativizeAndNormalizePath(CommonUtil.java:382)
at com.puppycrawl.tools.checkstyle.Checker.acceptFileStarted(Checker.java:366)
at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:283)
at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:216)
at org.infernus.idea.checkstyle.service.cmd.OpScan.processAndAudit(OpScan.j... (show balloon)
互联网上其他地方没有这个例外的痕迹,这很可怕。我使用的是 8.28 版本,但我尝试使用其他旧版本并遇到了同样的问题。当我导入 checkstyle 文件时,它要求我在 checkstyle 文件中定义的 basedi 和抑制规则属性。我在两个字段中都输入了空字符串“”。
有没有人遇到过这个?
解决方案
我对 checkstyle + gradle 有类似的问题,发现这是因为我使用了basedir
属性的相对路径。将其更改为绝对路径应该可以工作(参考);
<!-- Doesn't work -->
<module name="Checker">
<property name="basedir" value="someDirectory" />
<!-- Works -->
<module name="Checker">
<property name="basedir" value="/home/myuser/someDirectory" />
推荐阅读
- ios - 如何为单击按钮时以编程方式创建的 UIImageView 设置动画?(每个按钮单击都会创建一个具有相同图像的新 UIImageView)
- javascript - 在 HTML 表单上使用 JQuery Validation 创建 Javascript 表
- c# - 在 Process.Start 期间隐藏控制台窗口
- azure-ad-b2c - Azure B2C 跳过自我断言的社交注册。如果联合用户不存在则显示错误
- sql - Oracle 将值插入现有值的中间
- python - 为什么我的 LSTM 模型的结果滞后
- r - 为什么我的包中的数据被“序列化”并且没有在最新版本的 R 中被读取?
- docusignapi - oAuth 在常规 MVC 应用程序中
- sql - 如何将另一行中的值插入列中 - SQL Server
- reactjs - 我可以从 reducer 更改状态键名称吗?