Updated PMD rules.
This commit is contained in:
parent
94e42972e0
commit
cae74c95b3
6 changed files with 91 additions and 239 deletions
|
@ -1,6 +1,6 @@
|
||||||
# Semantic Version Annotation Processor
|
# Semantic Version Annotation Processor
|
||||||
|
|
||||||
[](http://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/semver/releases/latest) [](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/semver)\
|
[](http://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/semver/releases/latest) [](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/semver)
|
||||||
[](https://snyk.io/test/github/ethauvin/semver?targetFile=build.gradle) [](https://sonarcloud.io/dashboard?id=ethauvin_semver) [](https://github.com/ethauvin/semver/actions/workflows/gradle.yml) [](https://ci.appveyor.com/project/ethauvin/semver) [](https://circleci.com/gh/ethauvin/semver/tree/master)
|
[](https://snyk.io/test/github/ethauvin/semver?targetFile=build.gradle) [](https://sonarcloud.io/dashboard?id=ethauvin_semver) [](https://github.com/ethauvin/semver/actions/workflows/gradle.yml) [](https://ci.appveyor.com/project/ethauvin/semver) [](https://circleci.com/gh/ethauvin/semver/tree/master)
|
||||||
|
|
||||||
An [annotation processor](https://docs.oracle.com/javase/8/docs/api/javax/annotation/processing/Processor.html) that automatically generates a `GeneratedVersion` class based on a [Mustache](https://mustache.github.io/) template and containing the [semantic version](http://semver.org/) (major, minor, patch, etc.) that is read from a [Properties](https://docs.oracle.com/javase/tutorial/essential/environment/properties.html) file or defined in the [annotation](https://docs.oracle.com/javase/tutorial/java/annotations/basics.html).
|
An [annotation processor](https://docs.oracle.com/javase/8/docs/api/javax/annotation/processing/Processor.html) that automatically generates a `GeneratedVersion` class based on a [Mustache](https://mustache.github.io/) template and containing the [semantic version](http://semver.org/) (major, minor, patch, etc.) that is read from a [Properties](https://docs.oracle.com/javase/tutorial/essential/environment/properties.html) file or defined in the [annotation](https://docs.oracle.com/javase/tutorial/java/annotations/basics.html).
|
||||||
|
|
26
build.gradle
26
build.gradle
|
@ -5,7 +5,7 @@ plugins {
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'pmd'
|
id 'pmd'
|
||||||
id 'signing'
|
id 'signing'
|
||||||
id 'com.github.ben-manes.versions' version '0.38.0'
|
id 'com.github.ben-manes.versions' version '0.39.0'
|
||||||
id 'net.thauvin.erik.gradle.semver' version '1.0.4'
|
id 'net.thauvin.erik.gradle.semver' version '1.0.4'
|
||||||
id 'com.github.spotbugs' version '4.7.1'
|
id 'com.github.spotbugs' version '4.7.1'
|
||||||
id 'org.sonarqube' version '3.2.0'
|
id 'org.sonarqube' version '3.2.0'
|
||||||
|
@ -27,6 +27,7 @@ final def mavenScmCon = 'https://github.com/ethauvin/semver.git'
|
||||||
final def mavenScmDevCon = 'git@github.com:ethauvin/semver.git'
|
final def mavenScmDevCon = 'git@github.com:ethauvin/semver.git'
|
||||||
|
|
||||||
ext.versions = [
|
ext.versions = [
|
||||||
|
pmd: '6.35.0',
|
||||||
spotbugs: '4.2.3'
|
spotbugs: '4.2.3'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.spullara.mustache.java:compiler:0.9.7'
|
implementation 'com.github.spullara.mustache.java:compiler:0.9.10'
|
||||||
|
|
||||||
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0'
|
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0'
|
||||||
spotbugsPlugins 'com.mebigfatguy.sb-contrib:sb-contrib:7.4.7'
|
spotbugsPlugins 'com.mebigfatguy.sb-contrib:sb-contrib:7.4.7'
|
||||||
|
@ -60,6 +61,7 @@ java {
|
||||||
}
|
}
|
||||||
|
|
||||||
pmd {
|
pmd {
|
||||||
|
toolVersion = versions.pmd
|
||||||
ignoreFailures = true
|
ignoreFailures = true
|
||||||
ruleSets = []
|
ruleSets = []
|
||||||
ruleSetFiles = files("${projectDir}/config/pmd.xml")
|
ruleSetFiles = files("${projectDir}/config/pmd.xml")
|
||||||
|
@ -69,9 +71,9 @@ pmd {
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
mavenJava(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
from components.java
|
from(components.java)
|
||||||
groupId project.group
|
groupId = project.group
|
||||||
artifactId rootProject.name
|
artifactId = rootProject.name
|
||||||
|
|
||||||
pom {
|
pom {
|
||||||
name = mavenName
|
name = mavenName
|
||||||
|
@ -133,8 +135,8 @@ javadoc {
|
||||||
|
|
||||||
test {
|
test {
|
||||||
testLogging {
|
testLogging {
|
||||||
exceptionFormat "full"
|
exceptionFormat = "full"
|
||||||
events "passed", "skipped", "failed"
|
events("passed", "skipped", "failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
useTestNG()
|
useTestNG()
|
||||||
|
@ -179,8 +181,8 @@ task pandoc(type: Exec) {
|
||||||
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||||
commandLine(['cmd', '/c', 'pandoc'] + pandoc_args)
|
commandLine(['cmd', '/c', 'pandoc'] + pandoc_args)
|
||||||
} else {
|
} else {
|
||||||
executable 'pandoc'
|
executable = 'pandoc'
|
||||||
args pandoc_args
|
args(pandoc_args)
|
||||||
}
|
}
|
||||||
standardOutput = new ByteArrayOutputStream()
|
standardOutput = new ByteArrayOutputStream()
|
||||||
ext.output = {
|
ext.output = {
|
||||||
|
@ -198,9 +200,9 @@ jacocoTestReport {
|
||||||
|
|
||||||
sonarqube {
|
sonarqube {
|
||||||
properties {
|
properties {
|
||||||
property "sonar.organization", "ethauvin-github"
|
property("sonar.organization", "ethauvin-github")
|
||||||
property "sonar.projectKey", "ethauvin_semver"
|
property("sonar.projectKey", "ethauvin_semver")
|
||||||
property "sonar.host.url", "https://sonarcloud.io"
|
property("sonar.host.url", "https://sonarcloud.io")
|
||||||
property("sonar.sourceEncoding", "UTF-8")
|
property("sonar.sourceEncoding", "UTF-8")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
279
config/pmd.xml
279
config/pmd.xml
|
@ -5,109 +5,78 @@
|
||||||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
||||||
<description>Erik's Ruleset</description>
|
<description>Erik's Ruleset</description>
|
||||||
<!-- BEST PRACTICES -->
|
<!-- BEST PRACTICES -->
|
||||||
<!-- <rule ref="category/java/bestpractices.xml/AvoidStringBufferField"/>-->
|
<rule ref="category/java/bestpractices.xml">
|
||||||
<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/>
|
<exclude name="AvoidPrintStackTrace"/>
|
||||||
<rule ref="category/java/bestpractices.xml/CheckResultSet"/>
|
<exclude name="JUnit4TestShouldUseTestAnnotation"/>
|
||||||
<rule ref="category/java/bestpractices.xml/ConstantsInInterface"/>
|
<exclude name="JUnitTestContainsTooManyAsserts"/>
|
||||||
<rule ref="category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt"/>
|
</rule>
|
||||||
<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/GuardLogStatement"/>
|
|
||||||
<!-- <rule ref="category/java/bestpractices.xml/LooseCoupling"/> -->
|
|
||||||
<rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/MissingOverride">
|
<rule ref="category/java/bestpractices.xml/MissingOverride">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="violationSuppressXPath"
|
<property name="violationSuppressXPath"
|
||||||
value="./MethodDeclarator[@Image='hashCode' or @Image='equals' or @Image='toString']"/>
|
value="//MethodDeclaration[@Name='hashCode' or @Name='equals' or @Name='toString']"/>
|
||||||
</properties>
|
</properties>
|
||||||
</rule>
|
</rule>
|
||||||
<rule ref="category/java/bestpractices.xml/PreserveStackTrace"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/ReplaceEnumerationWithIterator"/>
|
|
||||||
<!-- <rule ref="category/java/bestpractices.xml/ReplaceHashtableWithMap"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/ReplaceVectorWithList"/> -->
|
|
||||||
<rule ref="category/java/bestpractices.xml/SwitchStmtsShouldHaveDefault"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/SystemPrintln"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/UnusedFormalParameter"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/UnusedImports"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/UseAssertEqualsInsteadOfAssertTrue"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/UseAssertNullInsteadOfAssertTrue"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/UseAssertSameInsteadOfAssertTrue"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/UseAssertTrueInsteadOfAssertEquals"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty"/>
|
|
||||||
<rule ref="category/java/bestpractices.xml/UseVarargs"/>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- NAMING CONVENTIONS -->
|
<!-- CODE STYLE -->
|
||||||
<rule ref="category/java/codestyle.xml/FormalParameterNamingConventions"/>
|
<rule ref="category/java/codestyle.xml">
|
||||||
<rule ref="category/java/codestyle.xml/GenericsNaming"/>
|
<exclude name="AtLeastOneConstructor"/>
|
||||||
<rule ref="category/java/codestyle.xml/LocalVariableNamingConventions"/>
|
<exclude name="ClassNamingConventions"/>
|
||||||
<rule ref="category/java/codestyle.xml/MethodNamingConventions"/>
|
<exclude name="ConfusingTernary"/>
|
||||||
<!-- <rule ref="category/java/codestyle.xml/PackageCase"/>-->
|
<exclude name="CommentDefaultAccessModifier"/>
|
||||||
|
<exclude name="DefaultPackage"/>
|
||||||
|
<exclude name="FieldNamingConventions"/>
|
||||||
<!-- OTHER -->
|
<exclude name="LongVariable"/>
|
||||||
<rule ref="category/java/codestyle.xml/AvoidDollarSigns"/>
|
<exclude name="OnlyOneReturn"/>
|
||||||
<rule ref="category/java/codestyle.xml/AvoidProtectedFieldInFinalClass"/>
|
<exclude name="PackageCase"/>
|
||||||
<rule ref="category/java/codestyle.xml/AvoidProtectedMethodInFinalClassNotExtending"/>
|
<exclude name="ShortClassName"/>
|
||||||
<rule ref="category/java/codestyle.xml/AvoidUsingNativeCode"/>
|
<exclude name="ShortMethodName"/>
|
||||||
<rule ref="category/java/codestyle.xml/BooleanGetMethodName"/>
|
<exclude name="ShortVariable"/>
|
||||||
<rule ref="category/java/codestyle.xml/CallSuperInConstructor"/>
|
<exclude name="UselessParentheses"/>
|
||||||
<rule ref="category/java/codestyle.xml/ControlStatementBraces"/>
|
<exclude name="UseUnderscoresInNumericLiterals"/>
|
||||||
<rule ref="category/java/codestyle.xml/DontImportJavaLang"/>
|
</rule>
|
||||||
<rule ref="category/java/codestyle.xml/DuplicateImports"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/EmptyMethodInAbstractClassShouldBeAbstract"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/ExtendsObject"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/FieldDeclarationsShouldBeAtStartOfClass"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/LocalVariableCouldBeFinal"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/MethodArgumentCouldBeFinal"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/NoPackage"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/PrematureDeclaration"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/TooManyStaticImports"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/UnnecessaryAnnotationValueElement"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/UnnecessaryLocalBeforeReturn"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/UnnecessaryReturn"/>
|
|
||||||
<rule ref="category/java/codestyle.xml/UselessQualifiedThis"/>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- DESIGN -->
|
<!-- DESIGN -->
|
||||||
<rule ref="category/java/design.xml/AbstractClassWithoutAnyMethod"/>
|
<rule ref="category/java/design.xml">
|
||||||
<rule ref="category/java/design.xml/AvoidRethrowingException"/>
|
<exclude name="AvoidCatchingGenericException"/>
|
||||||
<rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException"/>
|
<exclude name="AvoidDeeplyNestedIfStmts"/>
|
||||||
<rule ref="category/java/design.xml/AvoidThrowingNullPointerException"/>
|
<exclude name="AvoidUncheckedExceptionsInSignatures"/>
|
||||||
<rule ref="category/java/design.xml/AvoidThrowingRawExceptionTypes"/>
|
<exclude name="CognitiveComplexity"/>
|
||||||
<rule ref="category/java/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal"/>
|
<exclude name="CyclomaticComplexity"/>
|
||||||
<rule ref="category/java/design.xml/CollapsibleIfStatements"/>
|
<exclude name="ExcessiveClassLength"/>
|
||||||
<rule ref="category/java/design.xml/CouplingBetweenObjects"/>
|
<exclude name="ExcessiveMethodLength"/>
|
||||||
<rule ref="category/java/design.xml/DataClass"/>
|
<exclude name="ExcessiveParameterList"/>
|
||||||
<rule ref="category/java/design.xml/DoNotExtendJavaLangError"/>
|
<exclude name="ExcessivePublicCount"/>
|
||||||
<rule ref="category/java/design.xml/ExceptionAsFlowControl"/>
|
<exclude name="GodClass"/>
|
||||||
<!-- <rule ref="category/java/design.xml/ExcessivePublicCount"/>-->
|
<exclude name="LawOfDemeter"/>
|
||||||
<rule ref="category/java/design.xml/FinalFieldCouldBeStatic"/>
|
<exclude name="LoosePackageCoupling"/>
|
||||||
<rule ref="category/java/design.xml/ImmutableField"/>
|
<exclude name="NPathComplexity"/>
|
||||||
<rule ref="category/java/design.xml/LogicInversion"/>
|
<exclude name="NcssCount"/>
|
||||||
<rule ref="category/java/design.xml/SignatureDeclareThrowsException"/>
|
<exclude name="TooManyFields"/>
|
||||||
<rule ref="category/java/design.xml/SimplifiedTernary"/>
|
<exclude name="TooManyMethods"/>
|
||||||
<rule ref="category/java/design.xml/SimplifyBooleanAssertion"/>
|
<exclude name="UseObjectForClearerAPI"/>
|
||||||
<rule ref="category/java/design.xml/SimplifyBooleanExpressions"/>
|
</rule>
|
||||||
<rule ref="category/java/design.xml/SimplifyBooleanReturns"/>
|
|
||||||
<rule ref="category/java/design.xml/SimplifyConditional"/>
|
|
||||||
<rule ref="category/java/design.xml/SingularField"/>
|
|
||||||
<rule ref="category/java/design.xml/SwitchDensity"/>
|
|
||||||
<rule ref="category/java/design.xml/UselessOverridingMethod"/>
|
|
||||||
<rule ref="category/java/design.xml/UseUtilityClass"/>
|
|
||||||
|
|
||||||
<!-- DOCUMENTATION -->
|
<!-- DOCUMENTATION -->
|
||||||
<rule ref="category/java/documentation.xml/UncommentedEmptyConstructor"/>
|
<rule ref="category/java/documentation.xml">
|
||||||
<rule ref="category/java/documentation.xml/UncommentedEmptyMethodBody"/>
|
<exclude name="CommentRequired"/>
|
||||||
|
<exclude name="CommentSize"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
<!-- ERROR PRONE -->
|
<!-- ERROR PRONE -->
|
||||||
|
<rule ref="category/java/errorprone.xml">
|
||||||
|
<exclude name="AssignmentInOperand"/>
|
||||||
|
<exclude name="AvoidCatchingNPE"/>
|
||||||
|
<exclude name="AvoidDuplicateLiterals"/>
|
||||||
|
<exclude name="AvoidFieldNameMatchingMethodName"/>
|
||||||
|
<exclude name="AvoidFieldNameMatchingTypeName"/>
|
||||||
|
<exclude name="AvoidLiteralsInIfCondition"/>
|
||||||
|
<exclude name="BeanMembersShouldSerialize"/>
|
||||||
|
<exclude name="EmptyCatchBlock"/>
|
||||||
|
<exclude name="NullAssignment"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
<rule ref="category/java/errorprone.xml/AssignmentInOperand">
|
<rule ref="category/java/errorprone.xml/AssignmentInOperand">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="allowWhile" value="true"/>
|
<property name="allowWhile" value="true"/>
|
||||||
|
@ -115,86 +84,11 @@
|
||||||
<property name="allowIf" value="true"/>
|
<property name="allowIf" value="true"/>
|
||||||
</properties>
|
</properties>
|
||||||
</rule>
|
</rule>
|
||||||
<rule ref="category/java/errorprone.xml/AssignmentToNonFinalStatic"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/AvoidAccessibilityAlteration"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/AvoidAssertAsIdentifier"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/AvoidCallingFinalize"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/AvoidCatchingThrowable"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/AvoidDuplicateLiterals">
|
<rule ref="category/java/errorprone.xml/AvoidDuplicateLiterals">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="skipAnnotations" value="true"/>
|
<property name="skipAnnotations" value="true"/>
|
||||||
</properties>
|
</properties>
|
||||||
</rule>
|
</rule>
|
||||||
<rule ref="category/java/errorprone.xml/AvoidEnumAsIdentifier"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/AvoidInstanceofChecksInCatchClause"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/AvoidLosingExceptionInformation"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/BadComparison"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/BrokenNullCheck"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/CallSuperFirst"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/CallSuperLast"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/CheckSkipResult"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/CloneMethodMustBePublic"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/CloneMethodMustImplementCloneable"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/CloneMethodReturnTypeMustMatchClassName"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/CloneThrowsCloneNotSupportedException"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/CloseResource"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/CompareObjectsWithEquals"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/ConstructorCallsOverridableMethod"/>>
|
|
||||||
<rule ref="category/java/errorprone.xml/DoNotCallGarbageCollectionExplicitly"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/DoNotExtendJavaLangThrowable"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/DoNotHardCodeSDCard"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/DoNotThrowExceptionInFinally"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/DontImportSun"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/EqualsNull"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/FinalizeDoesNotCallSuperFinalize"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/FinalizeOnlyCallsSuperFinalize"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/FinalizeOverloaded"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/FinalizeShouldBeProtected"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/IdempotentOperations"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/ImportFromSamePackage"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/InstantiationToGetClass"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/InvalidLogMessageFormat"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/JumbledIncrementer"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/JUnitSpelling"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/JUnitStaticSuite"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/MethodWithSameNameAsEnclosingClass"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/MissingBreakInSwitch"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/MissingSerialVersionUID"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/MissingStaticMethodInNonInstantiatableClass"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/MoreThanOneLogger"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/NonCaseLabelInSwitchStatement"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/NonStaticInitializer"/>
|
|
||||||
<!-- <rule ref="category/java/errorprone.xml/NullAssignment"/>-->
|
|
||||||
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/ProperCloneImplementation"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/ProperLogger"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/ReturnEmptyArrayRatherThanNull"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/SimpleDateFormatNeedsLocale"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/SingleMethodSingleton"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/SingletonClassReturningNewInstance"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/StaticEJBFieldShouldBeFinal"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/StringBufferInstantiationWithChar"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/SuspiciousEqualsMethodName"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/SuspiciousHashcodeMethodName"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/SuspiciousOctalEscape"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/TestClassWithoutTestCases"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/UnnecessaryBooleanAssertion"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/UnnecessaryCaseChange"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/UseCorrectExceptionLogging"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/UseEqualsToCompareStrings"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/UselessOperationOnImmutable"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/UseLocaleWithCaseConversions"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/EmptyCatchBlock">
|
<rule ref="category/java/errorprone.xml/EmptyCatchBlock">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="allowExceptionNameRegex">
|
<property name="allowExceptionNameRegex">
|
||||||
|
@ -202,59 +96,16 @@
|
||||||
</property>
|
</property>
|
||||||
</properties>
|
</properties>
|
||||||
</rule>
|
</rule>
|
||||||
<rule ref="category/java/errorprone.xml/EmptyFinalizer"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/EmptyFinallyBlock"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/EmptyIfStmt"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/EmptyInitializer"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/EmptyStatementBlock"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/EmptyStatementNotInLoop"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/EmptySwitchStatements"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/EmptySynchronizedBlock"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/EmptyTryBlock"/>
|
|
||||||
<rule ref="category/java/errorprone.xml/EmptyWhileStmt"/>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- MULTITHREADING -->
|
<!-- MULTITHREADING -->
|
||||||
<rule ref="category/java/multithreading.xml/AvoidSynchronizedAtMethodLevel"/>
|
<rule ref="category/java/multithreading.xml">
|
||||||
<rule ref="category/java/multithreading.xml/AvoidThreadGroup"/>
|
</rule>
|
||||||
<rule ref="category/java/multithreading.xml/AvoidUsingVolatile"/>
|
|
||||||
<rule ref="category/java/multithreading.xml/DontCallThreadRun"/>
|
|
||||||
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking"/>
|
|
||||||
<rule ref="category/java/multithreading.xml/NonThreadSafeSingleton"/>
|
|
||||||
<rule ref="category/java/multithreading.xml/UseConcurrentHashMap"/>
|
|
||||||
<rule ref="category/java/multithreading.xml/UseNotifyAllInsteadOfNotify"/>
|
|
||||||
|
|
||||||
<!-- PERFORMANCE -->
|
<!-- PERFORMANCE -->
|
||||||
<rule ref="category/java/performance.xml/AddEmptyString"/>
|
<rule ref="category/java/performance.xml">
|
||||||
<rule ref="category/java/performance.xml/AppendCharacterWithChar"/>
|
</rule>
|
||||||
<rule ref="category/java/performance.xml/AvoidArrayLoops"/>
|
|
||||||
<rule ref="category/java/performance.xml/AvoidFileStream"/>
|
|
||||||
<rule ref="category/java/performance.xml/AvoidInstantiatingObjectsInLoops"/>
|
|
||||||
<rule ref="category/java/performance.xml/BigIntegerInstantiation"/>
|
|
||||||
<rule ref="category/java/performance.xml/BooleanInstantiation"/>
|
|
||||||
<rule ref="category/java/performance.xml/ByteInstantiation"/>
|
|
||||||
<rule ref="category/java/performance.xml/ConsecutiveAppendsShouldReuse"/>
|
|
||||||
<rule ref="category/java/performance.xml/ConsecutiveLiteralAppends"/>
|
|
||||||
<rule ref="category/java/performance.xml/InefficientEmptyStringCheck"/>
|
|
||||||
<rule ref="category/java/performance.xml/InefficientStringBuffering"/>
|
|
||||||
<rule ref="category/java/performance.xml/InsufficientStringBufferDeclaration"/>
|
|
||||||
<rule ref="category/java/performance.xml/IntegerInstantiation"/>
|
|
||||||
<rule ref="category/java/performance.xml/LongInstantiation"/>
|
|
||||||
<rule ref="category/java/performance.xml/OptimizableToArrayCall"/>
|
|
||||||
<rule ref="category/java/performance.xml/RedundantFieldInitializer"/>
|
|
||||||
<rule ref="category/java/performance.xml/ShortInstantiation"/>
|
|
||||||
<rule ref="category/java/performance.xml/StringInstantiation"/>
|
|
||||||
<rule ref="category/java/performance.xml/StringToString"/>
|
|
||||||
<rule ref="category/java/performance.xml/TooFewBranchesForASwitchStatement"/>
|
|
||||||
<rule ref="category/java/performance.xml/UnnecessaryWrapperObjectCreation"/>
|
|
||||||
<!-- <rule ref="category/java/performance.xml/UseArrayListInsteadOfVector"/> -->
|
|
||||||
<rule ref="category/java/performance.xml/UseArraysAsList"/>
|
|
||||||
<rule ref="category/java/performance.xml/UseIndexOfChar"/>
|
|
||||||
<rule ref="category/java/performance.xml/UselessStringValueOf"/>
|
|
||||||
<rule ref="category/java/performance.xml/UseStringBufferForStringAppends"/>
|
|
||||||
<rule ref="category/java/performance.xml/UseStringBufferLength"/>
|
|
||||||
|
|
||||||
<!-- SECURITY -->
|
<!-- SECURITY -->
|
||||||
<rule ref="category/java/security.xml/HardCodedCryptoKey"/>
|
<rule ref="category/java/security.xml">
|
||||||
<rule ref="category/java/security.xml/InsecureCryptoIv"/>
|
</rule>
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm").version("1.5.0")
|
id("application")
|
||||||
application
|
id("com.github.ben-manes.versions") version "0.39.0"
|
||||||
id("org.jetbrains.kotlin.kapt").version("1.5.0")
|
kotlin("jvm") version "1.5.10"
|
||||||
id("com.github.ben-manes.versions").version("0.38.0")
|
kotlin("kapt") version "1.5.10"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ./gradlew
|
// ./gradlew
|
||||||
|
|
|
@ -70,7 +70,7 @@ import java.util.Set;
|
||||||
* @created 2016-01-13
|
* @created 2016-01-13
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("PMD.GuardLogStatement")
|
@SuppressWarnings({ "PMD.GuardLogStatement", "PMD.BeanMembersShouldSerialize"})
|
||||||
@SupportedOptions({Constants.KAPT_KOTLIN_GENERATED_OPTION_NAME, Constants.SEMVER_PROJECT_DIR_ARG})
|
@SupportedOptions({Constants.KAPT_KOTLIN_GENERATED_OPTION_NAME, Constants.SEMVER_PROJECT_DIR_ARG})
|
||||||
public class VersionProcessor extends AbstractProcessor {
|
public class VersionProcessor extends AbstractProcessor {
|
||||||
private Filer filer;
|
private Filer filer;
|
||||||
|
@ -82,7 +82,7 @@ public class VersionProcessor extends AbstractProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void error(final String s, final Throwable t) {
|
private void error(final String s, final Throwable t) {
|
||||||
log(Diagnostic.Kind.ERROR, (t != null ? t.toString() : s));
|
log(Diagnostic.Kind.ERROR, t != null ? t.toString() : s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressFBWarnings({"PATH_TRAVERSAL_IN", "UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH"})
|
@SuppressFBWarnings({"PATH_TRAVERSAL_IN", "UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH"})
|
||||||
|
@ -96,7 +96,7 @@ public class VersionProcessor extends AbstractProcessor {
|
||||||
|
|
||||||
final Properties p = new Properties();
|
final Properties p = new Properties();
|
||||||
|
|
||||||
try (final InputStreamReader reader = new InputStreamReader(
|
try (InputStreamReader reader = new InputStreamReader(
|
||||||
Files.newInputStream(propsFile.toPath()), StandardCharsets.UTF_8)) {
|
Files.newInputStream(propsFile.toPath()), StandardCharsets.UTF_8)) {
|
||||||
p.load(reader);
|
p.load(reader);
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ public class VersionProcessor extends AbstractProcessor {
|
||||||
if (!ktFile.getParentFile().exists() && !ktFile.getParentFile().mkdirs()) {
|
if (!ktFile.getParentFile().exists() && !ktFile.getParentFile().mkdirs()) {
|
||||||
note("Could not create target directory: " + ktFile.getParentFile().getAbsolutePath());
|
note("Could not create target directory: " + ktFile.getParentFile().getAbsolutePath());
|
||||||
}
|
}
|
||||||
try (final OutputStreamWriter osw = new OutputStreamWriter(Files.newOutputStream(ktFile.toPath()),
|
try (OutputStreamWriter osw = new OutputStreamWriter(Files.newOutputStream(ktFile.toPath()),
|
||||||
StandardCharsets.UTF_8)) {
|
StandardCharsets.UTF_8)) {
|
||||||
mustache.execute(osw, versionInfo).flush();
|
mustache.execute(osw, versionInfo).flush();
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ public class VersionProcessor extends AbstractProcessor {
|
||||||
} else {
|
} else {
|
||||||
final FileObject jfo = filer.createSourceFile(
|
final FileObject jfo = filer.createSourceFile(
|
||||||
versionInfo.getPackageName() + '.' + versionInfo.getClassName());
|
versionInfo.getPackageName() + '.' + versionInfo.getClassName());
|
||||||
try (final Writer writer = jfo.openWriter()) {
|
try (Writer writer = jfo.openWriter()) {
|
||||||
mustache.execute(writer, versionInfo).flush();
|
mustache.execute(writer, versionInfo).flush();
|
||||||
}
|
}
|
||||||
note("Generated source: " + fileName + " (" + new File(jfo.getName()).getAbsoluteFile().getParent() + ')');
|
note("Generated source: " + fileName + " (" + new File(jfo.getName()).getAbsoluteFile().getParent() + ')');
|
||||||
|
|
|
@ -36,7 +36,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Date;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ import static org.testng.Assert.assertEquals;
|
||||||
*/
|
*/
|
||||||
@SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS")
|
@SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS")
|
||||||
public class VersionInfoTest {
|
public class VersionInfoTest {
|
||||||
private final Calendar now = Calendar.getInstance();
|
|
||||||
private VersionInfo versionInfo = new VersionInfo();
|
private VersionInfo versionInfo = new VersionInfo();
|
||||||
|
|
||||||
@SuppressWarnings("PMD.AvoidUsingHardCodedIP")
|
@SuppressWarnings("PMD.AvoidUsingHardCodedIP")
|
||||||
|
@ -159,7 +158,7 @@ public class VersionInfoTest {
|
||||||
|
|
||||||
assertEquals(versionInfo.getClassName(), "Example", "getClassName(Example");
|
assertEquals(versionInfo.getClassName(), "Example", "getClassName(Example");
|
||||||
|
|
||||||
Assert.assertTrue((versionInfo.getEpoch() - now.getTimeInMillis()) < 1000, "buildDate - now < 1s");
|
Assert.assertTrue((versionInfo.getEpoch() - new Date().getTime()) < 1000, "buildDate - now < 1s");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue