Skip to content

Commit 6db5845

Browse files
committed
Add the missing checkstyle checks
- Fixed the checkstyle errors - Also cleanup the pom.xml
1 parent a0fb365 commit 6db5845

11 files changed

+133
-126
lines changed

checkstyle.xml

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
-->
1717

1818
<!DOCTYPE module PUBLIC
19-
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
20-
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
19+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
20+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
2121

2222
<!-- This is a checkstyle configuration file. For descriptions of
2323
what the following rules do, please see the checkstyle configuration
@@ -114,8 +114,8 @@ page at http://checkstyle.sourceforge.net/config.html -->
114114
<property name="max" value="300"/>
115115
<property name="countEmpty" value="false"/>
116116
<property name="severity" value="warning"/>
117-
</module>
118-
117+
</module>
118+
119119
<!--
120120
121121
JAVADOC CHECKS
@@ -250,8 +250,8 @@ page at http://checkstyle.sourceforge.net/config.html -->
250250
-->
251251

252252
<property name="ignorePattern"
253-
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
254-
default="^(package .*;\s*)|(import .*;\s*)|( *\* *https?://.*)$"/>
253+
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
254+
default="^(package .*;\s*)|(import .*;\s*)|( *\* *https?://.*)$"/>
255255
</module>
256256

257257
<module name="LeftCurly">
@@ -298,7 +298,7 @@ page at http://checkstyle.sourceforge.net/config.html -->
298298
some other variants which we don't publicized to promote consistency).
299299
-->
300300
<property name="reliefPattern"
301-
value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
301+
value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
302302
<property name="severity" value="error"/>
303303
</module>
304304

pom.xml

+113-109
Original file line numberDiff line numberDiff line change
@@ -406,124 +406,132 @@
406406
</dependencies>
407407

