Skip to content

Commit

Permalink
Merge pull request #5716: Enable errorprone globally
Browse files Browse the repository at this point in the history
  • Loading branch information
iemejia committed Jun 22, 2018
2 parents 0fbbf82 + 359110e commit d75365e
Show file tree
Hide file tree
Showing 56 changed files with 79 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class BeamModulePlugin implements Plugin<Project> {
boolean enableErrorProne = true

/** Controls whether compiler warnings are treated as errors. */
boolean failOnWarning = false
boolean failOnWarning = true

/**
* List of additional lint warnings to disable.
Expand Down Expand Up @@ -351,7 +351,6 @@ class BeamModulePlugin implements Plugin<Project> {
datastore_v1_proto_client : "com.google.cloud.datastore:datastore-v1-proto-client:1.4.0",
datastore_v1_protos : "com.google.cloud.datastore:datastore-v1-protos:1.3.0",
error_prone_annotations : "com.google.errorprone:error_prone_annotations:2.0.15",
findbugs_annotations : "com.github.stephenc.findbugs:findbugs-annotations:1.3.9-1",
findbugs_jsr305 : "com.google.code.findbugs:jsr305:3.0.1",
gax_grpc : "com.google.api:gax-grpc:0.20.0",
google_api_client : "com.google.api-client:google-api-client:$google_clients_version",
Expand Down Expand Up @@ -595,6 +594,14 @@ class BeamModulePlugin implements Plugin<Project> {
apt auto_service
testCompileOnly auto_service
testApt auto_service

// These dependencies are needed to avoid error-prone warnings on package-info.java files,
// also to include the annotations to supress warnings.
def findbugs_annotations = "com.github.stephenc.findbugs:findbugs-annotations:1.3.9-1"
compileOnly findbugs_annotations
apt findbugs_annotations
testCompileOnly findbugs_annotations
testApt findbugs_annotations
}

// Add the optional and provided configurations for dependencies
Expand Down
2 changes: 1 addition & 1 deletion examples/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import groovy.json.JsonOutput

apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(failOnWarning: true)
applyJavaNature()

description = "Apache Beam :: Examples :: Java"
ext.summary = """Apache Beam SDK provides a simple, Java-based
Expand Down
4 changes: 1 addition & 3 deletions runners/apex/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import groovy.json.JsonOutput

apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(failOnWarning: true)
applyJavaNature()

description = "Apache Beam :: Runners :: Apex"

Expand All @@ -35,7 +35,6 @@ configurations {
}

dependencies {
compileOnly library.java.findbugs_annotations
shadow project(path: ":beam-model-pipeline", configuration: "shadow")
shadow project(path: ":beam-sdks-java-core", configuration: "shadow")
shadow project(path: ":beam-runners-core-construction-java", configuration: "shadow")
Expand All @@ -46,7 +45,6 @@ dependencies {
shadow library.java.commons_lang3
shadow library.java.findbugs_jsr305
shadow library.java.apex_engine
testCompileOnly library.java.findbugs_annotations
shadowTest project(path: ":beam-sdks-java-core", configuration: "shadowTest")
// ApexStateInternalsTest extends abstract StateInternalsTest
shadowTest project(path: ":beam-runners-core-java", configuration: "shadowTest")
Expand Down
4 changes: 1 addition & 3 deletions runners/core-construction-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(failOnWarning: true)
applyJavaNature()

description = "Apache Beam :: Runners :: Core Construction Java"
ext.summary = """Beam Runners Core provides utilities to aid runner authors interact with a Pipeline
Expand All @@ -34,7 +34,6 @@ test {

dependencies {
compile library.java.guava
compileOnly library.java.findbugs_annotations
shadow project(path: ":beam-model-pipeline", configuration: "shadow")
shadow project(path: ":beam-model-job-management", configuration: "shadow")
shadow project(path: ":beam-sdks-java-core", configuration: "shadow")
Expand All @@ -47,7 +46,6 @@ dependencies {
shadow library.java.slf4j_api
shadow library.java.grpc_core
shadow library.java.grpc_stub
testCompileOnly library.java.findbugs_annotations
shadowTest library.java.hamcrest_core
shadowTest library.java.hamcrest_library
shadowTest library.java.junit
Expand Down
4 changes: 1 addition & 3 deletions runners/core-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(failOnWarning: true)
applyJavaNature()

description = "Apache Beam :: Runners :: Core Java"
ext.summary = "Beam Runners Core provides utilities to aid runner authors."
Expand All @@ -32,7 +32,6 @@ test {

dependencies {
compile library.java.guava
compileOnly library.java.findbugs_annotations
shadow project(path: ":beam-model-pipeline", configuration: "shadow")
shadow project(path: ":beam-sdks-java-core", configuration: "shadow")
shadow project(path: ":beam-model-fn-execution", configuration: "shadow")
Expand All @@ -41,7 +40,6 @@ dependencies {
shadow library.java.grpc_core
shadow library.java.grpc_stub
shadow library.java.joda_time
testCompileOnly library.java.findbugs_annotations
shadowTest project(path: ":beam-sdks-java-core", configuration: "shadowTest")
shadowTest library.java.junit
shadowTest library.java.hamcrest_core
Expand Down
2 changes: 1 addition & 1 deletion runners/direct-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def dependOnProjects = [":beam-model-pipeline", ":beam-runners-core-construction
":beam-runners-java-fn-execution", ":beam-sdks-java-fn-execution"]

apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(failOnWarning: true, shadowClosure: DEFAULT_SHADOW_CLOSURE << {
applyJavaNature(shadowClosure: DEFAULT_SHADOW_CLOSURE << {
dependencies {
include(dependency(library.java.protobuf_java))
include(dependency(library.java.protobuf_java_util))
Expand Down
19 changes: 8 additions & 11 deletions runners/extensions-java/metrics/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@
*/

apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(failOnWarning: true)
applyJavaNature()

description = "Apache Beam :: Runners :: Extensions Java :: Metrics"
ext.summary = "Beam Runners Extensions Metrics provides implementations of runners core metrics APIs."


dependencies {
compile library.java.guava
compileOnly library.java.findbugs_annotations
shadow project(path: ":beam-sdks-java-core", configuration: "shadow")
shadow library.java.jackson_databind
shadow library.java.jackson_datatype_joda
shadow library.java.findbugs_jsr305
testCompileOnly library.java.findbugs_annotations
shadowTest library.java.joda_time
shadowTest library.java.junit
compile library.java.guava
shadow project(path: ":beam-sdks-java-core", configuration: "shadow")
shadow library.java.jackson_databind
shadow library.java.jackson_datatype_joda
shadow library.java.findbugs_jsr305
shadowTest library.java.joda_time
shadowTest library.java.junit
}
3 changes: 1 addition & 2 deletions runners/flink/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import groovy.json.JsonOutput

apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(failOnWarning: true)
applyJavaNature()


description = "Apache Beam :: Runners :: Flink"
Expand Down Expand Up @@ -49,7 +49,6 @@ def flink_version = "1.5.0"

dependencies {
compile library.java.guava
compileOnly library.java.findbugs_annotations
shadow project(path: ":beam-sdks-java-core", configuration: "shadow")
shadow project(path: ":beam-runners-core-java", configuration: "shadow")
shadow project(path: ":beam-runners-core-construction-java", configuration: "shadow")
Expand Down
4 changes: 1 addition & 3 deletions runners/gearpump/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import groovy.json.JsonOutput

apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(failOnWarning: true)
applyJavaNature()

description = "Apache Beam :: Runners :: Gearpump"

Expand All @@ -38,7 +38,6 @@ configurations {

dependencies {
compile library.java.guava
compileOnly library.java.findbugs_annotations
compileOnly "com.typesafe:config:1.3.0"
compileOnly "org.scala-lang:scala-library:2.11.8"
shadow project(path: ":beam-sdks-java-core", configuration: "shadow")
Expand All @@ -49,7 +48,6 @@ dependencies {
shadow library.java.joda_time
shadow library.java.jackson_annotations
shadow library.java.findbugs_jsr305
testCompileOnly library.java.findbugs_annotations
shadowTest project(path: ":beam-sdks-java-core", configuration: "shadowTest")
shadowTest library.java.junit
shadowTest library.java.hamcrest_core
Expand Down
2 changes: 1 addition & 1 deletion runners/google-cloud-dataflow-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import groovy.json.JsonOutput

apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(failOnWarning: true)
applyJavaNature()

description = "Apache Beam :: Runners :: Google Cloud Dataflow"

Expand Down
3 changes: 1 addition & 2 deletions runners/java-fn-execution/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
*/

apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(failOnWarning: true)
applyJavaNature()

description = "Apache Beam :: Runners :: Java Fn Execution"

dependencies {
compile library.java.guava
compile library.java.findbugs_annotations
compile project(path: ":beam-runners-core-construction-java", configuration: "shadow")
provided project(path: ":beam-sdks-java-harness")
shadow project(path: ":beam-model-pipeline", configuration: "shadow")
Expand Down
3 changes: 1 addition & 2 deletions runners/local-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(failOnWarning: true)
applyJavaNature()

description = "Apache Beam :: Runners :: Local Java Core"

Expand All @@ -31,7 +31,6 @@ dependencies {
shadow project(path: ":beam-sdks-java-core", configuration: "shadow")
shadow library.java.joda_time
shadow library.java.findbugs_jsr305
shadow library.java.findbugs_annotations
shadowTest library.java.hamcrest_core
shadowTest library.java.hamcrest_library
shadowTest library.java.junit
Expand Down
4 changes: 1 addition & 3 deletions runners/reference/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,18 @@
*/

apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(failOnWarning: true)
applyJavaNature()

description = "Apache Beam :: Runners :: Reference :: Java"
ext.summary = """A Java implementation of the Beam Model which utilizes the portability
framework to execute user-definied functions."""


dependencies {
compileOnly library.java.findbugs_annotations
shadow project(path: ":beam-model-pipeline", configuration: "shadow")
shadow project(path: ":beam-runners-core-construction-java", configuration: "shadow")
shadow project(path: ":beam-sdks-java-fn-execution", configuration: "shadow")
shadow library.java.slf4j_api
testCompileOnly library.java.findbugs_annotations
shadowTest project(path: ":beam-runners-core-construction-java", configuration: "shadowTest")
testCompile library.java.hamcrest_core
testCompile library.java.junit
Expand Down
4 changes: 1 addition & 3 deletions runners/spark/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import groovy.json.JsonOutput

apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(failOnWarning: true)
applyJavaNature()

description = "Apache Beam :: Runners :: Spark"

Expand Down Expand Up @@ -53,7 +53,6 @@ test {
}

dependencies {
compileOnly library.java.findbugs_annotations
shadow project(path: ":beam-model-pipeline", configuration: "shadow")
shadow project(path: ":beam-sdks-java-core", configuration: "shadow")
shadow project(path: ":beam-runners-core-construction-java", configuration: "shadow")
Expand All @@ -78,7 +77,6 @@ dependencies {
provided "org.apache.zookeeper:zookeeper:3.4.11"
provided "org.scala-lang:scala-library:2.11.8"
provided "com.esotericsoftware.kryo:kryo:2.21"
testCompileOnly library.java.findbugs_annotations
shadowTest project(path: ":beam-sdks-java-io-kafka", configuration: "shadow")
shadowTest project(path: ":beam-sdks-java-core", configuration: "shadowTest")
// SparkStateInternalsTest extends abstract StateInternalsTest
Expand Down
2 changes: 1 addition & 1 deletion sdks/java/build-tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
*/

apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(failOnWarning: true)
applyJavaNature()

description = "Apache Beam :: SDKs :: Java :: Build Tools"
2 changes: 0 additions & 2 deletions sdks/java/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ dependencies {
compile library.java.commons_compress
compile library.java.commons_lang3
compile library.java.guava_testlib
compileOnly library.java.findbugs_annotations
testCompileOnly library.java.findbugs_annotations
shadow library.java.jackson_core
shadow library.java.jackson_annotations
shadow library.java.jackson_databind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ private static long getProjectNumber(

@VisibleForTesting
static String getRegionFromZone(String zone) {
String[] zoneParts = zone.split("-");
String[] zoneParts = zone.split("-", -1);
checkArgument(zoneParts.length >= 2, "Invalid zone provided: %s", zone);
return zoneParts[0] + "-" + zoneParts[1];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import java.math.BigInteger;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -184,7 +184,7 @@ MatchResult expand(GcsPath gcsPattern) throws IOException {
prefix, p.toString());

String pageToken = null;
List<Metadata> results = new LinkedList<>();
List<Metadata> results = new ArrayList<>();
do {
Objects objects = options.getGcsUtil().listObjects(gcsPattern.getBucket(), prefix, pageToken);
if (objects.getItems() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -259,7 +258,7 @@ public List<GcsPath> expand(GcsPath gcsPattern) throws IOException {
prefix, p.toString());

String pageToken = null;
List<GcsPath> results = new LinkedList<>();
List<GcsPath> results = new ArrayList<>();
do {
Objects objects = listObjects(gcsPattern.getBucket(), prefix, pageToken);
if (objects.getItems() == null) {
Expand Down Expand Up @@ -586,7 +585,7 @@ private static void executeBatches(List<BatchRequest> batches) throws IOExceptio
TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>())));

List<CompletionStage<Void>> futures = new LinkedList<>();
List<CompletionStage<Void>> futures = new ArrayList<>();
for (final BatchRequest batch : batches) {
futures.add(MoreFutures.runAsync(
() -> batch.execute(),
Expand Down Expand Up @@ -620,7 +619,7 @@ private static void executeBatches(List<BatchRequest> batches) throws IOExceptio
List<BatchRequest> makeGetBatches(
Collection<GcsPath> paths,
List<StorageObjectOrIOException[]> results) throws IOException {
List<BatchRequest> batches = new LinkedList<>();
List<BatchRequest> batches = new ArrayList<>();
for (List<GcsPath> filesToGet :
Lists.partition(Lists.newArrayList(paths), MAX_REQUESTS_PER_BATCH)) {
BatchRequest batch = createBatchRequest();
Expand All @@ -647,7 +646,7 @@ List<BatchRequest> makeCopyBatches(Iterable<String> srcFilenames, Iterable<Strin
srcList.size(),
destList.size());

List<BatchRequest> batches = new LinkedList<>();
List<BatchRequest> batches = new ArrayList<>();
BatchRequest batch = createBatchRequest();
for (int i = 0; i < srcList.size(); i++) {
final GcsPath sourcePath = GcsPath.fromUri(srcList.get(i));
Expand All @@ -665,7 +664,7 @@ List<BatchRequest> makeCopyBatches(Iterable<String> srcFilenames, Iterable<Strin
}

List<BatchRequest> makeRemoveBatches(Collection<String> filenames) throws IOException {
List<BatchRequest> batches = new LinkedList<>();
List<BatchRequest> batches = new ArrayList<>();
for (List<String> filesToDelete :
Lists.partition(Lists.newArrayList(filenames), MAX_REQUESTS_PER_BATCH)) {
BatchRequest batch = createBatchRequest();
Expand Down
Loading

0 comments on commit d75365e

Please sign in to comment.