Minor cleanup
This commit is contained in:
parent
f837b26903
commit
c7578a870f
6 changed files with 135 additions and 14 deletions
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
110
config/pmd.xml
Normal file
110
config/pmd.xml
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="erik"
|
||||||
|
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
||||||
|
<description>Erik's Ruleset</description>
|
||||||
|
<!-- BEST PRACTICES -->
|
||||||
|
<rule ref="category/java/bestpractices.xml">
|
||||||
|
<exclude name="AvoidPrintStackTrace"/>
|
||||||
|
<exclude name="JUnit4TestShouldUseTestAnnotation"/>
|
||||||
|
<exclude name="JUnitTestContainsTooManyAsserts"/>
|
||||||
|
<exclude name="GuardLogStatement"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule ref="category/java/bestpractices.xml/MissingOverride">
|
||||||
|
<properties>
|
||||||
|
<property name="violationSuppressXPath"
|
||||||
|
value="//MethodDeclaration[@Name='hashCode' or @Name='equals' or @Name='toString']"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- CODE STYLE -->
|
||||||
|
<rule ref="category/java/codestyle.xml">
|
||||||
|
<exclude name="AtLeastOneConstructor"/>
|
||||||
|
<exclude name="ClassNamingConventions"/>
|
||||||
|
<exclude name="ConfusingTernary"/>
|
||||||
|
<exclude name="CommentDefaultAccessModifier"/>
|
||||||
|
<exclude name="FieldNamingConventions"/>
|
||||||
|
<exclude name="LocalVariableCouldBeFinal"/>
|
||||||
|
<exclude name="LocalVariableNamingConventions"/>
|
||||||
|
<exclude name="LongVariable"/>
|
||||||
|
<exclude name="MethodArgumentCouldBeFinal"/>
|
||||||
|
<exclude name="OnlyOneReturn"/>
|
||||||
|
<exclude name="PackageCase"/>
|
||||||
|
<exclude name="ShortClassName"/>
|
||||||
|
<exclude name="ShortMethodName"/>
|
||||||
|
<exclude name="ShortVariable"/>
|
||||||
|
<exclude name="UselessParentheses"/>
|
||||||
|
<exclude name="UseUnderscoresInNumericLiterals"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule ref="category/java/codestyle.xml/UnnecessaryImport">
|
||||||
|
<properties>
|
||||||
|
<property name="violationSuppressRegex" value="Unused (static|.*\.\*).*"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- DESIGN -->
|
||||||
|
<rule ref="category/java/design.xml">
|
||||||
|
<exclude name="AvoidCatchingGenericException"/>
|
||||||
|
<exclude name="AvoidDeeplyNestedIfStmts"/>
|
||||||
|
<exclude name="AvoidUncheckedExceptionsInSignatures"/>
|
||||||
|
<exclude name="CognitiveComplexity"/>
|
||||||
|
<exclude name="CyclomaticComplexity"/>
|
||||||
|
<exclude name="ExcessiveClassLength"/>
|
||||||
|
<exclude name="ExcessiveMethodLength"/>
|
||||||
|
<exclude name="ExcessiveParameterList"/>
|
||||||
|
<exclude name="ExcessivePublicCount"/>
|
||||||
|
<exclude name="GodClass"/>
|
||||||
|
<exclude name="LawOfDemeter"/>
|
||||||
|
<exclude name="LoosePackageCoupling"/>
|
||||||
|
<exclude name="NPathComplexity"/>
|
||||||
|
<exclude name="NcssCount"/>
|
||||||
|
<exclude name="TooManyFields"/>
|
||||||
|
<exclude name="TooManyMethods"/>
|
||||||
|
<exclude name="UseObjectForClearerAPI"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- DOCUMENTATION -->
|
||||||
|
<rule ref="category/java/documentation.xml">
|
||||||
|
<exclude name="CommentRequired"/>
|
||||||
|
<exclude name="CommentSize"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- 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="NullAssignment"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule ref="category/java/errorprone.xml/AssignmentInOperand">
|
||||||
|
<properties>
|
||||||
|
<property name="allowWhile" value="true"/>
|
||||||
|
<property name="allowFor" value="true"/>
|
||||||
|
<property name="allowIf" value="true"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
<rule ref="category/java/errorprone.xml/AvoidDuplicateLiterals">
|
||||||
|
<properties>
|
||||||
|
<property name="skipAnnotations" value="true"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- MULTITHREADING -->
|
||||||
|
<rule ref="category/java/multithreading.xml">
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- PERFORMANCE -->
|
||||||
|
<rule ref="category/java/performance.xml">
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- SECURITY -->
|
||||||
|
<rule ref="category/java/security.xml">
|
||||||
|
</rule>
|
||||||
|
</ruleset>
|
|
@ -1,6 +1,6 @@
|
||||||
bld.downloadExtensionJavadoc=false
|
bld.downloadExtensionJavadoc=false
|
||||||
bld.downloadExtensionSources=true
|
bld.downloadExtensionSources=true
|
||||||
bld.extensions=
|
bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.4
|
||||||
bld.repositories=MAVEN_CENTRAL,RIFE2_RELEASES
|
bld.repositories=MAVEN_CENTRAL,RIFE2_RELEASES
|
||||||
bld.downloadLocation=
|
bld.downloadLocation=
|
||||||
bld.sourceDirectories=
|
bld.sourceDirectories=
|
||||||
|
|
|
@ -16,13 +16,12 @@
|
||||||
|
|
||||||
package rife.bld.extension;
|
package rife.bld.extension;
|
||||||
|
|
||||||
|
import rife.bld.BuildCommand;
|
||||||
import rife.bld.Project;
|
import rife.bld.Project;
|
||||||
import rife.bld.operations.RunOperation;
|
|
||||||
import rife.bld.publish.PublishDeveloper;
|
import rife.bld.publish.PublishDeveloper;
|
||||||
import rife.bld.publish.PublishLicense;
|
import rife.bld.publish.PublishLicense;
|
||||||
import rife.bld.publish.PublishScm;
|
import rife.bld.publish.PublishScm;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static rife.bld.dependencies.Repository.*;
|
import static rife.bld.dependencies.Repository.*;
|
||||||
|
@ -78,4 +77,13 @@ public class CompileKotlinOperationBuild extends Project {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new CompileKotlinOperationBuild().start(args);
|
new CompileKotlinOperationBuild().start(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BuildCommand(summary = "Runs PMD analysis")
|
||||||
|
public void pmd() {
|
||||||
|
new PmdOperation()
|
||||||
|
.fromProject(this)
|
||||||
|
.failOnViolation(true)
|
||||||
|
.ruleSets("config/pmd.xml")
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -203,6 +203,8 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
||||||
/**
|
/**
|
||||||
* Performs the compile operation.
|
* Performs the compile operation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("PMD.SystemPrintln")
|
||||||
public void execute()
|
public void execute()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
executeCreateBuildDirectories();
|
executeCreateBuildDirectories();
|
||||||
|
@ -259,9 +261,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
||||||
args.addAll(compileOptions());
|
args.addAll(compileOptions());
|
||||||
|
|
||||||
// source
|
// source
|
||||||
sources.forEach(f -> {
|
sources.forEach(f -> args.add(f.getAbsolutePath()));
|
||||||
args.add(f.getAbsolutePath());
|
|
||||||
});
|
|
||||||
|
|
||||||
if (LOGGER.isLoggable(Level.FINE) && !silent()) {
|
if (LOGGER.isLoggable(Level.FINE) && !silent()) {
|
||||||
LOGGER.fine("kotlinc " + String.join(" ", args));
|
LOGGER.fine("kotlinc " + String.join(" ", args));
|
||||||
|
@ -292,17 +292,13 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
||||||
* Part of the {@link #execute} operation, creates the build directories.
|
* Part of the {@link #execute} operation, creates the build directories.
|
||||||
*/
|
*/
|
||||||
protected void executeCreateBuildDirectories() throws IOException {
|
protected void executeCreateBuildDirectories() throws IOException {
|
||||||
if (buildMainDirectory() != null && !buildMainDirectory().exists()) {
|
if (buildMainDirectory() != null && !buildMainDirectory().exists() && !buildMainDirectory().mkdirs()) {
|
||||||
if (!buildMainDirectory().mkdirs()) {
|
|
||||||
throw new IOException("Could not created build main directory: " + buildMainDirectory().getAbsolutePath());
|
throw new IOException("Could not created build main directory: " + buildMainDirectory().getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
if (buildTestDirectory() != null && !buildTestDirectory().exists() && !buildTestDirectory().mkdirs()) {
|
||||||
if (buildTestDirectory() != null && !buildTestDirectory().exists()) {
|
|
||||||
if (!buildTestDirectory().mkdirs()) {
|
|
||||||
throw new IOException("Could not created build test directory: " + buildTestDirectory().getAbsolutePath());
|
throw new IOException("Could not created build test directory: " + buildTestDirectory().getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures a compile operation from a {@link BaseProject}.
|
* Configures a compile operation from a {@link BaseProject}.
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package rife.bld.extension;
|
package rife.bld.extension;
|
||||||
|
|
||||||
|
@SuppressWarnings({"PMD.TestClassWithoutTestCases", "PMD.SystemPrintln"})
|
||||||
public class CompileKotlinOperationTest {
|
public class CompileKotlinOperationTest {
|
||||||
void verifyHello() {
|
void verifyHello() {
|
||||||
if (!"Hello World!".equals(new CompileKotlinOperation().getMessage())) {
|
if (!"Hello World!".equals(new CompileKotlinOperation().getMessage())) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue