mirror of
https://github.com/ysoftdevs/gradle-training.git
synced 2026-03-21 16:49:50 +01:00
initial import of project
This commit is contained in:
24
03-checkstyle/build.gradle
Normal file
24
03-checkstyle/build.gradle
Normal file
@@ -0,0 +1,24 @@
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'pmd'
|
||||
apply plugin: 'checkstyle'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile group: 'org.testng', name: 'testng', version: '6.+'
|
||||
}
|
||||
|
||||
test {
|
||||
useTestNG()
|
||||
}
|
||||
|
||||
pmdMain {
|
||||
ruleSets = [ "basic", "strings" ]
|
||||
ignoreFailures = true
|
||||
}
|
||||
|
||||
tasks.withType(Checkstyle) {
|
||||
ignoreFailures = true
|
||||
}
|
||||
11
03-checkstyle/config/checkstyle/checkstyle.xml
Normal file
11
03-checkstyle/config/checkstyle/checkstyle.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
|
||||
|
||||
<module name="Checker">
|
||||
<module name="TreeWalker">
|
||||
<module name="UnusedImports"/>
|
||||
</module>
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.ysoft.training;
|
||||
|
||||
// Generate Checkstyle warning - unused import
|
||||
import java.util.Date;
|
||||
|
||||
public class Calculator {
|
||||
|
||||
/** Internal counter */
|
||||
private int counter;
|
||||
|
||||
Calculator() {
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
|
||||
public int getCounter() {
|
||||
return counter;
|
||||
}
|
||||
|
||||
void add(int i) {
|
||||
|
||||
// Generate PMD warning
|
||||
if (i==1) {
|
||||
}
|
||||
|
||||
counter += i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ysoft.training;
|
||||
|
||||
import com.ysoft.training.Calculator;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class TestCalculator {
|
||||
|
||||
@Test
|
||||
public void testAdd() {
|
||||
Calculator calc = new Calculator();
|
||||
calc.add(1);
|
||||
Assert.assertEquals(calc.getCounter(), 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user