Skip to content

Commit b3ff91c

Browse files
AustinShalitJLLeitschuh
authored andcommitted
Block (non-Javadoc) and System.out.println using checkstyle (#617)
* Block (non-Javadoc) using checkstyle * Add System.*.print checking * Update PipelineRunnerTest.java
1 parent e36bf8d commit b3ff91c

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ allprojects {
9898
checkstyle {
9999
configFile = new File(rootDir, "checkstyle.xml")
100100
toolVersion = '6.19'
101+
if (project.hasProperty("ignoreCheckstyle")) {
102+
ignoreFailures = true
103+
}
101104
}
102105

103106
tasks.withType(Checkstyle) {

checkstyle.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,5 +235,9 @@
235235
<property name="commentFormat" value=".*"/>
236236
</module>
237237
<module name="CommentsIndentation"/>
238+
<module name="Regexp">
239+
<property name="format" value="\(non\-Javadoc\)|System\..*\.print"/>
240+
<property name="illegalPattern" value="true"/>
241+
</module>
238242
</module>
239243
</module>

core/src/test/java/edu/wpi/grip/core/PipelineRunnerTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
import com.google.common.eventbus.Subscribe;
1515
import com.google.common.util.concurrent.MoreExecutors;
1616
import com.google.common.util.concurrent.Service;
17-
1817
import net.jodah.concurrentunit.Waiter;
19-
2018
import org.junit.After;
2119
import org.junit.Before;
2220
import org.junit.Test;
@@ -27,6 +25,8 @@
2725
import java.util.List;
2826
import java.util.concurrent.TimeUnit;
2927
import java.util.concurrent.TimeoutException;
28+
import java.util.logging.Level;
29+
import java.util.logging.Logger;
3030

3131
import static com.google.common.truth.Truth.assertThat;
3232
import static junit.framework.Assert.assertNull;
@@ -37,6 +37,8 @@
3737
@RunWith(Enclosed.class)
3838
public class PipelineRunnerTest {
3939

40+
private static final Logger logger = Logger.getLogger(PipelineRunnerTest.class.getName());
41+
4042
interface SimpleOperation extends Operation {
4143
OperationDescription DESCRIPTION = OperationDescription.builder()
4244
.name("Simple Operation")
@@ -383,10 +385,9 @@ public synchronized void failed(Service.State from, Throwable failure) {
383385
this.failure = failure;
384386
}
385387

386-
@SuppressWarnings("PMD.SystemPrintln")
387388
public synchronized void throwIfProblemPresent() throws Throwable {
388389
if (failedFrom != null || failure != null) {
389-
System.err.println("Failed from state " + failedFrom);
390+
logger.log(Level.SEVERE, "Failed from state " + failedFrom);
390391
throw failure;
391392
}
392393
}

core/src/test/java/edu/wpi/grip/core/operations/opencv/AddOperationTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,10 @@ public void testAddMatrixOfOnesToMatrixOfTwosEqualsMatrixOfThrees() {
6464
a.setValue(new Mat(2, sz, opencv_core.CV_8U, Scalar.all(1)));
6565
b.setValue(new Mat(2, sz, opencv_core.CV_8U, Scalar.all(2)));
6666

67-
//When
68-
long startTime = System.currentTimeMillis();
6967
for (int i = 0; i < 1000; i++) {
7068
addition.perform();
7169
}
72-
long endTime = System.currentTimeMillis();
73-
System.out.println("Run time: " + (endTime - startTime));
7470

75-
//Then
7671
Mat expectedResult = new Mat(2, sz, opencv_core.CV_8U, Scalar.all(3));
7772
assertTrue(isMatEqual((Mat) c.getValue().get(), expectedResult));
7873
}

0 commit comments

Comments
 (0)