Skip to content

Commit

Permalink
Excavator: Upgrades Baseline to the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-excavator-bot committed Oct 11, 2019
1 parent eee9038 commit d408b08
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 52 deletions.
8 changes: 5 additions & 3 deletions .baseline/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@
<module name="AvoidStarImport"/> <!-- Java Style Guide: No wildcard imports -->
<module name="AvoidStaticImport"> <!-- Java Style Guide: No static imports -->
<property name="excludes" value="
com.google.common.base.Preconditions.*,
com.palantir.logsafe.Preconditions.*,
java.util.Collections.*,
java.util.stream.Collectors.*,
com.palantir.logsafe.Preconditions.*,
com.google.common.base.Preconditions.*,
org.apache.commons.lang3.Validate.*"/>
org.apache.commons.lang3.Validate.*,
org.assertj.core.api.Assertions.*,
org.mockito.Mockito.*"/>
</module>
<module name="ClassTypeParameterName"> <!-- Java Style Guide: Type variable names -->
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.netflix.nebula:nebula-publishing-plugin:14.0.0'
classpath 'com.netflix.nebula:gradle-info-plugin:5.1.1'
classpath 'com.palantir.baseline:gradle-baseline-java:2.13.0'
classpath 'com.palantir.baseline:gradle-baseline-java:2.19.0'
classpath 'gradle.plugin.org.inferred:gradle-processors:3.1.0'
classpath 'com.palantir.gradle.gitversion:gradle-git-version:0.12.2'
classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:1.12.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@

package com.palantir.javaformat.intellij;

import static com.google.common.base.Preconditions.checkState;

import com.google.common.collect.BoundType;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Range;
import com.intellij.openapi.util.TextRange;
import com.palantir.javaformat.java.Formatter;
import com.palantir.javaformat.java.FormatterException;
import com.palantir.logsafe.Preconditions;
import java.util.Collection;
import java.util.Map;
import java.util.stream.Collectors;
Expand All @@ -50,7 +49,8 @@ private static Collection<Range<Integer>> toRanges(Collection<TextRange> textRan
}

