Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Static Analysis #1350

Merged
merged 7 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix all Single Line Constructors
We decided to enforce no single line constructors
  • Loading branch information
RussellSpitzer committed Aug 21, 2020
commit e452662271c1647f056ad13e190ca18fea38fc03
2 changes: 1 addition & 1 deletion .baseline/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
</module>
<module name="RightCurly"> <!-- Java Style Guide: Nonempty blocks: K & R style -->
<property name="option" value="alone"/>
<property name="tokens" value="CLASS_DEF, METHOD_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT, INSTANCE_INIT"/>
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT, INSTANCE_INIT"/>
</module>
<module name="SeparatorWrap"> <!-- Java Style Guide: Where to break -->
<property name="tokens" value="DOT"/>
Expand Down
3 changes: 2 additions & 1 deletion api/src/main/java/org/apache/iceberg/Files.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@

public class Files {

private Files() {}
private Files() {
}

public static OutputFile localOutput(File file) {
return new LocalOutputFile(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
*/
public class ExpressionVisitors {

private ExpressionVisitors() {}
private ExpressionVisitors() {
}

public abstract static class ExpressionVisitor<R> {
public R alwaysTrue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@

class ProjectionUtil {

private ProjectionUtil() {}
private ProjectionUtil() {
}

static <T> UnboundPredicate<T> truncateInteger(
String name, BoundLiteralPredicate<Integer> pred, Transform<Integer, T> transform) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@

class TransformUtil {

private TransformUtil() {}
private TransformUtil() {
}

private static final OffsetDateTime EPOCH = Instant.ofEpochSecond(0).atOffset(ZoneOffset.UTC);
private static final int EPOCH_YEAR = EPOCH.getYear();
Expand Down
3 changes: 2 additions & 1 deletion api/src/main/java/org/apache/iceberg/types/Comparators.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@

public class Comparators {

private Comparators() {}
private Comparators() {
}

private static final ImmutableMap<Type.PrimitiveType, Comparator<?>> COMPARATORS = ImmutableMap
.<Type.PrimitiveType, Comparator<?>>builder()
Expand Down
3 changes: 2 additions & 1 deletion api/src/main/java/org/apache/iceberg/types/Conversions.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@

public class Conversions {

private Conversions() {}
private Conversions() {
}

private static final String HIVE_NULL = "__HIVE_DEFAULT_PARTITION__";

Expand Down
3 changes: 2 additions & 1 deletion api/src/main/java/org/apache/iceberg/types/TypeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@

public class TypeUtil {

private TypeUtil() {}
private TypeUtil() {
}

public static Schema select(Schema schema, Set<Integer> fieldIds) {
Preconditions.checkNotNull(schema, "Schema cannot be null");
Expand Down
3 changes: 2 additions & 1 deletion api/src/main/java/org/apache/iceberg/types/Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@

public class Types {

private Types() {}
private Types() {
}

private static final ImmutableMap<String, PrimitiveType> TYPES = ImmutableMap
.<String, PrimitiveType>builder()
Expand Down
3 changes: 2 additions & 1 deletion api/src/test/java/org/apache/iceberg/AssertHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

public class AssertHelpers {

private AssertHelpers() {}
private AssertHelpers() {
}

/**
* A convenience method to avoid a large number of @Test(expected=...) tests
Expand Down
3 changes: 2 additions & 1 deletion api/src/test/java/org/apache/iceberg/TestHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@

public class TestHelpers {

private TestHelpers() {}
private TestHelpers() {
}

public static <T> T assertAndUnwrap(Expression expr, Class<T> expected) {
Assert.assertTrue("Expression should have expected type: " + expected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public class ArrowSchemaUtil {
private static final String ORIGINAL_TYPE = "originalType";
private static final String MAP_TYPE = "mapType";

private ArrowSchemaUtil() { }
private ArrowSchemaUtil() {
}

/**
* Convert Iceberg schema to Arrow Schema.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

public class DynClasses {

private DynClasses() {}
private DynClasses() {
}

public static Builder builder() {
return new Builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
*/
public class DynConstructors {

private DynConstructors() {}
private DynConstructors() {
}

public static class Ctor<C> extends DynMethods.UnboundMethod {
private final Constructor<C> ctor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@

public class DynFields {

private DynFields() {}
private DynFields() {
}

/**
* Convenience wrapper class around {@link java.lang.reflect.Field}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
*/
public class DynMethods {

private DynMethods() {}
private DynMethods() {
}

/**
* Convenience wrapper class around {@link java.lang.reflect.Method}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public abstract class BaseMetastoreTableOperations implements TableOperations {
private boolean shouldRefresh = true;
private int version = -1;

protected BaseMetastoreTableOperations() { }
protected BaseMetastoreTableOperations() {
}

@Override
public TableMetadata current() {
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/iceberg/DataFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@

public class DataFiles {

private DataFiles() {}
private DataFiles() {
}

static PartitionData newPartitionData(PartitionSpec spec) {
return new PartitionData(spec.partitionType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class InheritableMetadataFactory {

private static final InheritableMetadata EMPTY = new EmptyInheritableMetadata();

private InheritableMetadataFactory() {}
private InheritableMetadataFactory() {
}

static InheritableMetadata empty() {
return EMPTY;
Expand Down Expand Up @@ -84,7 +85,8 @@ public <F extends ContentFile<F>> ManifestEntry<F> apply(ManifestEntry<F> manife

static class EmptyInheritableMetadata implements InheritableMetadata {

private EmptyInheritableMetadata() {}
private EmptyInheritableMetadata() {
}

@Override
public <F extends ContentFile<F>> ManifestEntry<F> apply(ManifestEntry<F> manifestEntry) {
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/iceberg/LocationProviders.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

public class LocationProviders {

private LocationProviders() {}
private LocationProviders() {
}

public static LocationProvider locationsFor(String location, Map<String, String> properties) {
if (PropertyUtil.propertyAsBoolean(properties,
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/iceberg/MetricsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public class MetricsConfig implements Serializable {
private Map<String, MetricsMode> columnModes = Maps.newHashMap();
private MetricsMode defaultMode;

private MetricsConfig() {}
private MetricsConfig() {
}

public static MetricsConfig getDefault() {
MetricsConfig spec = new MetricsConfig();
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/java/org/apache/iceberg/MetricsModes.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public class MetricsModes {

private static final Pattern TRUNCATE = Pattern.compile("truncate\\((\\d+)\\)");

private MetricsModes() {}
private MetricsModes() {
}

public static MetricsMode fromString(String mode) {
if ("none".equalsIgnoreCase(mode)) {
Expand All @@ -55,7 +56,8 @@ public static MetricsMode fromString(String mode) {
throw new IllegalArgumentException("Invalid metrics mode: " + mode);
}

public interface MetricsMode extends Serializable {}
public interface MetricsMode extends Serializable {
}

/**
* Under this mode, value_counts, null_value_counts, lower_bounds, upper_bounds are not persisted.
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/iceberg/SchemaParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@

public class SchemaParser {

private SchemaParser() {}
private SchemaParser() {
}

private static final String TYPE = "type";
private static final String STRUCT = "struct";
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/iceberg/SnapshotParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@

public class SnapshotParser {

private SnapshotParser() {}
private SnapshotParser() {
}

private static final String SEQUENCE_NUMBER = "sequence-number";
private static final String SNAPSHOT_ID = "snapshot-id";
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/iceberg/SystemProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
*/
public class SystemProperties {

private SystemProperties() {}
private SystemProperties() {
}

/**
* Sets the size of the worker pool. The worker pool limits the number of tasks concurrently
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public static Codec fromFileName(String fileName) {
}
}

private TableMetadataParser() {}
private TableMetadataParser() {
}

// visible for testing
static final String FORMAT_VERSION = "format-version";
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/iceberg/TableProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

public class TableProperties {

private TableProperties() {}
private TableProperties() {
}

public static final String COMMIT_NUM_RETRIES = "commit.retry.num-retries";
public static final int COMMIT_NUM_RETRIES_DEFAULT = 4;
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/iceberg/Transactions.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;

public final class Transactions {
private Transactions() {}
private Transactions() {
}

public static Transaction createOrReplaceTableTransaction(
String tableName, TableOperations ops, TableMetadata start) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@

public class AvroSchemaUtil {

private AvroSchemaUtil() {}
private AvroSchemaUtil() {
}

// Original Iceberg field name corresponding to a sanitized Avro name
public static final String ICEBERG_FIELD_NAME_PROP = "iceberg-field-name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public class DecoderResolver {
private static final ThreadLocal<Map<Schema, Map<Schema, ResolvingDecoder>>> DECODER_CACHES =
ThreadLocal.withInitial(() -> new MapMaker().weakKeys().makeMap());

private DecoderResolver() {}
private DecoderResolver() {
}

public static <T> T resolveAndRead(
Decoder decoder, Schema readSchema, Schema fileSchema, ValueReader<T> reader, T reuse) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ public static EncryptedOutputFile encryptedOutput(OutputFile encryptedOutputFile
return encryptedOutput(encryptedOutputFile, BaseEncryptionKeyMetadata.fromByteArray(keyMetadata));
}

private EncryptedFiles() {}
private EncryptedFiles() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ public static EncryptionKeyMetadata of(byte[] keyMetadata) {
return BaseEncryptionKeyMetadata.fromByteArray(keyMetadata);
}

private EncryptionKeyMetadatas() {}
private EncryptionKeyMetadatas() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
*/
class HadoopStreams {

private HadoopStreams() {}
private HadoopStreams() {
}

private static final Logger LOG = LoggerFactory.getLogger(HadoopStreams.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public class HiddenPathFilter implements PathFilter {

private static final HiddenPathFilter INSTANCE = new HiddenPathFilter();

private HiddenPathFilter() {}
private HiddenPathFilter() {
}

public static HiddenPathFilter get() {
return INSTANCE;
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/iceberg/util/ByteBuffers.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ public static ByteBuffer copy(ByteBuffer buffer) {
return ByteBuffer.wrap(copyArray);
}

private ByteBuffers() {}
private ByteBuffers() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

public class ExceptionUtil {

private ExceptionUtil() {}
private ExceptionUtil() {
}

@SuppressWarnings("unchecked")
static <E extends Exception> void castAndThrow(
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/iceberg/util/JsonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

public class JsonUtil {

private JsonUtil() {}
private JsonUtil() {
}

private static final JsonFactory FACTORY = new JsonFactory();
private static final ObjectMapper MAPPER = new ObjectMapper(FACTORY);
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/iceberg/util/PropertyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

public class PropertyUtil {

private PropertyUtil() {}
private PropertyUtil() {
}

public static boolean propertyAsBoolean(Map<String, String> properties,
String property, boolean defaultValue) {
Expand Down
Loading