【问题标题】:Exception during Checkstyle scan in IntellijIntellij 中的 Checkstyle 扫描期间出现异常
【发布时间】:2020-05-13 08:01:38
【问题描述】:

我安装了 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 和抑制规则属性。我在两个字段中都输入了空字符串“”。

以前有人遇到过这种情况吗?

【问题讨论】:

  • 项目路径中有符号链接吗?
  • 抛出此异常的文件不是符号链接。
  • 我会向插件开发人员报告一个错误。它可能特定于您的项目结构,因此Minimal, Complete, and Verifiable example 会有所帮助。

标签: java intellij-idea checkstyle intellij-plugin


【解决方案1】:

我在使用 checkstyle + gradle 时遇到了类似的问题,发现这是因为我为 basedir 属性使用了相对路径。将其更改为绝对路径应该可以工作 (reference);

<!-- Doesn't work -->
<module name="Checker">
  <property name="basedir" value="someDirectory" />

<!-- Works -->
<module name="Checker">
  <property name="basedir" value="/home/myuser/someDirectory" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-30
    • 2018-10-20
    • 2018-06-08
    • 2015-05-07
    • 1970-01-01
    • 1970-01-01
    • 2021-03-25
    • 2017-09-04
    相关资源
    最近更新 更多