-
Notifications
You must be signed in to change notification settings - Fork 332
fix and enforce more errorprone checks #1663
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,6 @@ | |
| package org.apache.polaris.service.types; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Locale; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
| import java.util.stream.Collectors; | ||
|
|
@@ -84,9 +83,9 @@ public static Optional<NotificationType> lookupByName(String name) { | |
| return Optional.empty(); | ||
| } | ||
|
|
||
| for (NotificationType NotificationType : NotificationType.values()) { | ||
| if (name.toUpperCase(Locale.ROOT).equals(NotificationType.name())) { | ||
| return Optional.of(NotificationType); | ||
| for (NotificationType notificationType : NotificationType.values()) { | ||
| if (name.equalsIgnoreCase(notificationType.name())) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this flagged by ErrorProne or collateral?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. collateral as i thought it didnt make sense to always call uppercase inside the loop. |
||
| return Optional.of(notificationType); | ||
| } | ||
| } | ||
| return Optional.empty(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,6 +227,12 @@ UseCorrectAssertInTests=ERROR | |
| ConstantPatternCompile=ERROR | ||
| # Variables initialized with Pattern#compile calls on constants can be constants | ||
|
|
||
| ObjectsHashCodePrimitive=ERROR | ||
| # Objects.hashCode(Object o) should not be passed a primitive value | ||
|
|
||
| OptionalMapToOptional=ERROR | ||
| # Mapping to another Optional will yield a nested Optional. Did you mean flatMap? | ||
|
Comment on lines
+233
to
+234
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only one I'm not so sure about. The bug you found looks real to me, but this is a legit pattern and I'm a bit wary of disallowing it
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The need for nested
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @dimas-b; and in the unlikely case where there is a compelling reason to have |
||
|
|
||
| PrimitiveArrayPassedToVarargsMethod=ERROR | ||
| # Passing a primitive array to a varargs method is usually wrong | ||
|
|
||
|
|
@@ -239,6 +245,9 @@ RedundantThrows=ERROR | |
| 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.) | ||
|
|
||
| StringCharset=ERROR | ||
| # Prefer StandardCharsets over using string names for charsets | ||
|
|
||
| StronglyTypeByteString=WARN | ||
| # This primitive byte array is only used to construct ByteStrings. It would be clearer to strongly type the field instead. | ||
|
|
||
|
|
@@ -254,6 +263,9 @@ TransientMisuse=ERROR | |
| UrlInSee=ERROR | ||
| # URLs should not be used in @see tags; they are designed for Java elements which could be used with @link. | ||
|
|
||
| VariableNameSameAsType=ERROR | ||
| # variableName and type with the same name would refer to the static field instead of the class | ||
|
|
||
| #################################################################################################### | ||
| # Experimental : SUGGESTION | ||
| # See https://errorprone.info/bugpatterns | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,6 @@ | |
| import jakarta.annotation.Nonnull; | ||
| import java.util.EnumMap; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
| import java.util.Set; | ||
| import org.apache.polaris.core.PolarisDiagnostics; | ||
|
|
||
|
|
@@ -129,7 +128,7 @@ public boolean equals(Object o) { | |
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hashCode(success); | ||
| return Boolean.hashCode(success); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just wondering: the class seems to intentionally exclude the |
||
| } | ||
|
|
||
| @Override | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -151,7 +151,7 @@ public ProductionReadinessCheck checkTokenBrokers( | |||||||||||||||||||||||||
| if (config | ||||||||||||||||||||||||||
| .tokenBroker() | ||||||||||||||||||||||||||
| .symmetricKey() | ||||||||||||||||||||||||||
| .map(SymmetricKeyConfiguration::secret) | ||||||||||||||||||||||||||
| .flatMap(SymmetricKeyConfiguration::secret) | ||||||||||||||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking at Lines 73 to 84 in e1c0a1c
this might actually be a bug fix in that previously any symmetricKey was flagged as an error?i.e. this line was checking Optional.of(Optional.empty()).isPresent() when the SymmetricKeyConfiguration is file-based.
|
||||||||||||||||||||||||||
| .isPresent()) { | ||||||||||||||||||||||||||
| errors.add( | ||||||||||||||||||||||||||
| Error.of( | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the
lookupByNamemethod seems completely unused, so we could also just remove it instead afaict.same applies to the
displayNamefield (whose value is always the same asname())