mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-02 22:47:41 +01:00
Add Checkstyle rules and suppressions
This commit adds Checkstyle rules for EssentialsX, based on those from the adventure library (https://github.com/KyoriPowered/adventure/tree/master/.checkstyle). It also makes Checkstyle passes mandatory for a GH build to pass.
This commit is contained in:
parent
89b3c9233e
commit
234a481b0d
183
.checkstyle/checkstyle.xml
Normal file
183
.checkstyle/checkstyle.xml
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
<?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">
|
||||||
|
|
||||||
|
<!-- based on https://github.com/KyoriPowered/adventure/blob/master/.checkstyle/checkstyle.xml -->
|
||||||
|
|
||||||
|
<module name="Checker">
|
||||||
|
<property name="charset" value="UTF-8"/>
|
||||||
|
<property name="fileExtensions" value="java, properties, xml"/>
|
||||||
|
<property name="severity" value="error"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_filefilters.html#BeforeExecutionExclusionFileFilter -->
|
||||||
|
<module name="BeforeExecutionExclusionFileFilter">
|
||||||
|
<property name="fileNamePattern" value="module\-info\.java$"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_whitespace.html#FileTabCharacter -->
|
||||||
|
<module name="FileTabCharacter">
|
||||||
|
<property name="eachLine" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
|
||||||
|
<module name="NewlineAtEndOfFile"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
|
||||||
|
<module name="SuppressionFilter">
|
||||||
|
<property name="file" value="${checkstyle.suppressions.file}"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_filters.html#SuppressWithPlainTextCommentFilter -->
|
||||||
|
<module name="SuppressWithPlainTextCommentFilter"/>
|
||||||
|
|
||||||
|
<module name="TreeWalker">
|
||||||
|
<!-- https://checkstyle.org/config_misc.html#ArrayTypeStyle -->
|
||||||
|
<module name="ArrayTypeStyle"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_imports.html#AvoidStarImport -->
|
||||||
|
<module name="AvoidStarImport"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_misc.html#AvoidEscapedUnicodeCharacters -->
|
||||||
|
<module name="AvoidEscapedUnicodeCharacters">
|
||||||
|
<property name="allowByTailComment" value="true"/>
|
||||||
|
<property name="allowEscapesForControlCharacters" value="true"/>
|
||||||
|
<property name="allowNonPrintableEscapes" value="true"/>
|
||||||
|
<property name="severity" value="info"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_misc.html#CommentsIndentation -->
|
||||||
|
<module name="CommentsIndentation"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_whitespace.html#EmptyForInitializerPad -->
|
||||||
|
<module name="EmptyForInitializerPad"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_whitespace.html#EmptyForIteratorPad -->
|
||||||
|
<module name="EmptyForIteratorPad"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_whitespace.html#EmptyLineSeparator -->
|
||||||
|
<module name="EmptyLineSeparator">
|
||||||
|
<property name="allowMultipleEmptyLines" value="false"/>
|
||||||
|
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
|
||||||
|
<property name="allowNoEmptyLineBetweenFields" value="true"/>
|
||||||
|
<property name="tokens"
|
||||||
|
value="CLASS_DEF, CTOR_DEF, ENUM_DEF, IMPORT, INSTANCE_INIT, INTERFACE_DEF, METHOD_DEF, STATIC_IMPORT, STATIC_INIT, VARIABLE_DEF"/> <!-- remove PACKAGE_DEF, temporarily remove COMPACT_CTOR_DEF, RECORD_DEF -->
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_coding.html#FallThrough -->
|
||||||
|
<module name="FallThrough">
|
||||||
|
<property name="checkLastCaseGroup" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_design.html#FinalClass -->
|
||||||
|
<module name="FinalClass"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_coding.html#FinalLocalVariable -->
|
||||||
|
<module name="FinalLocalVariable"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_whitespace.html#GenericWhitespace -->
|
||||||
|
<module name="GenericWhitespace"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_design.html#HideUtilityClassConstructor -->
|
||||||
|
<module name="HideUtilityClassConstructor"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_imports.html#IllegalImport -->
|
||||||
|
<module name="IllegalImport">
|
||||||
|
<property name="illegalPkgs" value="sun, jdk, com.sun"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_coding.html#IllegalTokenText -->
|
||||||
|
<module name="IllegalTokenText">
|
||||||
|
<property name="format"
|
||||||
|
value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
||||||
|
<property name="message"
|
||||||
|
value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
|
||||||
|
<property name="tokens" value="CHAR_LITERAL, STRING_LITERAL"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_misc.html#Indentation -->
|
||||||
|
<module name="Indentation"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_blocks.html#LeftCurly -->
|
||||||
|
<module name="LeftCurly"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_naming.html#MethodName -->
|
||||||
|
<module name="MethodName">
|
||||||
|
<property name="format" value="^[_]?[a-z][a-zA-Z0-9]*$"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_whitespace.html#MethodParamPad -->
|
||||||
|
<module name="MethodParamPad"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_javadoc.html#MissingJavadocMethod -->
|
||||||
|
<module name="MissingJavadocMethod">
|
||||||
|
<property name="allowMissingPropertyJavadoc" value="true"/>
|
||||||
|
<property name="tokens" value="METHOD_DEF, ANNOTATION_FIELD_DEF"/> <!-- remove CTOR_DEF, COMPACT_CTOR_DEF -->
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_javadoc.html#MissingJavadocType -->
|
||||||
|
<module name="MissingJavadocType"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_coding.html#NoFinalizer -->
|
||||||
|
<module name="NoFinalizer"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_whitespace.html#NoLineWrap -->
|
||||||
|
<module name="NoLineWrap"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_whitespace.html#NoWhitespaceAfter -->
|
||||||
|
<module name="NoWhitespaceAfter">
|
||||||
|
<property name="allowLineBreaks" value="false"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_whitespace.html#NoWhitespaceBefore -->
|
||||||
|
<module name="NoWhitespaceBefore">
|
||||||
|
<property name="allowLineBreaks" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_coding.html#OneStatementPerLine -->
|
||||||
|
<module name="OneStatementPerLine"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_misc.html#OuterTypeFilename -->
|
||||||
|
<module name="OuterTypeFilename"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_imports.html#RedundantImport -->
|
||||||
|
<module name="RedundantImport"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_modifier.html#RedundantModifier -->
|
||||||
|
<module name="RedundantModifier">
|
||||||
|
<property name="tokens"
|
||||||
|
value="ANNOTATION_FIELD_DEF, CLASS_DEF, CTOR_DEF, ENUM_DEF, INTERFACE_DEF, VARIABLE_DEF"/> <!-- remove METHOD_DEF and RESOURCE -->
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_coding.html#RequireThis -->
|
||||||
|
<module name="RequireThis"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_blocks.html#RightCurly -->
|
||||||
|
<module name="RightCurly">
|
||||||
|
<property name="id" value="RightCurlyAlone"/>
|
||||||
|
<property name="option" value="alone"/>
|
||||||
|
<property name="tokens"
|
||||||
|
value="ANNOTATION_DEF, CLASS_DEF, CTOR_DEF, ENUM_DEF, INSTANCE_INIT, LITERAL_FOR, LITERAL_WHILE, METHOD_DEF, STATIC_INIT"/>
|
||||||
|
</module>
|
||||||
|
<module name="RightCurly">
|
||||||
|
<property name="id" value="RightCurlySame"/>
|
||||||
|
<property name="option" value="same"/>
|
||||||
|
<property name="tokens"
|
||||||
|
value="LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF, LITERAL_TRY"/> <!-- add LITERAL_DO -->
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_whitespace.html#SingleSpaceSeparator -->
|
||||||
|
<module name="SingleSpaceSeparator">
|
||||||
|
<property name="validateComments" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_whitespace.html#TypecastParenPad -->
|
||||||
|
<module name="TypecastParenPad"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_coding.html#UnnecessaryParentheses -->
|
||||||
|
<module name="UnnecessaryParentheses"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_imports.html#UnusedImports -->
|
||||||
|
<module name="UnusedImports"/>
|
||||||
|
|
||||||
|
</module>
|
||||||
|
</module>
|
6
.checkstyle/suppressions.xml
Normal file
6
.checkstyle/suppressions.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" "http://checkstyle.org/dtds/suppressions_1_2.dtd">
|
||||||
|
<suppressions>
|
||||||
|
<suppress files=".*[\\/]test[\\/]java[\\/].*" checks="RequireExplicitVisibilityModifier"/>
|
||||||
|
<suppress files="(com[\\/]earth2me[\\/]essentials[\\/]|net[\\/]ess3[\\/])(?:[^\\/]+$|(?!api)[^\\/]+[\\/])" checks="MissingJavadoc(Method|Type)"/>
|
||||||
|
</suppressions>
|
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -29,7 +29,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
java-version: 1.8
|
java-version: 1.8
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
run: mvn package --file pom.xml
|
run: mvn package verify --file pom.xml
|
||||||
- name: Copy artifacts
|
- name: Copy artifacts
|
||||||
run: mkdir -p ./out/ && cp -t ./out/ **/target/Essentials*.jar
|
run: mkdir -p ./out/ && cp -t ./out/ **/target/Essentials*.jar
|
||||||
- uses: actions/upload-artifact@master
|
- uses: actions/upload-artifact@master
|
||||||
|
9
.gitignore
vendored
9
.gitignore
vendored
@ -1,11 +1,14 @@
|
|||||||
# IDE files
|
# Other IDE files
|
||||||
*.classpath
|
*.classpath
|
||||||
*.project
|
*.project
|
||||||
*.settings/
|
*.settings/
|
||||||
.idea/
|
.idea/*
|
||||||
*.iml
|
*.iml
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# Checkstyle-IDEA config
|
||||||
|
!.idea/checkstyle-idea.xml
|
||||||
|
|
||||||
# Essentials files
|
# Essentials files
|
||||||
/Essentials/userdata
|
/Essentials/userdata
|
||||||
/Essentials/config.yml
|
/Essentials/config.yml
|
||||||
@ -16,4 +19,4 @@
|
|||||||
# Build files
|
# Build files
|
||||||
target/
|
target/
|
||||||
jars/
|
jars/
|
||||||
out/
|
out/
|
||||||
|
19
.idea/checkstyle-idea.xml
Normal file
19
.idea/checkstyle-idea.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CheckStyle-IDEA">
|
||||||
|
<option name="configuration">
|
||||||
|
<map>
|
||||||
|
<entry key="active-configuration" value="PROJECT_RELATIVE:$PROJECT_DIR$/.checkstyle/checkstyle.xml:EssentialsX" />
|
||||||
|
<entry key="checkstyle-version" value="8.36.2" />
|
||||||
|
<entry key="copy-libs" value="true" />
|
||||||
|
<entry key="location-0" value="BUNDLED:(bundled):Sun Checks" />
|
||||||
|
<entry key="location-1" value="BUNDLED:(bundled):Google Checks" />
|
||||||
|
<entry key="location-2" value="PROJECT_RELATIVE:$PROJECT_DIR$/.checkstyle/checkstyle.xml:EssentialsX" />
|
||||||
|
<entry key="property-2.checkstyle.suppressions.file" value=".checkstyle/suppressions.xml" />
|
||||||
|
<entry key="scan-before-checkin" value="false" />
|
||||||
|
<entry key="scanscope" value="JavaOnly" />
|
||||||
|
<entry key="suppress-errors" value="false" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
27
pom.xml
27
pom.xml
@ -35,10 +35,10 @@
|
|||||||
<id>paper-repo</id>
|
<id>paper-repo</id>
|
||||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>jitpack</id>
|
<id>jitpack</id>
|
||||||
<url>https://jitpack.io</url>
|
<url>https://jitpack.io</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
@ -188,6 +188,7 @@
|
|||||||
<value>${full.version}</value>
|
<value>${full.version}</value>
|
||||||
</replacement>
|
</replacement>
|
||||||
<replacement>
|
<replacement>
|
||||||
|
<!--suppress UnresolvedMavenProperty -->
|
||||||
<token>$${build.number}</token>
|
<token>$${build.number}</token>
|
||||||
<value>${full.version}</value>
|
<value>${full.version}</value>
|
||||||
</replacement>
|
</replacement>
|
||||||
@ -251,7 +252,24 @@
|
|||||||
</gitDescribe>
|
</gitDescribe>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.1.1</version>
|
||||||
|
<configuration>
|
||||||
|
<configLocation>.checkstyle/checkstyle.xml</configLocation>
|
||||||
|
<suppressionsLocation>.checkstyle/suppressions.xml</suppressionsLocation>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src</directory>
|
<directory>src</directory>
|
||||||
@ -274,6 +292,7 @@
|
|||||||
<release.version>2.18.1</release.version>
|
<release.version>2.18.1</release.version>
|
||||||
|
|
||||||
<!-- The plugins' build number -->
|
<!-- The plugins' build number -->
|
||||||
|
<!--suppress UnresolvedMavenProperty -->
|
||||||
<build.version>${git.closest.tag.commit.count}</build.version>
|
<build.version>${git.closest.tag.commit.count}</build.version>
|
||||||
|
|
||||||
<full.version>${release.version}.${build.version}</full.version>
|
<full.version>${release.version}.${build.version}</full.version>
|
||||||
|
Loading…
Reference in New Issue
Block a user