-
Notifications
You must be signed in to change notification settings - Fork 49
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
Enable Nullaway #988
Enable Nullaway #988
Changes from 2 commits
a65e205
f4bfe2c
2ff0e2b
d1e2c53
bb18ad9
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type: improvement | ||
improvement: | ||
description: Enable Nullaway | ||
links: | ||
- https://github.com/palantir/palantir-java-format/pull/988 |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -28,6 +28,8 @@ | |||||
import java.util.Arrays; | ||||||
import java.util.LinkedHashMap; | ||||||
import java.util.Map; | ||||||
import java.util.Map.Entry; | ||||||
import java.util.Optional; | ||||||
import java.util.concurrent.ExecutionException; | ||||||
import java.util.concurrent.ExecutorService; | ||||||
import java.util.concurrent.Executors; | ||||||
|
@@ -130,7 +132,7 @@ private int formatFiles(CommandLineOptions parameters, JavaFormatterOptions opti | |||||
} | ||||||
} | ||||||
|
||||||
for (Map.Entry<Path, Future<String>> result : results.entrySet()) { | ||||||
for (Entry<Path, Future<String>> result : results.entrySet()) { | ||||||
Path path = result.getKey(); | ||||||
String formatted; | ||||||
try { | ||||||
|
@@ -145,8 +147,11 @@ private int formatFiles(CommandLineOptions parameters, JavaFormatterOptions opti | |||||
errWriter.println(path + ":" + diagnostic.toString()); | ||||||
} | ||||||
} else { | ||||||
errWriter.println(path + ": error: " + e.getCause().getMessage()); | ||||||
e.getCause().printStackTrace(errWriter); | ||||||
errWriter.println(path + ": error: " | ||||||
+ Optional.ofNullable(e.getCause()) | ||||||
.map(Throwable::getMessage) | ||||||
.orElse("null")); | ||||||
Optional.ofNullable(e.getCause()).ifPresent(cause -> cause.printStackTrace(errWriter)); | ||||||
} | ||||||
allOk = false; | ||||||
continue; | ||||||
|
@@ -215,10 +220,10 @@ public static CommandLineOptions processArgs(String... args) throws UsageExcepti | |||||
try { | ||||||
parameters = CommandLineOptionsParser.parse(Arrays.asList(args)); | ||||||
} catch (IllegalArgumentException e) { | ||||||
throw new UsageException(e.getMessage()); | ||||||
throw new UsageException(Optional.ofNullable(e.getMessage()).orElse("null")); | ||||||
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 don't think we need to change this, but in other types of hot paths
Suggested change
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. Thanks for sharing -- I've needed this before and its good to know a way to do this without the allocation |
||||||
} catch (Throwable t) { | ||||||
t.printStackTrace(); | ||||||
throw new UsageException(t.getMessage()); | ||||||
throw new UsageException(Optional.ofNullable(t.getMessage()).orElse("null")); | ||||||
} | ||||||
int filesToFormat = parameters.files().size(); | ||||||
if (parameters.stdin()) { | ||||||
|
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.
Was this intentional? I'm surprised this didn't trigger error-prone BadImport
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.
"Entry"
isn't on BadImport's list: https://github.com/google/error-prone/blob/4165ecdc3d11a41b989d08e324de6fbc944e95ae/core/src/main/java/com/google/errorprone/bugpatterns/BadImport.java#L73-L84Maybe it should be?
Fixed
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.
Wow, looks like Entry was removed from the BadImport list 3 years ago, but my brain has already been conditioned to qualify Entry.
google/error-prone@38a0e4b