Skip to content

Commit

Permalink
increase severity of multiple errorprone checks
Browse files Browse the repository at this point in the history
note that we fix DifferentNameButSame with a minimal diff, but
not make it uniform across all files
  • Loading branch information
XN137 committed May 11, 2023
1 parent 744a7e3 commit 8dbe771
Show file tree
Hide file tree
Showing 23 changed files with 70 additions and 79 deletions.
46 changes: 26 additions & 20 deletions codestyle/errorprone-rules.properties
Original file line number Diff line number Diff line change
Expand Up @@ -966,10 +966,10 @@ MissingOverride=ERROR
#MixedMutabilityReturnType=WARN
# This method returns both mutable and immutable collections or maps from different paths. This may be confusing for users of the method.

#ModifiedButNotUsed=WARN
ModifiedButNotUsed=ERROR
# A collection or proto builder was created, but its values were never accessed.

#MockNotUsedInProduction=WARN
MockNotUsedInProduction=ERROR
# This mock is instantiated and configured, but is never passed to production code. It should be
# either removed or used.

Expand Down Expand Up @@ -1000,16 +1000,19 @@ MissingOverride=ERROR
#NestedInstanceOfConditions=WARN
# Nested instanceOf conditions of disjoint types create blocks of code that never execute

#NonAtomicVolatileUpdate=WARN
NonAtomicVolatileUpdate=ERROR
# This update of a volatile variable is non-atomic

#NonCanonicalType=WARN
NonCanonicalType=ERROR
# This type is referred to by a non-canonical name, which may be misleading.

#NonOverridingEquals=WARN
# equals method doesn't override Object.equals

#NullOptional=WARN
NotJavadoc=ERROR
# Avoid using /** for comments which aren't actually Javadoc.

NullOptional=ERROR
# Passing a literal null to an Optional parameter is almost certainly a mistake. Did you mean to provide an empty Optional?

#NullableConstructor=WARN
Expand Down Expand Up @@ -1222,10 +1225,10 @@ UnnecessaryLambda=ERROR
UnusedMethod=ERROR
# Unused.

#UnusedNestedClass=WARN
UnusedNestedClass=ERROR
# This nested class is unused, and can be removed.

#UnusedTypeParameter=WARN
UnusedTypeParameter=ERROR
# This type parameter is unused and can be removed.

#UnusedVariable=WARN
Expand Down Expand Up @@ -1349,10 +1352,10 @@ UseCorrectAssertInTests=ERROR
#CheckedExceptionNotThrown=WARN
# This method cannot throw a checked exception that it claims to. This may cause consumers of the API to incorrectly attempt to handle, or propagate, this exception.

ConstantPatternCompile=WARN
ConstantPatternCompile=ERROR
# Variables initialized with Pattern#compile calls on constants can be constants

#DifferentNameButSame=WARN
DifferentNameButSame=ERROR
# This type is referred to in different ways within this file, which may be confusing.

#EqualsBrokenForNull=WARN
Expand Down Expand Up @@ -1415,7 +1418,7 @@ ConstantPatternCompile=WARN
#PreferredInterfaceType=WARN
# This type can be more specific.

PrimitiveArrayPassedToVarargsMethod=WARN
PrimitiveArrayPassedToVarargsMethod=ERROR
# Passing a primitive array to a varargs method is usually wrong

#QualifierWithTypeUse=WARN
Expand All @@ -1427,10 +1430,13 @@ RedundantOverride=ERROR
RedundantThrows=ERROR
# Thrown exception is a subtype of another

StringCaseLocaleUsage=ERROR
# Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

StronglyTypeByteString=WARN
# This primitive byte array is only used to construct ByteStrings. It would be clearer to strongly type the field instead.

StronglyTypeTime=WARN
StronglyTypeTime=ERROR
# This primitive integral type is only used to construct time types. It would be clearer to strongly type the field instead.

#SuppressWarningsWithoutExplanation=WARN
Expand All @@ -1442,7 +1448,7 @@ StronglyTypeTime=WARN
#SystemOut=WARN
# Printing to standard output should only be used for debugging, not in production code

#TestExceptionChecker=WARN
TestExceptionChecker=ERROR
# Using @Test(expected=…) is discouraged, since the test will pass if any statement in the test method throws the expected exception

#ThrowSpecificExceptions=WARN
Expand All @@ -1454,7 +1460,7 @@ StronglyTypeTime=WARN
#TooManyParameters=WARN
# A large number of parameters on public APIs should be avoided.

#TransientMisuse=WARN
TransientMisuse=ERROR
# Static fields are implicitly transient, so the explicit modifier is unnecessary

