From 38451c226dd8e4173c0dae1b4d75e4166549990c Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Tue, 6 Dec 2016 16:35:11 -0800 Subject: [PATCH] Fixing Codacy warnings --- .../java/com/google/cloud/bigquery/QueryParameter.java | 9 --------- .../com/google/cloud/bigquery/QueryParameterValue.java | 2 +- .../java/com/google/cloud/bigquery/QueryRequest.java | 2 -- .../google/cloud/bigquery/QueryParameterValueTest.java | 1 - .../com/google/cloud/bigquery/it/ITBigQueryTest.java | 7 ++----- 5 files changed, 3 insertions(+), 18 deletions(-) diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryParameter.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryParameter.java index ee950a3fb654..43f632f0db87 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryParameter.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryParameter.java @@ -18,18 +18,9 @@ import static com.google.common.base.Preconditions.checkNotNull; -import com.google.api.services.bigquery.Bigquery.Jobs.Query; -import com.google.cloud.bigquery.Field.Builder; -import com.google.cloud.bigquery.Field.Mode; -import com.google.cloud.bigquery.Field.Type; import com.google.common.base.Function; import com.google.common.base.MoreObjects; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import java.util.Objects; /** diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryParameterValue.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryParameterValue.java index c9a595652849..b118d4daea17 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryParameterValue.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryParameterValue.java @@ -394,7 +394,7 @@ com.google.api.services.bigquery.model.QueryParameterValue toValuePb() { com.google.api.services.bigquery.model.QueryParameterValue valuePb = new com.google.api.services.bigquery.model.QueryParameterValue(); valuePb.setValue(value); - if (arrayValues != null && arrayValues.size() > 0) { + if (arrayValues != null && !arrayValues.isEmpty()) { valuePb.setArrayValues( Lists.transform(arrayValues, QueryParameterValue.TO_VALUE_PB_FUNCTION)); } diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryRequest.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryRequest.java index e3f5b2df5f1a..87725c396f5e 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryRequest.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryRequest.java @@ -19,13 +19,11 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.MoreObjects; - import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import java.io.Serializable; import java.util.List; import java.util.Objects; -import javax.annotation.concurrent.Immutable; /** * Google Cloud BigQuery Query Request. This class can be used to run a BigQuery SQL query and diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryParameterValueTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryParameterValueTest.java index 545cca6a9fb8..270f24eee8f9 100644 --- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryParameterValueTest.java +++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryParameterValueTest.java @@ -16,7 +16,6 @@ package com.google.cloud.bigquery; -import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java index 57f4ce44230d..cccb6a9567d4 100644 --- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java +++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java @@ -75,6 +75,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; import com.google.common.io.BaseEncoding; import java.io.IOException; import java.nio.ByteBuffer; @@ -89,7 +90,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.junit.AfterClass; -import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; @@ -860,10 +860,7 @@ public void testNamedQueryParameters() throws InterruptedException { QueryResponse response = queryAndWaitForResponse(request); assertEquals(QUERY_RESULT_SCHEMA, response.getResult().getSchema()); int rowCount = 0; - for (List row : response.getResult().getValues()) { - rowCount++; - } - assertEquals(2, rowCount); + assertEquals(2, Iterables.size(response.getResult().getValues())); } @Test