408408
<build>
409-
<pluginManagement>
410-
<plugins>
411-
<plugin>
412-
<groupId>org.apache.maven.plugins</groupId>
413-
<artifactId>maven-compiler-plugin</artifactId>
414-
<version>3.1</version>
415-
<configuration>
416-
<source>1.8</source>
417-
<target>1.8</target>
418-
</configuration>
419-
</plugin>
420-
<plugin>
421-
<groupId>org.apache.maven.plugins</groupId>
422-
<artifactId>maven-surefire-plugin</artifactId>
423-
<version>2.14.1</version>
424-
<configuration>
425-
<argLine>-Xmx512m</argLine>
426-
<systemPropertyVariables>
427-
<java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
428-
</systemPropertyVariables>
429-
<includes>
430-
<include>**/*TestSuite.java</include>
431-
<include>**/Test*.java</include>
432-
<include>**/*Test.java</include>
433-
<include>**/*TestCase.java</include>
434-
</includes>
435-
</configuration>
436-
</plugin>
437-
<plugin>
438-
<groupId>org.apache.felix</groupId>
439-
<artifactId>maven-bundle-plugin</artifactId>
440-
<version>3.5.1</version>
441-
<extensions>true</extensions>
442-
<configuration>
443-
<instructions>
444-
<Embed-Dependency>*;inline=false;scope=compile</Embed-Dependency>
445-
<Embed-Transitive>true</Embed-Transitive>
446-
<Embed-Directory>lib</Embed-Directory>
447-
<!--Only @Plugin classes in the export packages will be included as plugin-->
448-
<_exportcontents>
449-
co.cask.gcp.*;
450-
com.google.cloud.hadoop.*;
451-
org.apache.avro.mapred.*;
452-
org.apache.avro.mapreduce;
453-
parquet.avro.*;
454-
parquet.hadoop.*;
455-
org.apache.spark.streaming.pubsub*;
456-
</_exportcontents>
457-
</instructions>
458-
</configuration>
459-
<executions>
460-
<execution>
461-
<phase>package</phase>
462-
<goals>
463-
<goal>bundle</goal>
464-
</goals>
465-
</execution>
466-
</executions>
467-
</plugin>
468-
<plugin>
469-
<groupId>org.apache.maven.plugins</groupId>
470-
<artifactId>maven-antrun-plugin</artifactId>
471-
<version>1.7</version>
472-
</plugin>
473-
<plugin>
474-
<groupId>net.alchim31.maven</groupId>
475-
<artifactId>scala-maven-plugin</artifactId>
476-
<version>3.2.2</version>
477-
<configuration>
478-
<args>
479-
<arg>-target:jvm-1.7</arg>
480-
</args>
481-
</configuration>
482-
<executions>
483-
<execution>
484-
<id>scala-add-source</id>
485-
<goals>
486-
<goal>add-source</goal>
487-
</goals>
488-
</execution>
489-
<execution>
490-
<id>scala-compile</id>
491-
<!-- Needs to be before the compile phase -->
492-
<phase>process-resources</phase>
493-
<goals>
494-
<goal>compile</goal>
495-
</goals>
496-
</execution>
497-
<execution>
498-
<id>scala-test-compile</id>
499-
<!-- Needs to be before the test-compile phase -->
500-
<phase>process-test-resources</phase>
501-
<goals>
502-
<goal>testCompile</goal>
503-
</goals>
504-
</execution>
505-
</executions>
506-
</plugin>
507-
</plugins>
508-
</pluginManagement>
509-
510409
<plugins>
410+
<plugin>
411+
<groupId>org.apache.maven.plugins</groupId>
412+
<artifactId>maven-checkstyle-plugin</artifactId>
413+
<version>2.17</version>
414+
<executions>
415+
<execution>
416+
<id>validate</id>
417+
<phase>process-test-classes</phase>
418+
<configuration>
419+
<configLocation>checkstyle.xml</configLocation>
420+
<suppressionsLocation>suppressions.xml</suppressionsLocation>
421+
<encoding>UTF-8</encoding>
422+
<consoleOutput>true</consoleOutput>
423+
<failsOnError>true</failsOnError>
424+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
425+
</configuration>
426+
<goals>
427+
<goal>check</goal>
428+
</goals>
429+
</execution>
430+
</executions>
431+
<dependencies>
432+
<dependency>
433+
<groupId>com.puppycrawl.tools</groupId>
434+
<artifactId>checkstyle</artifactId>
435+
<version>6.19</version>
436+
</dependency>
437+
</dependencies>
438+
</plugin>
439+
511440
<plugin>
512441
<groupId>org.apache.maven.plugins</groupId>
513442
<artifactId>maven-compiler-plugin</artifactId>
443+
<version>3.1</version>
444+
<configuration>
445+
<source>1.8</source>
446+
<target>1.8</target>
447+
</configuration>
448+
</plugin>
449+
450+
<plugin>
451+
<groupId>net.alchim31.maven</groupId>
452+
<artifactId>scala-maven-plugin</artifactId>
453+
<version>3.2.2</version>
454+
<configuration>
455+
<args>
456+
<arg>-target:jvm-1.7</arg>
457+
</args>
458+
</configuration>
459+
<executions>
460+
<execution>
461+
<id>scala-add-source</id>
462+
<goals>
463+
<goal>add-source</goal>
464+
</goals>
465+
</execution>
466+
<execution>
467+
<id>scala-compile</id>
468+
<!-- Needs to be before the compile phase -->
469+
<phase>process-resources</phase>
470+
<goals>
471+
<goal>compile</goal>
472+
</goals>
473+
</execution>
474+
<execution>
475+
<id>scala-test-compile</id>
476+
<!-- Needs to be before the test-compile phase -->
477+
<phase>process-test-resources</phase>
478+
<goals>
479+
<goal>testCompile</goal>
480+
</goals>
481+
</execution>
482+
</executions>
514483
</plugin>
484+
515485
<plugin>
516486
<groupId>org.apache.maven.plugins</groupId>
517487
<artifactId>maven-surefire-plugin</artifactId>
488+
<version>2.14.1</version>
489+
<configuration>
490+
<argLine>-Xmx512m</argLine>
491+
<systemPropertyVariables>
492+
<java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
493+
</systemPropertyVariables>
494+
<includes>
495+
<include>**/*TestSuite.java</include>
496+
<include>**/Test*.java</include>
497+
<include>**/*Test.java</include>
498+
<include>**/*TestCase.java</include>
499+
</includes>
500+
</configuration>
518501
</plugin>
502+
519503
<plugin>
520504
<groupId>org.apache.felix</groupId>
521505
<artifactId>maven-bundle-plugin</artifactId>
506+
<version>3.5.1</version>
507+
<extensions>true</extensions>
508+
<configuration>
509+
<instructions>
510+
<Embed-Dependency>*;inline=false;scope=compile</Embed-Dependency>
511+
<Embed-Transitive>true</Embed-Transitive>
512+
<Embed-Directory>lib</Embed-Directory>
513+
<!--Only @Plugin classes in the export packages will be included as plugin-->
514+
<_exportcontents>
515+
co.cask.gcp.*;
516+
com.google.cloud.hadoop.*;
517+
org.apache.avro.mapred.*;
518+
org.apache.avro.mapreduce;
519+
parquet.avro.*;
520+
parquet.hadoop.*;
521+
org.apache.spark.streaming.pubsub*;
522+
</_exportcontents>
523+
</instructions>
524+
</configuration>
525+
<executions>
526+
<execution>
527+
<phase>package</phase>
528+
<goals>
529+
<goal>bundle</goal>
530+
</goals>
531+
</execution>
532+
</executions>
522533
</plugin>
523-
<plugin>
524-
<groupId>org.apache.maven.plugins</groupId>
525-
<artifactId>maven-antrun-plugin</artifactId>
526-
</plugin>
534+
527535
<plugin>
528536
<groupId>co.cask</groupId>
529537
<artifactId>cdap-maven-plugin</artifactId>
@@ -544,10 +552,6 @@
544552
</execution>
545553
</executions>
546554
</plugin>
547-
<plugin>
548-
<groupId>net.alchim31.maven</groupId>
549-
<artifactId>scala-maven-plugin</artifactId>
550-
</plugin>
551555
</plugins>
552556
</build>
553557