#TryWithResourcesVariable=WARN
Expand Down Expand Up @@ -1484,7 +1490,7 @@ StronglyTypeTime=WARN
#UnusedException=WARN
# This catch block catches an exception and re-throws another, but swallows the caught exception rather than setting it as a cause. This can make debugging harder.

#UrlInSee=WARN
UrlInSee=ERROR
# URLs should not be used in @see tags; they are designed for Java elements which could be used with @link.

#UsingJsr305CheckReturnValue=WARN
Expand Down Expand Up @@ -1525,13 +1531,13 @@ StronglyTypeTime=WARN
#FieldCanBeLocal=WARN
# This field can be replaced with a local variable in the methods that use it.

#FieldCanBeStatic=WARN
FieldCanBeStatic=ERROR
# A final field initialized at compile-time with an instance of an immutable type can be static.

#FieldMissingNullable=WARN
# Field is assigned (or compared against) a definitely null value but is not annotated @Nullable

#ForEachIterable=WARN
ForEachIterable=ERROR
# This loop can be replaced with an enhanced for loop.

#ImmutableMemberCollection=WARN
Expand All @@ -1555,7 +1561,7 @@ StronglyTypeTime=WARN
#MissingBraces=WARN
# The Google Java Style Guide requires braces to be used with if, else, for, do and while statements, even when the body is empty or contains only a single statement.

#MixedArrayDimensions=WARN
MixedArrayDimensions=ERROR
# C-style array declarations should not be used

#MultiVariableDeclaration=WARN
Expand All @@ -1564,7 +1570,7 @@ StronglyTypeTime=WARN
#MultipleTopLevelClasses=WARN
# Source files should not contain multiple top-level class declarations

#PackageLocation=WARN
PackageLocation=ERROR
# Package names should match the directory they are declared in

#ParameterComment=WARN
Expand Down Expand Up @@ -1603,7 +1609,7 @@ StronglyTypeTime=WARN
#ThrowsUncheckedException=WARN
# Unchecked exceptions do not need to be declared in the method signature.

TryFailRefactoring=WARN
TryFailRefactoring=ERROR
# Prefer assertThrows to try/fail

#TypeParameterNaming=WARN
Expand All @@ -1627,7 +1633,7 @@ UnnecessaryBoxedVariable=ERROR
#UnnecessaryStaticImport=WARN
# Using static imports for types is unnecessary

UseEnumSwitch=WARN
UseEnumSwitch=ERROR
# Prefer using a switch instead of a chained if-else for enums

#VoidMissingNullable=WARN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.projectnessie.model.Content;
import org.projectnessie.model.ContentKey;
import org.projectnessie.model.IcebergTable;
import org.projectnessie.model.LogResponse;
import org.projectnessie.model.LogResponse.LogEntry;
import org.projectnessie.model.MergeBehavior;
import org.projectnessie.model.MergeResponse;
Expand Down Expand Up @@ -88,8 +87,7 @@ Stream<Reference> allReferences() throws NessieNotFoundException {
}

