Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
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
46 changes: 46 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugins {
id 'com.diffplug.spotless' version '6.+'
id 'pmd'
id 'com.github.spotbugs' version '6.2.2'
}

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

spotless {
Expand Down Expand Up @@ -49,6 +53,46 @@ subprojects {
finalizedBy jacocoTestReport
}

pmd {
consoleOutput = true
ruleSetFiles = files("$rootDir/config/pmd/custom-ruleset.xml")
rulesMinimumPriority = 1
Copy link
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
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
}
}

spotbugs {
effort = com.github.spotbugs.snom.Effort.MAX
reportLevel = com.github.spotbugs.snom.Confidence.valueOf("HIGH")
excludeFilter = file("$rootDir/config/spotbugs/exclude.xml")
}

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

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

compileJava {
sourceCompatibility = 17
targetCompatibility = 17
Expand All @@ -71,6 +115,8 @@ subprojects {
implementation "org.apache.commons:commons-lang3:${versions.commonsLang}"
annotationProcessor "org.projectlombok:lombok:${versions.lombok}"
compileOnly "org.projectlombok:lombok:${versions.lombok}"

spotbugsPlugins("com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0")
}

repositories {
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 @@ -30,10 +30,9 @@ public class SummaryUtil {

private static boolean isSummaryInputOutputJsonSerializationEnabled;

private boolean isJsonSerializationEnabled;

@Deprecated(forRemoval = true)
public void init() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’m having trouble understanding the purpose of this class — most of its code seems to be unreachable, and all the booleans are private and unused.

Does anyone happen to remember what the original intention behind this class was, or where it might have been copied from? f4d77a5#diff-cece0d808b9662b571949c1de8b7f123b0f6da6dcea16ac0c46e95a2868cb744

isSummaryInputOutputJsonSerializationEnabled = isJsonSerializationEnabled;
// noop
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class AbstractWorkflowTests {

protected static ObjectMapper objectMapper = new ObjectMapperProvider().getObjectMapper();
protected static final ObjectMapper objectMapper = new ObjectMapperProvider().getObjectMapper();

protected static TypeReference<Map<String, List<WorkflowTestRequest.TaskMock>>> mockType =
protected static final TypeReference<Map<String, List<WorkflowTestRequest.TaskMock>>> mockType =
new TypeReference<Map<String, List<WorkflowTestRequest.TaskMock>>>() {};

protected MetadataClient metadataClient;
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>
26 changes: 26 additions & 0 deletions config/spotbugs/exclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter
xmlns="https://github.com/spotbugs/filter/3.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">

<Match>
<!-- It is all over the codebase. Skipping for now. TODO: investigate each usage later and fix if possible. -->
<Bug pattern="DM_DEFAULT_ENCODING"/>
</Match>

<Match>
<!-- TDOO: I don't see usages of this class in the codebase. But it is public class. Get back to this later and try to understand what was the intention behind it. -->
<Bug pattern="WEAK_MESSAGE_DIGEST_MD5"/>
<Class name="com.netflix.conductor.common.utils.MetadataUtils"/>
<Method name="computeChecksum" />
</Match>

<Match>
<!-- Shouldn't cause any issues. Skipping for now. TODO: fix this code smell later. -->
<Bug pattern="NP_NULL_PARAM_DEREF_NONVIRTUAL"/>
<Class name="com.netflix.conductor.client.spring.SpringWorkerConfiguration"/>
<Method name="getDomain"/>
</Match>

</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

import com.netflix.conductor.sdk.workflow.def.tasks.DynamicForkInput;
import com.netflix.conductor.sdk.workflow.def.tasks.SubWorkflow;
Expand Down Expand Up @@ -53,7 +53,7 @@ public DynamicForkInput generateDynamicFork(

@WorkerTask(value = "get_order_details", threadCount = 5)
public List<Order> getOrderDetails(@InputParam("orderNo") String orderNo) {
int lineItemCount = new Random().nextInt(10);
int lineItemCount = ThreadLocalRandom.current().nextInt(10);
List<Order> orderDetails = new ArrayList<>();
for (int i = 0; i < lineItemCount; i++) {
Order orderDetail = new Order(orderNo, "sku_" + i, 2, BigDecimal.valueOf(20.5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
*/
public class MetadataManagement {

public static String taskName = "test11_task";
public static String taskName2 = "test11_task1";
public static String taskName3 = "test11_task2";
private static final String taskName = "test11_task";
private static final String taskName2 = "test11_task1";
private static final String taskName3 = "test11_task2";
private static TaskDef taskDef;
private static TaskDef taskDef2;
private static TaskDef taskDef3;
Expand Down
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