Skip to content
This repository was archived by the owner on Dec 23, 2023. It is now read-only.

Commit cba3ca9

Browse files
authored
Merge pull request #71 from sebright/checkstyle-unused-imports
Checks for unused imports with Checkstyle.
2 parents e8f0cb3 + 9dec368 commit cba3ca9

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ matrix:
88
env: BUILD=MVN
99

1010
- jdk: oraclejdk7
11-
env: BUILD=MVN
11+
env: BUILD=MVN STYLE_CHECK=google_checks.xml
1212

1313
- jdk: oraclejdk8
14-
env: BUILD=MVN
14+
env: BUILD=MVN STYLE_CHECK=google_checks.xml
15+
16+
- jdk: oraclejdk8
17+
env: BUILD=MVN STYLE_CHECK=checkstyle_custom_checks.xml
1518

1619
- jdk: oraclejdk8
1720
env: BUILD=BAZEL
@@ -49,6 +52,6 @@ script:
4952
"openjdk6")
5053
mvn verify -P java6 ;;
5154
*)
52-
mvn verify ;;
55+
mvn verify -Dcheckstyle.config=$STYLE_CHECK ;;
5356
esac
5457
esac

checkstyle_custom_checks.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
4+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
5+
6+
<module name = "Checker">
7+
<property name="charset" value="UTF-8"/>
8+
<property name="severity" value="error"/>
9+
<module name="TreeWalker">
10+
<module name="UnusedImports"/>
11+
</module>
12+
</module>

core/java/com/google/instrumentation/stats/RpcConstants.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
import com.google.instrumentation.stats.MeasurementDescriptor.BasicUnit;
1717
import com.google.instrumentation.stats.MeasurementDescriptor.MeasurementUnit;
18-
import com.google.instrumentation.stats.ViewDescriptor.DistributionViewDescriptor;
19-
import com.google.instrumentation.stats.ViewDescriptor.IntervalViewDescriptor;
2018

2119
import java.util.Arrays;
2220
import java.util.List;

core/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
<artifactId>census-parent</artifactId>
1616
<version>0.1.0-SNAPSHOT</version>
1717
</parent>
18+
19+
<properties>
20+
<checkstyle.config>google_checks.xml</checkstyle.config>
21+
</properties>
22+
1823
<build>
1924
<sourceDirectory>java</sourceDirectory>
2025
<plugins>
@@ -73,7 +78,7 @@
7378
<id>validate</id>
7479
<phase>validate</phase>
7580
<configuration>
76-
<configLocation>google_checks.xml</configLocation>
81+
<configLocation>${checkstyle.config}</configLocation>
7782
<encoding>UTF-8</encoding>
7883
<consoleOutput>true</consoleOutput>
7984
<failsOnViolation>true</failsOnViolation>

core_impl/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
<version>0.1.0-SNAPSHOT</version>
1717
</parent>
1818

19+
<properties>
20+
<checkstyle.config>google_checks.xml</checkstyle.config>
21+
</properties>
22+
1923
<dependencies>
2024
<dependency>
2125
<groupId>com.google.census</groupId>
@@ -89,7 +93,7 @@
8993
<id>validate</id>
9094
<phase>validate</phase>
9195
<configuration>
92-
<configLocation>google_checks.xml</configLocation>
96+
<configLocation>${checkstyle.config}</configLocation>
9397
<encoding>UTF-8</encoding>
9498
<consoleOutput>true</consoleOutput>
9599
<failsOnViolation>true</failsOnViolation>

0 commit comments

Comments
 (0)