Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'com.diffplug.spotless' version '6.+'
id 'pmd'
}

group = 'io.orkes.conductor'
Expand All @@ -10,6 +11,7 @@ subprojects {
apply plugin: 'java'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'jacoco'
apply plugin: 'pmd'
group = 'org.conductoross'

spotless {
Expand Down Expand Up @@ -49,6 +51,26 @@ subprojects {
finalizedBy jacocoTestReport
}

pmd {
consoleOutput = true
ruleSetFiles = files("$rootDir/config/pmd/custom-ruleset.xml")
rulesMinimumPriority = 1
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope later to increase it to at least 3

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also plan to add it to PR pipelines later. Together with spotlessCheck

}

pmdMain {
reports {
html.required = true
xml.required = true
}
}

pmdTest {
reports {
html.required = true
xml.required = true
}
}

compileJava {
sourceCompatibility = 17
targetCompatibility = 17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private static Properties loadProperties(String file) {
Properties properties = new Properties();
try (InputStream input = PropertyFactory.class.getClassLoader().getResourceAsStream(file)) {
if (input == null) {
return null;
return properties;
}
properties.load(input);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,7 @@ public boolean isRetriable() {
private long firstStartTime;

public void setInputData(Map<String, Object> inputData) {
if (inputData == null) {
inputData = new HashMap<>();
}
this.inputData = inputData;
this.inputData = (inputData == null) ? new HashMap<>() : inputData;
}

public long getQueueWaitTime() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void testEqualsAndHashCodeWithSameInstance() {
@Test
void testEqualsWithNull() {
EventExecution execution = new EventExecution();
assertFalse(execution.equals(null));
assertNotNull(execution);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void testEqualsWithSameObject() {
@Test
public void testEqualsWithNull() {
PollData pollData = new PollData("queue", "domain", "worker", 123L);
assertFalse(pollData.equals(null));
assertNotNull(pollData);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void testEqualsWithSameObject() {
@Test
void testEqualsWithNull() {
TaskExecLog log = new TaskExecLog("test");
assertFalse(log.equals(null));
assertNotNull(log);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void testEqualsWithSameObject() {
void testEqualsWithNull() {
SubWorkflowParams params = new SubWorkflowParams();

assertFalse(params.equals(null));
assertNotNull(params);
}

@Test
Expand Down
26 changes: 26 additions & 0 deletions config/pmd/custom-ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<ruleset name="Conductor Java SDK Custom Rules"
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>
Custom PMD ruleset for Conductor Java SDK project.
Inherits errorprone and bestpractices rulesets.
</description>

<!-- Inherit the two specified rulesets -->
<rule ref="category/java/errorprone.xml">
</rule>

<rule ref="category/java/bestpractices.xml">
</rule>

<!-- Exclude generated code and build artifacts -->
<exclude-pattern>.*/generated/.*</exclude-pattern>
<exclude-pattern>.*/build/.*</exclude-pattern>
<exclude-pattern>.*/target/.*</exclude-pattern>
<exclude-pattern>.*/bin/.*</exclude-pattern>
<exclude-pattern>.*/out/.*</exclude-pattern>

</ruleset>
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void testEqualsAndHashCode() {
assertFalse(model1.equals(model3));
assertNotEquals(model1.hashCode(), model3.hashCode());

assertFalse(model1.equals(null));
assertNotNull(model1);
assertFalse(model1.equals("not a model"));
}

Expand Down
Loading