Skip to content

Commit

Permalink
Make pulsar-brokers gradually conform project checkstyle (apache#8520)
Browse files Browse the repository at this point in the history
  • Loading branch information
Renkai authored Nov 12, 2020
1 parent f308cc4 commit bf00673
Show file tree
Hide file tree
Showing 44 changed files with 215 additions and 152 deletions.
78 changes: 72 additions & 6 deletions buildtools/src/main/resources/pulsar/checkstyle-pulsar-broker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ page at http://checkstyle.sourceforge.net/config.html -->
<property name="fileNamePattern" value=".*Tests\.java$"/>
</module>

<!-- Allow use of comment to suppress javadocstyle -->
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
<property name="onCommentFormat" value="CHECKSTYLE.ON\: ([\w\|]+)"/>
<property name="checkFormat" value="$1"/>
</module>
<module name="SuppressionFilter">
<property name="file" value="${checkstyle.suppressions.file}" default="suppressions.xml"/>
</module>
Expand All @@ -75,6 +69,78 @@ page at http://checkstyle.sourceforge.net/config.html -->

<!-- All Java AST specific tests live under TreeWalker module. -->
<module name="TreeWalker">

<!-- Allow use of comment to suppress javadocstyle -->
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
<property name="onCommentFormat" value="CHECKSTYLE.ON\: ([\w\|]+)"/>
<property name="checkFormat" value="$1"/>
</module>

<module name="SuppressWarningsHolder"/>

<module name="TodoComment">
<!-- Checks that disallowed strings are not used in comments. -->
<property name="format" value="(FIXME)|(XXX)|(@author)"/>
</module>

<!--
IMPORT CHECKS
-->

<module name="RedundantImport">
<!-- Checks for redundant import statements. -->
<property name="severity" value="error"/>
<message key="import.redundancy"
value="Redundant import {0}."/>
</module>

<module name="ImportOrder">
<property name="severity" value="error"/>
<!-- This ensures that static imports go first. -->
<property name="option" value="top"/>
<property name="sortStaticImportsAlphabetically" value="true"/>
<property name="tokens" value="STATIC_IMPORT, IMPORT"/>
<message key="import.ordering"
value="Import {0} appears after other imports that it should precede"/>
</module>

<module name="AvoidStarImport">
<property name="severity" value="error"/>
</module>

<module name="IllegalImport">
<property name="illegalPkgs"
value="autovalue.shaded, avro.shaded, bk-shade, com.google.api.client.repackaged, com.google.appengine.repackaged, io.netty.util.internal"/>
</module>

<module name="RedundantModifier">
<!-- Checks for redundant modifiers on various symbol definitions.
See: http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier
-->
<property name="tokens"
value="METHOD_DEF, VARIABLE_DEF, ANNOTATION_FIELD_DEF, INTERFACE_DEF, CLASS_DEF, ENUM_DEF"/>
</module>

<!--
IllegalImport cannot blacklist classes, and c.g.api.client.util is used for some shaded
code and some useful code. So we need to fall back to Regexp.
-->
<module name="RegexpSinglelineJava">
<property name="format"
value="com\.google\.api\.client\.util\.(ByteStreams|Charsets|Collections2|Joiner|Lists|Maps|Objects|Preconditions|Sets|Strings|Throwables)"/>
</module>

<!--
Require static importing from Preconditions.
-->
<module name="RegexpSinglelineJava">
<property name="format" value="^import com.google.common.base.Preconditions;$"/>
<property name="message" value="Static import functions from Guava Preconditions"/>
</module>

<module name="UnusedImports">
<property name="severity" value="error"/>
<property name="processJavadoc" value="true"/>
Expand Down
65 changes: 28 additions & 37 deletions buildtools/src/main/resources/pulsar/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,39 @@ what the following rules do, please see the checkstyle configuration
page at http://checkstyle.sourceforge.net/config.html -->

<module name="Checker">
<!--
<module name="SuppressWarningsFilter" />
LENGTH and CODING CHECKS
-->

<module name="LineLength">
<!-- Checks if a line is too long. -->
<property name="max" value="120"/>
<property name="severity" value="error"/>

<!--
The default ignore pattern exempts the following elements:
- import statements
- long URLs inside comments
-->

<property name="ignorePattern"
value="^(package .*;\s*)|(import .*;\s*)|( *\* .*https?://.*)$"/>
</module>

<!-- Required to support SuppressWarningsComment -->
<!-- <module name="FileContentsHolder"/>-->

<module name="SuppressWarningsFilter"/>

<module name="FileTabCharacter">
<!-- Checks that there are no tab characters in the file. -->
</module>

<module name="RegexpSingleline">
<!-- Checks that TODOs don't have stuff in parenthesis, e.g., username. -->
<property name="format" value="((//.*)|(\*.*))TODO\(" />
<property name="format" value="((//.*)|(\*.*))TODO\("/>
<property name="message" value="TODO comments must not include usernames." />
<property name="severity" value="error" />
</module>
Expand All @@ -59,12 +82,6 @@ page at http://checkstyle.sourceforge.net/config.html -->
<property name="fileNamePattern" value=".*Tests\.java$" />
</module>

<!-- Allow use of comment to suppress javadocstyle -->
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
<property name="onCommentFormat" value="CHECKSTYLE.ON\: ([\w\|]+)"/>
<property name="checkFormat" value="$1"/>
</module>
<module name="SuppressionFilter">
<property name="file" value="${checkstyle.suppressions.file}" default="suppressions.xml" />
</module>
Expand Down Expand Up @@ -110,7 +127,8 @@ page at http://checkstyle.sourceforge.net/config.html -->
</module>

<module name="IllegalImport">
<property name="illegalPkgs" value="autovalue.shaded, avro.shaded, bk-shade, com.google.api.client.repackaged, com.google.appengine.repackaged, io.netty.util.internal"/>
<property name="illegalPkgs"
value="autovalue.shaded, avro.shaded, bk-shade, com.google.api.client.repackaged, com.google.appengine.repackaged, io.netty.util.internal"/>
</module>

<module name="RedundantModifier">
Expand Down Expand Up @@ -154,16 +172,12 @@ page at http://checkstyle.sourceforge.net/config.html -->
<module name="JavadocMethod">
<property name="scope" value="protected"/>
<property name="severity" value="error"/>
<property name="allowMissingJavadoc" value="true"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
<property name="allowUndeclaredRTE" value="true"/>
</module>

<!-- Check that paragraph tags are used correctly in Javadoc. -->
<module name="JavadocParagraph"/>
<!-- <module name="JavadocParagraph"/>-->

<module name="JavadocType">
<property name="scope" value="protected"/>
Expand Down Expand Up @@ -281,27 +295,6 @@ page at http://checkstyle.sourceforge.net/config.html -->
<property name="severity" value="error"/>
</module>

<!--
LENGTH and CODING CHECKS
-->

<module name="LineLength">
<!-- Checks if a line is too long. -->
<property name="max" value="120"/>
<property name="severity" value="error"/>

<!--
The default ignore pattern exempts the following elements:
- import statements
- long URLs inside comments
-->

<property name="ignorePattern"
value="^(package .*;\s*)|(import .*;\s*)|( *\* .*https?://.*)$"/>
</module>

<module name="LeftCurly">
<!-- Checks for placement of the left curly brace ('{'). -->
<property name="severity" value="error"/>
Expand Down Expand Up @@ -426,8 +419,6 @@ page at http://checkstyle.sourceforge.net/config.html -->
<property name="severity" value="error"/>
</module>

<!-- Required to support SuppressWarningsComment -->
<module name="FileContentsHolder"/>

</module>
</module>
27 changes: 20 additions & 7 deletions buildtools/src/main/resources/pulsar/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,26 @@
<suppress checks="JavadocType" files=".*Impl\.java$" />

<!-- suppress all checks in the generated directories -->
<suppress checks=".*" files=".+[\\/]generated[\\/].+\.java" />
<suppress checks=".*" files=".+[\\/]generated-sources[\\/].+\.java" />
<suppress checks=".*" files=".+[\\/]generated-test-sources[\\/].+\.java" />
<suppress checks=".*" files=".+[\\/]generated[\\/].+\.java"/>
<suppress checks=".*" files=".+[\\/]generated-sources[\\/].+\.java"/>
<suppress checks=".*" files=".+[\\/]generated-test-sources[\\/].+\.java"/>

<!-- suppress all checks in the copied code -->
<suppress checks=".*" files=".+[\\/]com[\\/]scurrilous[\\/]circe[\\/].+\.java" />

<suppress checks=".*" files="MLDataFormats.java" />
<suppress checks=".*" files="BitSetRecyclable.java" />
<suppress checks=".*" files=".+[\\/]com[\\/]scurrilous[\\/]circe[\\/].+\.java"/>

<suppress checks=".*" files="MLDataFormats.java"/>
<suppress checks=".*" files="BitSetRecyclable.java"/>
<suppress checks=".*" files="Schema.java"/>
<suppress checks="StaticVariableName" files="AuthData.java"/>
<suppress checks="MethodName" files="AuthenticationFactory.java"/>
<suppress checks="ConstantName" files="MessageId.java"/>
<suppress checks="MethodName" files="TopicsImpl.java"/>
<suppress checks="MemberName" files="TopicsImpl.java"/>
<suppress checks="ImportOrder" files="src/main/java/org/apache/pulsar/common/.*.java"/>
<suppress checks="ImportOrder" files="src/main/java/org/apache/pulsar/client/.*.java"/>
<suppress checks="ImportOrder" files="src/main/java/org/apache/pulsar/transaction/.*.java"/>
<suppress checks="ImportOrder" files="src/main/java/org/apache/pulsar/broker/.*.java"/>
<suppress checks="ImportOrder" files="src/main/java/org/apache/pulsar/compaction/.*.java"/>
<suppress checks="ImportOrder" files="src/main/java/org/apache/pulsar/utils/.*.java"/>
<suppress checks="ImportOrder" files="src/main/java/org/apache/pulsar/sql/.*.java"/>
</suppressions>
30 changes: 15 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ flexible messaging model and an intuitive client API.</description>
<jackson.databind.version>2.11.1</jackson.databind.version>
<reflections.version>0.9.11</reflections.version>
<swagger.version>1.5.21</swagger.version>
<puppycrawl.checkstyle.version>6.19</puppycrawl.checkstyle.version>
<puppycrawl.checkstyle.version>8.37</puppycrawl.checkstyle.version>
<dockerfile-maven.version>1.4.13</dockerfile-maven.version>
<typetools.version>0.5.0</typetools.version>
<protobuf2.version>2.4.1</protobuf2.version>
Expand Down Expand Up @@ -210,7 +210,7 @@ flexible messaging model and an intuitive client API.</description>
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<maven-archiver.version>2.5</maven-archiver.version>
<nifi-nar-maven-plugin.version>1.2.0</nifi-nar-maven-plugin.version>
<maven-checkstyle-plugin.version>3.0.0</maven-checkstyle-plugin.version>
<maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
<git-commit-id-plugin.version>4.0.2</git-commit-id-plugin.version>
<wagon-ssh-external.version>2.10</wagon-ssh-external.version>
<os-maven-plugin.version>1.4.1.Final</os-maven-plugin.version>
Expand Down Expand Up @@ -437,7 +437,7 @@ flexible messaging model and an intuitive client API.</description>
<artifactId>jetty-util</artifactId>
<version>${jetty.version}</version>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
Expand Down Expand Up @@ -609,7 +609,7 @@ flexible messaging model and an intuitive client API.</description>
<artifactId>jna</artifactId>
<version>${jna.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
Expand Down Expand Up @@ -935,37 +935,37 @@ flexible messaging model and an intuitive client API.</description>
<artifactId>opencensus-api</artifactId>
<version>${opencensus.version}</version>
</dependency>

<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-contrib-grpc-metrics</artifactId>
<version>${opencensus.version}</version>
</dependency>

<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda.version}</version>
</dependency>

<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>${javassist.version}</version>
</dependency>

<dependency>
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
<version>${jcip.version}</version>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>aircompressor</artifactId>
Expand All @@ -977,13 +977,13 @@ flexible messaging model and an intuitive client API.</description>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>${objenesis.version}</version>
</dependency>

</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -1296,7 +1296,7 @@ flexible messaging model and an intuitive client API.</description>
<exclude>**/_helpers.tpl</exclude>
</excludes>
</configuration>
</plugin>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
Expand Down Expand Up @@ -1395,7 +1395,7 @@ flexible messaging model and an intuitive client API.</description>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
<version>${maven-assembly-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -1690,6 +1690,6 @@ flexible messaging model and an intuitive client API.</description>
<url>http://packages.confluent.io/maven/</url>
</repository>
</repositories>

</project>

Loading

0 comments on commit bf00673

Please sign in to comment.