diff --git a/build.gradle b/build.gradle index 830e2edf..1bf741b9 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ buildscript { classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.50.0' classpath 'com.palantir.gradle.revapi:gradle-revapi:1.8.0' classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.50.0' + classpath 'com.palantir.suppressible-error-prone:gradle-suppressible-error-prone:1.6.0' classpath 'gradle.plugin.org.inferred:gradle-processors:3.7.0' } } diff --git a/idea-plugin/src/main/java/com/palantir/javaformat/intellij/FormatterProvider.java b/idea-plugin/src/main/java/com/palantir/javaformat/intellij/FormatterProvider.java index edffd9f8..8c771189 100644 --- a/idea-plugin/src/main/java/com/palantir/javaformat/intellij/FormatterProvider.java +++ b/idea-plugin/src/main/java/com/palantir/javaformat/intellij/FormatterProvider.java @@ -67,6 +67,7 @@ Optional get(Project project, PalantirJavaFormatSettings setti settings.injectedVersionIsOutdated())); } + @SuppressWarnings("for-rollout:Slf4jLogsafeArgs") private static Optional createFormatter(FormatterCacheKey cacheKey) { if (cacheKey.jdkMajorVersion.isEmpty()) { return Optional.empty(); @@ -107,6 +108,7 @@ private static List getProvidedImplementationUrls(List implementation return implementationClasspath.stream().map(Path::of).collect(Collectors.toList()); } + @SuppressWarnings("for-rollout:Slf4jLogsafeArgs") private static List getBundledImplementationUrls() { // Load from the jars bundled with the plugin. IdeaPluginDescriptor ourPlugin = Preconditions.checkNotNull( @@ -116,6 +118,7 @@ private static List getBundledImplementationUrls() { return listDirAsUrlsUnchecked(implDir); } + @SuppressWarnings("for-rollout:Slf4jLogsafeArgs") private static List getImplementationUrls( Optional> implementationClassPath, boolean useBundledImplementation) { if (useBundledImplementation) { @@ -163,6 +166,7 @@ private static OptionalInt parseSdkJavaVersion(Sdk sdk) { return parseSdkJavaVersion(version); } + @SuppressWarnings("for-rollout:Slf4jLogsafeArgs") @VisibleForTesting static OptionalInt parseSdkJavaVersion(String version) { int indexOfVersionDelimiter = version.indexOf('.'); diff --git a/idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirJavaFormatConfigurable.java b/idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirJavaFormatConfigurable.java index 40e289cc..0dd857bb 100644 --- a/idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirJavaFormatConfigurable.java +++ b/idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirJavaFormatConfigurable.java @@ -40,10 +40,14 @@ class PalantirJavaFormatConfigurable extends BaseConfigurable implements Searcha private final Project project; private JPanel panel; private JCheckBox enable; + + @SuppressWarnings("for-rollout:RawTypes") private JComboBox styleComboBox; + private JLabel formatterVersion; private JLabel pluginVersion; + @SuppressWarnings("for-rollout:NullAway") public PalantirJavaFormatConfigurable(Project project) { this.project = project; } @@ -133,6 +137,7 @@ private void createUIComponents() { * * @noinspection ALL */ + @SuppressWarnings("for-rollout:InvalidBlockTag") private void $$$setupUI$$$() { createUIComponents(); panel = new JPanel(); @@ -281,6 +286,7 @@ private void createUIComponents() { } /** @noinspection ALL */ + @SuppressWarnings({"for-rollout:InvalidBlockTag", "for-rollout:MissingSummary"}) public JComponent $$$getRootComponent$$$() { return panel; } diff --git a/idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirJavaFormatSettings.java b/idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirJavaFormatSettings.java index 4898ab59..a4eec586 100644 --- a/idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirJavaFormatSettings.java +++ b/idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirJavaFormatSettings.java @@ -34,17 +34,20 @@ import java.util.stream.Stream; import javax.annotation.Nullable; +@SuppressWarnings("for-rollout:SameNameButDifferent") @State( name = "PalantirJavaFormatSettings", storages = {@Storage("palantir-java-format.xml")}) class PalantirJavaFormatSettings implements PersistentStateComponent { + @SuppressWarnings("for-rollout:SameNameButDifferent") private State state = new State(); static PalantirJavaFormatSettings getInstance(Project project) { return ServiceManager.getService(project, PalantirJavaFormatSettings.class); } + @SuppressWarnings("for-rollout:SameNameButDifferent") @Nullable @Override public State getState() { @@ -52,7 +55,7 @@ public State getState() { } @Override - public void loadState(State state) { + public void loadState(@SuppressWarnings("for-rollout:SameNameButDifferent") State state) { this.state = state; } @@ -144,6 +147,7 @@ public void setImplementationClassPath(@Nullable List value) { .map(strings -> strings.stream().map(URI::create).collect(Collectors.toList())); } + @SuppressWarnings("for-rollout:NullAway") public List getImplementationClassPath() { return implementationClassPath .map(paths -> paths.stream().map(URI::toString).collect(Collectors.toList())) @@ -161,6 +165,7 @@ public void setEnabled(@Nullable String enabledStr) { } } + @SuppressWarnings("for-rollout:NullAway") public String getEnabled() { switch (enabled) { case ENABLED: diff --git a/palantir-java-format/src/main/java/com/palantir/javaformat/Newlines.java b/palantir-java-format/src/main/java/com/palantir/javaformat/Newlines.java index 825cc84a..2a83ff29 100644 --- a/palantir-java-format/src/main/java/com/palantir/javaformat/Newlines.java +++ b/palantir-java-format/src/main/java/com/palantir/javaformat/Newlines.java @@ -53,6 +53,7 @@ public static int hasNewlineAt(String input, int idx) { } /** Returns the terminating line break in the input, or {@code null} if the input does not end in a break. */ + @SuppressWarnings("for-rollout:NullAway") public static String getLineEnding(String input) { for (String b : BREAKS) { if (input.endsWith(b)) { @@ -158,6 +159,7 @@ private static final class LineIterator implements Iterator { private final String input; private final Iterator indices; + @SuppressWarnings("for-rollout:NullAway") private LineIterator(String input) { this.input = input; this.indices = lineOffsetIterator(input); diff --git a/palantir-java-format/src/main/java/com/palantir/javaformat/doc/LevelDelimitedFlatValueDocVisitor.java b/palantir-java-format/src/main/java/com/palantir/javaformat/doc/LevelDelimitedFlatValueDocVisitor.java index 1ec1b64d..fd3e46b3 100644 --- a/palantir-java-format/src/main/java/com/palantir/javaformat/doc/LevelDelimitedFlatValueDocVisitor.java +++ b/palantir-java-format/src/main/java/com/palantir/javaformat/doc/LevelDelimitedFlatValueDocVisitor.java @@ -53,6 +53,7 @@ public String visitBreak(Break doc) { return sb.toString(); } + @SuppressWarnings("for-rollout:NullAway") @Override public String visitLevel(Level level) { if (level.getFlat().isEmpty()) { diff --git a/palantir-java-format/src/main/java/com/palantir/javaformat/doc/Obs.java b/palantir-java-format/src/main/java/com/palantir/javaformat/doc/Obs.java index 0fcbf7ed..457351e0 100644 --- a/palantir-java-format/src/main/java/com/palantir/javaformat/doc/Obs.java +++ b/palantir-java-format/src/main/java/com/palantir/javaformat/doc/Obs.java @@ -64,6 +64,7 @@ FinishExplorationNode startExplorationNode( String getOutput(); } + @SuppressWarnings("for-rollout:NullAway") public static ExplorationNode createRoot(Sink sink) { return new ExplorationNodeImpl(null, "(initial node)", sink, 0, Optional.empty()); } diff --git a/palantir-java-format/src/main/java/com/palantir/javaformat/java/CommandLineOptionsParser.java b/palantir-java-format/src/main/java/com/palantir/javaformat/java/CommandLineOptionsParser.java index b06f9952..0e2959b4 100644 --- a/palantir-java-format/src/main/java/com/palantir/javaformat/java/CommandLineOptionsParser.java +++ b/palantir-java-format/src/main/java/com/palantir/javaformat/java/CommandLineOptionsParser.java @@ -39,6 +39,7 @@ final class CommandLineOptionsParser { Splitter.on(CharMatcher.breakingWhitespace()).omitEmptyStrings().trimResults(); /** Parses {@link CommandLineOptions}. */ + @SuppressWarnings("for-rollout:NullAway") static CommandLineOptions parse(Iterable options) { CommandLineOptions.Builder optionsBuilder = CommandLineOptions.builder(); List expandedOptions = new ArrayList<>(); diff --git a/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavaInput.java b/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavaInput.java index 4077bb54..fea551af 100644 --- a/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavaInput.java +++ b/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavaInput.java @@ -266,6 +266,7 @@ public String toString() { * @param text the input text * @throws FormatterException if the input cannot be parsed */ + @SuppressWarnings("for-rollout:NullAway") public JavaInput(String text) throws FormatterException { this.text = checkNotNull(text); setLines(ImmutableList.copyOf(Newlines.lineIterator(text))); @@ -344,6 +345,7 @@ private ImmutableList buildToks(String text) throws FormatterException { * @param stopTokens a set of tokens which should cause lexing to stop. If one of these is found, the returned list * will include tokens up to but not including that token. */ + @SuppressWarnings("for-rollout:NullAway") static ImmutableList buildToks(String text, ImmutableSet stopTokens) throws FormatterException { stopTokens = ImmutableSet.builder() .addAll(stopTokens) diff --git a/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java b/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java index b4428c64..e288e842 100644 --- a/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java +++ b/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java @@ -984,6 +984,7 @@ void visitVariables(List fragments, DeclarationKind declarationKin } } + @SuppressWarnings("for-rollout:NullAway") private TypeWithDims variableFragmentDims(boolean first, int leadingDims, Tree type) { if (type == null) { return null; @@ -1381,6 +1382,7 @@ public Void visitAnnotatedType(AnnotatedTypeTree node, Void unused) { protected static final long RECORD = 1L << 61; + @SuppressWarnings("for-rollout:NullAway") @Override public Void visitMethod(MethodTree node, Void unused) { sync(node); @@ -2997,6 +2999,7 @@ private ExpressionTree getArrayBase(ExpressionTree node) { return node; } + @SuppressWarnings("for-rollout:NullAway") private ExpressionTree getMethodReceiver(MethodInvocationTree methodInvocation) { ExpressionTree select = methodInvocation.getMethodSelect(); return select instanceof MemberSelectTree ? ((MemberSelectTree) select).getExpression() : null; @@ -3328,6 +3331,7 @@ static int rowLength(List row) { return size; } + @SuppressWarnings("for-rollout:NullAway") private Integer actualColumn(ExpressionTree expression) { Map positionToColumnMap = builder.getInput().getPositionToColumnMap(); return positionToColumnMap.get(builder.actualStartColumn(getStartPosition(expression))); diff --git a/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavaOutput.java b/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavaOutput.java index b6f9e068..b7502a12 100644 --- a/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavaOutput.java +++ b/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavaOutput.java @@ -177,6 +177,7 @@ void flush() { * * @return a list of {@link Replacement}s, sorted by start index, without overlaps */ + @SuppressWarnings("for-rollout:NullAway") public ImmutableList getFormatReplacements(RangeSet iRangeSet0) { ImmutableList.Builder result = ImmutableList.builder(); Map> kToJ = JavaOutput.makeKToIJ(this); @@ -212,6 +213,7 @@ public ImmutableList getFormatReplacements(RangeSet iRange replaceFrom--; } + @SuppressWarnings("for-rollout:NullAway") int i = kToJ.get(startTok.getIndex()).lowerEndpoint(); // Include leading blank lines from the formatted output, unless the formatted range // starts at the beginning of the file. diff --git a/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavacTokens.java b/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavacTokens.java index 9cc61d20..70583741 100644 --- a/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavacTokens.java +++ b/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavacTokens.java @@ -72,6 +72,7 @@ public String stringVal() { } /** Lex the input and return a list of {@link RawTok}s. */ + @SuppressWarnings("for-rollout:NullAway") public static ImmutableList getTokens(String source, Context context, Set stopTokens) { if (source == null) { return ImmutableList.of(); @@ -154,6 +155,7 @@ static class CommentWithTextAndPosition implements Comment { private final AccessibleReader reader; private final CommentStyle style; + @SuppressWarnings("for-rollout:NullAway") private String text = null; public CommentWithTextAndPosition(int pos, int endPos, AccessibleReader reader, CommentStyle style) { diff --git a/palantir-java-format/src/main/java/com/palantir/javaformat/java/JsonSink.java b/palantir-java-format/src/main/java/com/palantir/javaformat/java/JsonSink.java index 87d7f7ec..7ef3d7af 100644 --- a/palantir-java-format/src/main/java/com/palantir/javaformat/java/JsonSink.java +++ b/palantir-java-format/src/main/java/com/palantir/javaformat/java/JsonSink.java @@ -35,8 +35,11 @@ public final class JsonSink implements Sink { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper().registerModule(new Jdk8Module()); private final Map childrenMap = new HashMap<>(); + + @SuppressWarnings("for-rollout:NullAway") private ObjectNode rootNode; + @SuppressWarnings("for-rollout:NullAway") @Override public FinishExplorationNode startExplorationNode( int exporationId, @@ -68,6 +71,7 @@ public FinishExplorationNode startExplorationNode( @Override public FinishLevelNode writeLevelNode(int levelNodeId, int parentExplorationId, State incomingState, Level level) { + @SuppressWarnings("for-rollout:NullAway") ObjectNode json = childrenMap.get(parentExplorationId).addObject(); json.put("type", "level"); json.put("id", levelNodeId); diff --git a/palantir-java-format/src/main/java/com/palantir/javaformat/java/ModifierOrderer.java b/palantir-java-format/src/main/java/com/palantir/javaformat/java/ModifierOrderer.java index 364b1df4..26e83f13 100644 --- a/palantir-java-format/src/main/java/com/palantir/javaformat/java/ModifierOrderer.java +++ b/palantir-java-format/src/main/java/com/palantir/javaformat/java/ModifierOrderer.java @@ -107,6 +107,7 @@ private static void addTrivia(StringBuilder replacement, ImmutableList getPermitsClause(ClassTree node) { } } + @SuppressWarnings("for-rollout:NullAway") @Override public Void visitBindingPattern(BindingPatternTree node, Void unused) { sync(node); @@ -326,6 +327,7 @@ public Void visitLambdaExpression(LambdaExpressionTree node, Void unused) { return null; } + @SuppressWarnings("for-rollout:NullAway") private static Method maybeGetMethod(Class c, String name) { try { return c.getMethod(name); diff --git a/palantir-java-format/src/main/java/com/palantir/javaformat/java/javadoc/JavadocLexer.java b/palantir-java-format/src/main/java/com/palantir/javaformat/java/javadoc/JavadocLexer.java index 8e55f085..2ba55d60 100644 --- a/palantir-java-format/src/main/java/com/palantir/javaformat/java/javadoc/JavadocLexer.java +++ b/palantir-java-format/src/main/java/com/palantir/javaformat/java/javadoc/JavadocLexer.java @@ -436,6 +436,7 @@ private static ImmutableList deindentPreCodeBlocks(List input) { return output.build(); } + @SuppressWarnings("for-rollout:NullAway") private static void deindentPreCodeBlock(ImmutableList.Builder output, PeekingIterator tokens) { Deque saved = new ArrayDeque<>(); output.add(new Token(LITERAL, tokens.next().getValue().trim()));