private static TextRange toTextRange(Range<Integer> range) {
checkState(range.lowerBoundType().equals(BoundType.CLOSED) && range.upperBoundType().equals(BoundType.OPEN));
Preconditions.checkState(
range.lowerBoundType().equals(BoundType.CLOSED) && range.upperBoundType().equals(BoundType.OPEN));
return new TextRange(range.lowerEndpoint(), range.upperEndpoint());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

package com.palantir.javaformat;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.palantir.logsafe.Preconditions;

/** An error that prevented formatting from succeeding. */
public class FormatterDiagnostic {
Expand All @@ -28,9 +27,9 @@ public static FormatterDiagnostic create(String message) {
}

public static FormatterDiagnostic create(int lineNumber, int column, String message) {
checkArgument(lineNumber >= 0);
checkArgument(column >= 0);
checkNotNull(message);
Preconditions.checkArgument(lineNumber >= 0);
Preconditions.checkArgument(column >= 0);
Preconditions.checkNotNull(message);
return new FormatterDiagnostic(lineNumber, column, message);
}

Expand Down Expand Up @@ -58,6 +57,7 @@ public String message() {
return message;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
if (lineNumber >= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.palantir.javaformat.Indent;
import com.palantir.javaformat.Output;
import com.palantir.javaformat.doc.StartsWithBreakVisitor.Result;
import com.palantir.logsafe.exceptions.SafeIllegalStateException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -167,7 +168,7 @@ public State computeBreaks(CommentsHelper commentsHelper, int maxWidth, State st
Level firstLevel = innerLevels.stream()
.filter(doc -> StartsWithBreakVisitor.INSTANCE.visit(doc) != Result.EMPTY)
.findFirst()
.orElseThrow(() -> new IllegalStateException(
.orElseThrow(() -> new SafeIllegalStateException(
"Levels were broken so expected to find at least a non-empty level"));

// Add the width of tokens, breaks before the firstLevel. We must always have space for
Expand Down Expand Up @@ -239,7 +240,7 @@ private Optional<State> tryBreakLastLevel(
splitByBreaks(leadingDocs, splits, breaks);

state = tryToLayOutLevelOnOneLine(commentsHelper, maxWidth, state);
Preconditions.checkState(
com.palantir.logsafe.Preconditions.checkState(
!state.mustBreak, "We messed up, it wants to break a bunch of splits that shouldn't be broken");

// manually add the last level to the last split
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static com.palantir.javaformat.java.JavaInput.buildToks;

import com.google.common.base.CharMatcher;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -357,7 +356,7 @@ private ImportsAndIndex scanImports(int i) throws FormatterException {

// Produces the sorted output based on the imports we have scanned.
private String reorderedImportsString(ImmutableSortedSet<Import> imports) {
Preconditions.checkArgument(!imports.isEmpty(), "imports");
com.palantir.logsafe.Preconditions.checkArgument(!imports.isEmpty(), "imports");

// Pretend that the first import was preceded by another import of the same kind, so we don't
// insert a newline there.
Expand Down Expand Up @@ -402,7 +401,7 @@ private StringAndIndex scanImported(int start) throws FormatterException {
// At the start of each iteration of this loop, i points to an identifier.
// On exit from the loop, i points to a token after an identifier or after *.
while (true) {
Preconditions.checkState(isIdentifierToken(i));
com.palantir.logsafe.Preconditions.checkState(isIdentifierToken(i));
imported.append(tokenAt(i));
i++;
if (!tokenAt(i).equals(".")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package com.palantir.javaformat.java;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.getLast;
import static java.nio.charset.StandardCharsets.UTF_8;

Expand All @@ -33,6 +32,7 @@
import com.palantir.javaformat.Input;
import com.palantir.javaformat.Newlines;
import com.palantir.javaformat.java.JavacTokens.RawTok;
import com.palantir.logsafe.Preconditions;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
Expand Down Expand Up @@ -260,7 +260,7 @@ public String toString() {
* @throws FormatterException if the input cannot be parsed
*/
public JavaInput(String text) throws FormatterException {
this.text = checkNotNull(text);
this.text = Preconditions.checkNotNull(text);
setLines(ImmutableList.copyOf(Newlines.lineIterator(text)));
ImmutableList<Tok> toks = buildToks(text);
positionToColumnMap = makePositionToColumnMap(toks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.Multiset;
import com.google.common.collect.PeekingIterator;
import com.google.common.collect.Streams;
Expand All @@ -72,6 +73,7 @@
import com.palantir.javaformat.doc.Token;
import com.palantir.javaformat.java.DimensionHelpers.SortedDims;
import com.palantir.javaformat.java.DimensionHelpers.TypeWithDims;
import com.palantir.logsafe.exceptions.SafeIllegalStateException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -483,7 +485,7 @@ public boolean visitArrayInitializer(List<? extends ExpressionTree> expressions)
token("{");
builder.forcedBreak();
boolean first = true;
for (Iterable<? extends ExpressionTree> row : Iterables.partition(expressions, cols)) {
for (Iterable<? extends ExpressionTree> row : Lists.partition(expressions, cols)) {
if (!first) {
builder.forcedBreak();
}
Expand Down Expand Up @@ -1953,7 +1955,7 @@ public Void visitTypeParameter(TypeParameterTree node, Void unused) {

@Override
public Void visitUnionType(UnionTypeTree node, Void unused) {
throw new IllegalStateException("expected manual descent into union types");
throw new SafeIllegalStateException("expected manual descent into union types");
}

@Override
Expand Down Expand Up @@ -2101,7 +2103,7 @@ void visitAndBreakModifiers(

@Override
public Void visitModifiers(ModifiersTree node, Void unused) {
throw new IllegalStateException("expected manual descent into modifiers");
throw new SafeIllegalStateException("expected manual descent into modifiers");
}

/** Output combined modifiers and annotations and returns the trailing break. */
Expand Down Expand Up @@ -2188,7 +2190,7 @@ boolean nextIsModifier() {

@Override
public Void visitCatch(CatchTree node, Void unused) {
throw new IllegalStateException("expected manual descent into catch trees");
throw new SafeIllegalStateException("expected manual descent into catch trees");
}

/** Helper method for {@link CatchTree}s. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

package com.palantir.javaformat.java;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.collect.Range;
import com.palantir.logsafe.Preconditions;
import java.util.Objects;

/**
Expand All @@ -28,17 +26,17 @@
public final class Replacement {

public static Replacement create(int startPosition, int endPosition, String replaceWith) {
checkArgument(startPosition >= 0, "startPosition must be non-negative");
checkArgument(startPosition <= endPosition, "startPosition cannot be after endPosition");
Preconditions.checkArgument(startPosition >= 0, "startPosition must be non-negative");
Preconditions.checkArgument(startPosition <= endPosition, "startPosition cannot be after endPosition");
return new Replacement(Range.closedOpen(startPosition, endPosition), replaceWith);
}

private final Range<Integer> replaceRange;
private final String replacementString;

private Replacement(Range<Integer> replaceRange, String replacementString) {
this.replaceRange = checkNotNull(replaceRange, "Null replaceRange");
this.replacementString = checkNotNull(replacementString, "Null replacementString");
this.replaceRange = Preconditions.checkNotNull(replaceRange, "Null replaceRange");
this.replacementString = Preconditions.checkNotNull(replacementString, "Null replacementString");
}

/** The range of characters in the original source to replace. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.common.collect.Range;
import com.google.common.collect.RangeSet;
import com.google.common.collect.TreeRangeSet;
import com.palantir.logsafe.exceptions.SafeIllegalArgumentException;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -97,7 +98,7 @@ public ImmutableList<Replacement> format(
}
if (includeComments) {
if (kind != SnippetKind.COMPILATION_UNIT) {
throw new IllegalArgumentException("comment formatting is only supported for compilation units");
throw new SafeIllegalArgumentException("comment formatting is only supported for compilation units");
}
return formatter.getFormatReplacements(source, ranges);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@

package com.palantir.javaformat.java;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.base.Joiner;
import com.palantir.logsafe.Preconditions;

/** Checked exception class for formatter command-line usage errors. */
final class UsageException extends Exception {
Expand Down Expand Up @@ -79,7 +78,7 @@ final class UsageException extends Exception {
}

UsageException(String message) {
super(buildMessage(checkNotNull(message)));
super(buildMessage(Preconditions.checkNotNull(message)));
}

private static String buildMessage(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@

package com.palantir.javaformat.java.filer;

import static com.google.common.base.Preconditions.checkNotNull;

import com.palantir.javaformat.java.Formatter;
import com.palantir.logsafe.Preconditions;
import java.io.IOException;
import javax.annotation.Nullable;
import javax.annotation.processing.Filer;
Expand Down Expand Up @@ -46,7 +45,7 @@ public FormattingFiler(Filer delegate) {
* @param messager to log warnings to
*/
public FormattingFiler(Filer delegate, @Nullable Messager messager) {
this.delegate = checkNotNull(delegate);
this.delegate = Preconditions.checkNotNull(delegate);
this.messager = messager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@

package com.palantir.javaformat.java.filer;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.io.CharSink;
import com.google.common.io.CharSource;
import com.palantir.javaformat.java.Formatter;
import com.palantir.javaformat.java.FormatterException;
import com.palantir.logsafe.Preconditions;
import java.io.IOException;
import java.io.Writer;
import javax.annotation.Nullable;
Expand All @@ -43,8 +42,8 @@ final class FormattingJavaFileObject extends ForwardingJavaFileObject<JavaFileOb
* @param messager to log messages with.
*/
FormattingJavaFileObject(JavaFileObject delegate, Formatter formatter, @Nullable Messager messager) {
super(checkNotNull(delegate));
this.formatter = checkNotNull(formatter);
super(Preconditions.checkNotNull(delegate));
this.formatter = Preconditions.checkNotNull(formatter);
this.messager = messager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

package com.palantir.javaformat.java.javadoc;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import com.palantir.logsafe.Preconditions;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand All @@ -31,7 +29,7 @@ final class CharStream {
int toConsume;

CharStream(String input) {
this.remaining = checkNotNull(input);
this.remaining = Preconditions.checkNotNull(input);
}

boolean tryConsume(String expected) {
Expand All @@ -50,7 +48,7 @@ boolean tryConsumeRegex(Pattern pattern) {
if (!matcher.find()) {
return false;
}
checkArgument(matcher.start() == 0);
Preconditions.checkArgument(matcher.start() == 0);
toConsume = matcher.end();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.palantir.javaformat.java.javadoc;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Verify.verify;
import static com.google.common.collect.Iterators.peekingIterator;
import static com.palantir.javaformat.java.javadoc.Token.Type.BEGIN_JAVADOC;
Expand Down Expand Up @@ -54,6 +53,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.PeekingIterator;
import com.palantir.javaformat.java.javadoc.Token.Type;
import com.palantir.logsafe.Preconditions;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
Expand Down Expand Up @@ -100,7 +100,7 @@ private static String stripJavadocBeginAndEnd(String input) {
private boolean somethingSinceNewline;

private JavadocLexer(CharStream input) {
this.input = checkNotNull(input);
this.input = Preconditions.checkNotNull(input);
}

private ImmutableList<Token> generateTokens() throws LexException {
Expand Down
Loading

0 comments on commit d408b08

Please sign in to comment.