【问题标题】:Checkstyle error with LineLength and JavadocMethodLineLength 和 JavadocMethod 的 Checkstyle 错误
【发布时间】:2020-05-12 22:41:09
【问题描述】:

昨天我在个人项目 (lifx-client) 中更新了 Gradle 包装器(到版本 6.1)。 在这个项目中,我使用Checkstyle 来验证代码的一些规则。 更新任务:checkstyleMain失败后出现如下错误:

$ ./gradlew checkstyleMain
> Task :checkstyleMain FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':checkstyleMain'.
> Unable to create Root Module: config {/Users/me/Projects/Miscellanea/
  lifx-client/config/checkstyle/checkstyle.xml}, classpath { ...

在用 Checkstyle 配置文件做了一些测试后(你可以在checkstyle.xml看到它),我发现如果我注释掉模块,错误就会消失:

    <module name="LineLength">
      <property name="max" value="120"/>
      <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
    </module>

    <module name="JavadocMethod">
      <property name="scope" value="public"/>
      <property name="allowMissingJavadoc" value="true"/>
      <property name="allowMissingParamTags" value="true"/>
      <property name="allowMissingThrowsTags" value="true"/>
      <property name="allowMissingReturnTag" value="true"/>
      <property name="minLineCount" value="2"/>
      <property name="allowedAnnotations" value="Override,Test,Before,Given,When,Then,And"/>
      <property name="allowThrowsTagsForSubclasses" value="true"/>
      <property name="tokens" value="METHOD_DEF"/>
    </module>

关于该问题和/或如何解决问题的任何提示?

提前致谢。

【问题讨论】:

    标签: java gradle checkstyle


    【解决方案1】:

    您需要从您的 checkstyle 插件中找到 checkstyle 库的确切错误消息。

    您很可能正面临 checksyle 库中已知的破坏性兼容性更改。 请查看https://checkstyle.org/releasenotes.html 搜索“JavadocMethod”和“LineLength”,打开相关的 Guthub 问题,您将看到“迁移说明”,其中解释了如何升级配置以解决问题。

    【讨论】:

    • 我还必须删除minLineCount。但我解决了。谢谢
    猜你喜欢
    • 1970-01-01
    • 2020-01-07
    • 2017-01-23
    • 2021-10-24
    • 2020-07-28
    • 2019-01-05
    • 2012-04-05
    • 2015-12-11
    • 1970-01-01
    相关资源
    最近更新 更多