我在哪里将模块元素放在Checkstyle配置文件中?

问题描述 投票:1回答:2

我有一个简单的问题,当我运行maven checkstyle,然后去检查有什么问题,我有:

Line is longer than 80 characters (found 98).

有人知道如何设置超过80个字符?我在互联网上发现了一些东西,但他们没有告诉我需要把它放在哪里:

<module name="LineLength"> <property name="max" value="120"/> </module>

有人有线索吗?

敬邀

maven checkstyle
2个回答
0
投票

您可以通过配置maven-checkstyle-plugin(您显然已经使用过)来配置自定义checkstyle配置

你可以使用custom-checker-configinline-checker-config


0
投票

通常,您需要将这些模块配置放入配置文件中,例如:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
    "https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">

    <!-- FileSetChecks go here ("parent = Checker") -->

    <module name="TreeWalker">

        <!-- TreeWalker checks go here ("parent = TreeWalker") -->

        <module name="LineLength">
            <property name="max" value="120" />
            <property name="ignorePattern" value="^\s*\*\s*\S+$" />
        </module>

    </module>
</module>

another answer中所述,您可以随后告诉Maven您的配置文件在哪里,或者您可以内联指定它(不推荐)。在任何一种情况下,您都需要获取当前使用的配置文件的副本,然后进行修改。

在普通的旧Maven Checkstyle 3.0.0中,配置文件将是this one。如果在Maven配置中指定Checkstyle版本,请修改URL中的版本号以使其匹配。

© www.soinside.com 2019 - 2024. All rights reserved.