Skip to content

Commit

Permalink
increase severity of multiple errorprone checks (#6800)
Browse files Browse the repository at this point in the history
  • Loading branch information
XN137 committed May 12, 2023
1 parent d54bcdf commit 46a3d76
Show file tree
Hide file tree
Showing 23 changed files with 99 additions and 118 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 @@ -60,11 +60,9 @@
import org.projectnessie.model.ContentKey;
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 @@ -121,8 +119,7 @@ Stream<EntriesResponse.Entry> entries(Function<GetEntriesBuilder, GetEntriesBuil
}

@SuppressWarnings("deprecation")
Stream<LogResponse.LogEntry> commitLog(
Function<GetCommitLogBuilder, GetCommitLogBuilder> configurer)
Stream<LogEntry> commitLog(Function<GetCommitLogBuilder, GetCommitLogBuilder> configurer)
throws NessieNotFoundException {
if (version.isGreaterThan(Version.parseVersion("0.30.0"))) {
return configurer.apply(api.getCommitLog()).stream();
Expand All @@ -132,8 +129,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 @@ -217,7 +214,7 @@ void commitLog() throws NessieNotFoundException {
.allSatisfy(
ref -> {
String versionFromRef = ref.getName().substring(VERSION_BRANCH_PREFIX.length());
Stream<LogResponse.LogEntry> commitLog = commitLog(b -> b.refName(ref.getName()));
Stream<LogEntry> commitLog = commitLog(b -> b.refName(ref.getName()));
String commitMessage = "hello world " + versionFromRef;
assertThat(commitLog)
.hasSize(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Status status() {
@Override
@Value.Auxiliary
public Schema getSchema() {
Types.StructType fileSchema = MockManifestFile.fileType(partitionType());
StructType fileSchema = MockManifestFile.fileType(partitionType());
return AvroSchemaUtil.convert(
new org.apache.iceberg.Schema(
STATUS, SNAPSHOT_ID, SEQUENCE_NUMBER, required(DATA_FILE_ID, "data_file", fileSchema)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.apache.iceberg.avro.AvroSchemaUtil;
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;

Expand Down Expand Up @@ -193,11 +192,11 @@ public void write(OutputFile output) {
}
}

static org.apache.iceberg.Schema entrySchema(Types.StructType partitionType) {
static org.apache.iceberg.Schema entrySchema(StructType partitionType) {
return wrapFileSchema(fileType(partitionType));
}

static org.apache.iceberg.Schema wrapFileSchema(Types.StructType fileSchema) {
static org.apache.iceberg.Schema wrapFileSchema(StructType fileSchema) {
// this is used to build projection schemas
return new org.apache.iceberg.Schema(
MockManifestEntry.STATUS,
Expand All @@ -206,8 +205,8 @@ static org.apache.iceberg.Schema wrapFileSchema(Types.StructType fileSchema) {
required(MockManifestEntry.DATA_FILE_ID, "data_file", fileSchema));
}

static Types.StructType fileType(Types.StructType partitionType) {
return Types.StructType.of(
static StructType fileType(StructType partitionType) {
return StructType.of(
DataFile.CONTENT.asRequired(),
DataFile.FILE_PATH,
DataFile.FILE_FORMAT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.projectnessie.model.ImmutableCommitMeta;
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;
Expand Down Expand Up @@ -299,14 +298,13 @@ protected List<SparkCommitLogEntry> commitAndReturnLog(String branch, String ini
content != null
? ImmutableOperations.builder()
.addOperations(
Operation.Put.of(
key, IcebergTable.of("foo", 42, 42, 42, 42, content.getId()), content))
Put.of(key, IcebergTable.of("foo", 42, 42, 42, 42, content.getId()), content))
.commitMeta(cm1)
.build()
: ImmutableOperations.builder()
.addOperations(
Operation.Put.of(ContentKey.of("table"), Namespace.of("table")),
Operation.Put.of(key, IcebergTable.of("foo", 42, 42, 42, 42)))
Put.of(ContentKey.of("table"), Namespace.of("table")),
Put.of(key, IcebergTable.of("foo", 42, 42, 42, 42)))
.commitMeta(cm1)
.build();

Expand All @@ -323,8 +321,7 @@ protected List<SparkCommitLogEntry> commitAndReturnLog(String branch, String ini
Operations ops2 =
ImmutableOperations.builder()
.addOperations(
Operation.Put.of(
key, IcebergTable.of("bar", 42, 42, 42, 42, content.getId()), content))
Put.of(key, IcebergTable.of("bar", 42, 42, 42, 42, content.getId()), content))
.commitMeta(cm2)
.build();

Expand All @@ -341,8 +338,7 @@ protected List<SparkCommitLogEntry> commitAndReturnLog(String branch, String ini
Operations ops3 =
ImmutableOperations.builder()
.addOperations(
Operation.Put.of(
key, IcebergTable.of("baz", 42, 42, 42, 42, content.getId()), content))
Put.of(key, IcebergTable.of("baz", 42, 42, 42, 42, content.getId()), content))
.commitMeta(cm3)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ public void commitMergeTransplant() throws Exception {
.hasSize(4);

soft.assertThat(api().getEntries().reference(branch).get().getEntries())
.extracting(EntriesResponse.Entry::getName)
.extracting(Entry::getName)
.containsExactlyInAnyOrder(
ContentKey.of("a"),
ContentKey.of("b"),
Expand All @@ -481,7 +481,7 @@ public void commitMergeTransplant() throws Exception {

soft.assertThat(api().getCommitLog().refName(main.getName()).get().getLogEntries()).hasSize(2);
soft.assertThat(api().getEntries().reference(main).get().getEntries())
.extracting(EntriesResponse.Entry::getName)
.extracting(Entry::getName)
.containsExactly(ContentKey.of("a"), ContentKey.of("b"));

Reference main2;
Expand Down Expand Up @@ -528,7 +528,7 @@ public void commitMergeTransplant() throws Exception {
}

soft.assertThat(api().getEntries().reference(main2).get().getEntries())
.extracting(EntriesResponse.Entry::getName)
.extracting(Entry::getName)
.containsExactlyInAnyOrder(
ContentKey.of("a"),
ContentKey.of("b"),
Expand All @@ -537,7 +537,7 @@ public void commitMergeTransplant() throws Exception {
ContentKey.of("b", "b"));

soft.assertThat(api().getEntries().reference(otherBranch).get().getEntries())
.extracting(EntriesResponse.Entry::getName)
.extracting(Entry::getName)
.containsExactly(ContentKey.of("a"), ContentKey.of("b"));
api()
.transplantCommitsIntoBranch()
Expand All @@ -546,7 +546,7 @@ public void commitMergeTransplant() throws Exception {
.branch(otherBranch)
.transplant();
soft.assertThat(api().getEntries().refName(otherBranch.getName()).get().getEntries())
.extracting(EntriesResponse.Entry::getName)
.extracting(Entry::getName)
.containsExactlyInAnyOrder(
ContentKey.of("a"),
ContentKey.of("b"),
Expand Down Expand Up @@ -962,15 +962,15 @@ public void entries() throws Exception {
if (isV2()) {
soft.assertThat(response.getEffectiveReference()).isEqualTo(main);
soft.assertThat(response.getEntries())
.extracting(EntriesResponse.Entry::getContent)
.extracting(Entry::getContent)
.doesNotContainNull()
.isNotEmpty();
}
List<EntriesResponse.Entry> notPaged = response.getEntries();
List<Entry> notPaged = response.getEntries();
soft.assertThat(notPaged).hasSize(10);

if (pagingSupported(api().getEntries())) {
List<EntriesResponse.Entry> all = new ArrayList<>();
List<Entry> all = new ArrayList<>();
String token = null;
for (int i = 0; i < 10; i++) {
EntriesResponse resp =
Expand Down Expand Up @@ -1371,7 +1371,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

0 comments on commit 46a3d76

Please sign in to comment.