0

如何配置以抑制 checkstyle 上的参数数量(ParameterNumber):

检查样式配置:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>3.1.2</version>
    <dependencies>
      <dependency>
        <groupId>com.puppycrawl.tools</groupId>
        <artifactId>checkstyle</artifactId>
        <version>9.1</version>
      </dependency>
    </dependencies>
    <configuration>
      <configLocation>/config/checkstyle.xml</configLocation>
      <suppressionsLocation>/config/checkstyle-suppressions.xml</suppressionsLocation>
      <suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
    </configuration>
    <executions>
      <execution>
        <goals>
          <goal>check</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

checkstyle-suppressions.xml 文件:

<suppressions>
  <suppress checks="ParameterNumber" files="src/main/java/org/acme/Signal.java" />
</suppressions>

我仍然收到消息:

Signal.java:[247,26] (sizes) ParameterNumber: More than 7 parameters (found 15).
4

1 回答 1

0

https://checkstyle.sourceforge.io/config_filters.html#SuppressionFilter

文件属性中定义的文件的位置按以下顺序检查:

as a filesystem location
if no file found, and the location starts with either http:// or https://, then it is interpreted as a URL
if no file found, then passed to the ClassLoader.getResource() method.

使用包完全是在java中:

<suppress 
  checks="ParameterNumber"
  files="org.acme.Signal.java" />
于 2021-11-14T02:45:49.447 回答