@SuppressWarnings("deprecation")
Stream<LogResponse.LogEntry> commitLog(
Function<GetCommitLogBuilder, GetCommitLogBuilder> configurer)
Stream<LogEntry> commitLog(Function<GetCommitLogBuilder, GetCommitLogBuilder> configurer)
throws NessieNotFoundException {
if (getClientVersion().isGreaterThanOrEqual(Version.CLIENT_RESULTS_NATIVE_STREAM)) {
return configurer.apply(api.getCommitLog()).stream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
import org.projectnessie.model.EntriesResponse;
import org.projectnessie.model.IcebergTable;
import org.projectnessie.model.LogResponse;
import org.projectnessie.model.LogResponse.LogEntry;
import org.projectnessie.model.Operation.Delete;
import org.projectnessie.model.Operation.Put;
import org.projectnessie.model.RefLogResponse;
import org.projectnessie.model.RefLogResponse.RefLogResponseEntry;
import org.projectnessie.model.Reference;
import org.projectnessie.tools.compatibility.api.NessieAPI;
Expand Down Expand Up @@ -132,8 +130,8 @@ Stream<LogResponse.LogEntry> commitLog(
}

@SuppressWarnings("deprecation")
Stream<RefLogResponse.RefLogResponseEntry> refLog(
Function<GetRefLogBuilder, GetRefLogBuilder> configurer) throws NessieNotFoundException {
Stream<RefLogResponseEntry> refLog(Function<GetRefLogBuilder, GetRefLogBuilder> configurer)
throws NessieNotFoundException {
if (version.isGreaterThan(Version.parseVersion("0.30.0"))) {
return configurer.apply(api.getRefLog()).stream();
} else {
Expand Down Expand Up @@ -221,7 +219,7 @@ void commitLog() throws NessieNotFoundException {
String commitMessage = "hello world " + versionFromRef;
assertThat(commitLog)
.hasSize(1)
.map(LogEntry::getCommitMeta)
.map(LogResponse.LogEntry::getCommitMeta)
.map(CommitMeta::getMessage)
.containsExactly(commitMessage);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.iceberg.BridgeToIceberg;
import org.apache.iceberg.avro.AvroSchemaUtil;
import org.apache.iceberg.types.Types;
import org.apache.iceberg.types.Types.StructType;
import org.immutables.value.Value;

@Value.Immutable
Expand All @@ -51,7 +50,7 @@ public Status status() {

public abstract String filePath();

public abstract StructType partitionType();
public abstract Types.StructType partitionType();

// ids for data-file columns are assigned from 1000
static final Types.NestedField STATUS = required(0, "status", Types.IntegerType.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.apache.iceberg.io.FileAppender;
import org.apache.iceberg.io.OutputFile;
import org.apache.iceberg.types.Types;
import org.apache.iceberg.types.Types.StructType;
import org.immutables.value.Value;

@Value.Immutable
Expand Down Expand Up @@ -143,7 +142,7 @@ public List<MockManifestEntry> manifestEntries() {
MockPartitionSpec mockPartitionSpec = mockTableMeta.partitionSpec(0);
org.apache.iceberg.Schema icebergSchema = mockTableMeta.schema(0).toSchema();
PartitionSpec partitionSpec = mockPartitionSpec.toPartitionSpec(icebergSchema);
StructType partitionType = partitionSpec.partitionType();
Types.StructType partitionType = partitionSpec.partitionType();

return IntStream.range(0, numEntries())
.mapToObj(
Expand All @@ -164,7 +163,7 @@ public void write(OutputFile output) {
MockPartitionSpec mockPartitionSpec = mockTableMeta.partitionSpec(0);
org.apache.iceberg.Schema icebergSchema = mockTableMeta.schema(0).toSchema();
PartitionSpec partitionSpec = mockPartitionSpec.toPartitionSpec(icebergSchema);
StructType partitionType = partitionSpec.partitionType();
Types.StructType partitionType = partitionSpec.partitionType();

try {
String partitionSpecJson = PartitionSpecParser.toJson(partitionSpec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
import org.projectnessie.model.ImmutableOperations;
import org.projectnessie.model.Namespace;
import org.projectnessie.model.Operation;
import org.projectnessie.model.Operation.Delete;
import org.projectnessie.model.Operation.Put;
import org.projectnessie.model.Operations;
import org.projectnessie.model.Reference;
import org.projectnessie.model.Tag;
Expand Down Expand Up @@ -107,13 +105,14 @@ protected void setupSparkAndApi(TestInfo testInfo)
api.commitMultipleOperations()
.branch(initialDefaultBranch)
.commitMeta(CommitMeta.fromMessage("INFRA: initial commit"))
.operation(Put.of(ContentKey.of("dummy"), IcebergTable.of("foo", 1, 2, 3, 4)))
.operation(
Operation.Put.of(ContentKey.of("dummy"), IcebergTable.of("foo", 1, 2, 3, 4)))
.commit();
initialDefaultBranch =
api.commitMultipleOperations()
.branch(initialDefaultBranch)
.commitMeta(CommitMeta.fromMessage("INFRA: common ancestor"))
.operation(Delete.of(ContentKey.of("dummy")))
.operation(Operation.Delete.of(ContentKey.of("dummy")))
.commit();
first = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
import org.projectnessie.model.DiffResponse;
import org.projectnessie.model.DiffResponse.DiffEntry;
import org.projectnessie.model.EntriesResponse;
import org.projectnessie.model.EntriesResponse.Entry;
import org.projectnessie.model.GetMultipleContentsResponse;
import org.projectnessie.model.GetNamespacesResponse;
import org.projectnessie.model.IcebergTable;
Expand Down Expand Up @@ -1371,7 +1370,7 @@ public void commitLogForNamelessReference() throws BaseNessieClientServerExcepti
branch = prepCommit(branch, "c-" + i, dummyPut("c", Integer.toString(i))).commit();
}
}
List<LogResponse.LogEntry> log =
List<LogEntry> log =
api().getCommitLog().hashOnRef(branch.getHash()).stream().collect(Collectors.toList());
// Verifying size is sufficient to make sure the right log was retrieved
assertThat(log).hasSize(5);
Expand Down Expand Up @@ -1440,7 +1439,8 @@ public void fetchEntriesByNamelessReference() throws BaseNessieClientServerExcep
.operation(Put.of(b, tb))
.commitMeta(CommitMeta.fromMessage("commit 1"))
.commit();
List<Entry> entries = api().getEntries().hashOnRef(branch.getHash()).get().getEntries();
List<EntriesResponse.Entry> entries =
api().getEntries().hashOnRef(branch.getHash()).get().getEntries();
soft.assertThat(entries)
.map(e -> immutableEntry(e.getName(), e.getType()))
.containsExactlyInAnyOrder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
import javax.ws.rs.ext.ParamConverter;
import javax.ws.rs.ext.ParamConverterProvider;
import javax.ws.rs.ext.Provider;
import org.projectnessie.model.Reference;
import org.projectnessie.model.Reference.ReferenceType;

/**
* Provider for {@link ReferenceTypeParamConverter}, to convert between lower-case representations
* of {@link Reference.ReferenceType} in REST paths and upper-case in the Java enum..
* of {@link ReferenceType} in REST paths and upper-case in the Java enum..
*/
@Provider
public class ReferenceTypeParamConverterProvider implements ParamConverterProvider {
Expand All @@ -37,7 +36,7 @@ public class ReferenceTypeParamConverterProvider implements ParamConverterProvid
@Override
public <T> ParamConverter<T> getConverter(
Class<T> rawType, Type genericType, Annotation[] annotations) {
if (rawType == Reference.ReferenceType.class) {
if (rawType == ReferenceType.class) {
@SuppressWarnings("unchecked")
ParamConverter<T> r = (ParamConverter<T>) REFERENCE_TYPE_PARAM_CONVERTER;
return r;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static NamedRef toNamedRef(@Nonnull @jakarta.annotation.Nonnull Reference
}

public static NamedRef toNamedRef(
@Nonnull @jakarta.annotation.Nonnull Reference.ReferenceType referenceType,
@Nonnull @jakarta.annotation.Nonnull ReferenceType referenceType,
@Nonnull @jakarta.annotation.Nonnull String referenceName) {
Objects.requireNonNull(referenceType, "referenceType must not be null");
switch (referenceType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
import org.projectnessie.model.ContentKey;
import org.projectnessie.model.Detached;
import org.projectnessie.model.EntriesResponse;
import org.projectnessie.model.EntriesResponse.Entry;
import org.projectnessie.model.FetchOption;
import org.projectnessie.model.ImmutableCommitMeta;
import org.projectnessie.model.ImmutableCommitResponse;
Expand All @@ -92,7 +91,6 @@
import org.projectnessie.model.Operation;
import org.projectnessie.model.Operations;
import org.projectnessie.model.Reference;
import org.projectnessie.model.Reference.ReferenceType;
import org.projectnessie.model.ReferenceMetadata;
import org.projectnessie.model.Tag;
import org.projectnessie.model.Validation;
Expand Down Expand Up @@ -327,7 +325,7 @@ public Reference assignReference(

@Override
public Reference deleteReference(
ReferenceType referenceType, String referenceName, String expectedHash)
Reference.ReferenceType referenceType, String referenceName, String expectedHash)
throws NessieConflictException, NessieNotFoundException {
try {
ReferenceInfo<CommitMeta> resolved =
Expand Down Expand Up @@ -780,7 +778,7 @@ public <R> R getEntries(
String filter,
String pagingToken,
boolean withContent,
PagedResponseHandler<R, Entry> pagedResponseHandler,
PagedResponseHandler<R, EntriesResponse.Entry> pagedResponseHandler,
Consumer<WithHash<NamedRef>> effectiveReference)
throws NessieNotFoundException {
WithHash<NamedRef> refWithHash = namedRefWithHashOrThrow(namedRef, hashOnRef);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.projectnessie.model.MergeResponse;
import org.projectnessie.model.Operations;
import org.projectnessie.model.Reference;
import org.projectnessie.model.Reference.ReferenceType;
import org.projectnessie.model.Validation;
import org.projectnessie.versioned.NamedRef;
import org.projectnessie.versioned.WithHash;
Expand Down Expand Up @@ -121,7 +120,7 @@ Reference assignReference(
throws NessieNotFoundException, NessieConflictException;

Reference deleteReference(
ReferenceType referenceType,
Reference.ReferenceType referenceType,
@Valid
@jakarta.validation.Valid
@NotNull
Expand Down

0 comments on commit 8dbe771

Please sign in to comment.