src/main/java/co/cask/gcp/bigquery/BigQuerySink.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public void prepareRun(BatchSinkContext context) throws Exception {
159159
Schema.Type type = field.getSchema().getType();
160160

161161
Schema fieldSchema = field.getSchema();
162-
fieldSchema = fieldSchema.isNullable()? fieldSchema.getNonNullable() : fieldSchema;
162+
fieldSchema = fieldSchema.isNullable() ? fieldSchema.getNonNullable() : fieldSchema;
163163
if (!fieldSchema.getType().isSimpleType()) {
164164
throw new IllegalArgumentException(String.format("Field '%s' is of unsupported type '%s'", name, type));
165165
}

src/main/java/co/cask/gcp/common/GCPReferenceSinkConfig.java

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import co.cask.cdap.api.annotation.Description;
2020
import co.cask.cdap.api.annotation.Macro;
2121
import co.cask.cdap.api.annotation.Name;
22-
import co.cask.gcp.common.GCPConfig;
2322

2423
/**
2524
* Reference config extending GCPConfig for sinks.

src/main/java/co/cask/gcp/common/GCPReferenceSourceConfig.java

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import co.cask.cdap.api.annotation.Description;
2020
import co.cask.cdap.api.annotation.Macro;
2121
import co.cask.cdap.api.annotation.Name;
22-
import co.cask.gcp.common.GCPConfig;
2322

2423
/**
2524
* Reference config extending GCPConfig for sources.

src/main/java/co/cask/gcp/common/WholeFileInputFormat.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ public WholeFileRecordReader createRecordReader(InputSplit inputSplit,
4242
reader.initialize(inputSplit, context);
4343
return reader;
4444
}
45-
}
45+
}

src/main/java/co/cask/gcp/common/WholeFileRecordReader.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ public float getProgress() throws IOException, InterruptedException {
8989
public void close() throws IOException {
9090
// no-op
9191
}
92-
}
92+
}

src/main/java/co/cask/gcp/gcs/source/GCSFileBlob.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void configurePipeline(PipelineConfigurer configurer) {
6363
}
6464

6565
@Override
66-
public void prepareRun(BatchSourceContext context){
66+
public void prepareRun(BatchSourceContext context) {
6767
config.validate();
6868
Schema outputSchema = context.getOutputSchema();
6969

src/main/java/co/cask/gcp/publisher/source/GoogleSubscriber.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@
1919
import co.cask.cdap.api.annotation.Macro;
2020
import co.cask.cdap.api.annotation.Name;
2121
import co.cask.cdap.api.annotation.Plugin;
22-
import co.cask.cdap.api.common.Bytes;
2322
import co.cask.cdap.api.data.format.StructuredRecord;
2423
import co.cask.cdap.api.data.schema.Schema;
2524
import co.cask.cdap.etl.api.PipelineConfigurer;
2625
import co.cask.cdap.etl.api.streaming.StreamingContext;
2726
import co.cask.cdap.etl.api.streaming.StreamingSource;
2827
import co.cask.gcp.common.GCPReferenceSourceConfig;
2928
import com.google.cloud.Timestamp;
30-
import org.apache.spark.api.java.function.Function;
3129
import org.apache.spark.storage.StorageLevel;
3230
import org.apache.spark.streaming.api.java.JavaDStream;
3331
import org.apache.spark.streaming.api.java.JavaReceiverInputDStream;
@@ -89,7 +87,7 @@ public JavaDStream<StructuredRecord> getStream(StreamingContext streamingContext
8987
PubsubUtils.createStream(streamingContext.getSparkStreamingContext(), config.getProject(), config.topic,
9088
config.subscription, credentials, StorageLevel.MEMORY_ONLY());
9189

92-
return pubSubMessages.map((Function<SparkPubsubMessage, StructuredRecord>) pubSubMessage -> StructuredRecord.builder(DEFAULT_SCHEMA)
90+
return pubSubMessages.map(pubSubMessage -> StructuredRecord.builder(DEFAULT_SCHEMA)
9391
.set("message", pubSubMessage.getData())
9492
.set("id", pubSubMessage.getMessageId())
9593
.setTimestamp("timestamp", getTimestamp(pubSubMessage.getPublishTime())).build());
@@ -104,6 +102,9 @@ private ZonedDateTime getTimestamp(String publishTime) {
104102
return ZonedDateTime.ofInstant(instant, ZoneId.ofOffset("UTC", ZoneOffset.UTC));
105103
}
106104

105+
/**
106+
* Configuration class for the subscriber source.
107+
*/
107108
public static class SubscriberConfig extends GCPReferenceSourceConfig {
108109

109110
@Description("Cloud Pub/Sub subscription to read from. If the subscription does not exist it will be " +

src/main/java/co/cask/gcp/speech/SpeechTransform.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public Credentials getCredentials() throws IOException {
146146

147147
@Override
148148
public void transform(StructuredRecord input, Emitter<StructuredRecord> emitter) throws Exception {
149-
ByteString audioBytes = ByteString.copyFrom((byte[])input.get(config.audio));
149+
ByteString audioBytes = ByteString.copyFrom((byte[]) input.get(config.audio));
150150
RecognitionAudio audio = RecognitionAudio.newBuilder()
151151
.setContent(audioBytes)
152152
.build();
@@ -200,6 +200,9 @@ public static ServiceAccountCredentials loadServiceAccountCredentials(String pat
200200
}
201201
}
202202

203+
/**
204+
* Request object from the Plugin REST call.
205+
*/
203206
public static final class Request {
204207
private Map<String, Schema> inputSchemas;
205208
}

0 commit comments

Comments
 (0)