Skip to content

Commit

Permalink
Excavator: Upgrades Baseline to the latest version (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-excavator-bot authored and bulldozer-bot[bot] committed Nov 12, 2019
1 parent 5785a4a commit 5245770
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 52 deletions.
8 changes: 3 additions & 5 deletions .baseline/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
<property name="optional" value="true"/>
</module>
<module name="SuppressWarningsFilter"/> <!-- baseline-gradle: README.md -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
<module name="TreeWalker">
<module name="SuppressionCommentFilter"/> <!-- baseline-gradle: README.md -->
<module name="SuppressionCommentFilter">
Expand Down Expand Up @@ -112,7 +115,6 @@
<module name="EmptyStatement"/> <!-- Java Style Guide: One statement per line -->
<module name="EqualsHashCode"/>
<module name="FallThrough"/> <!-- Java Style Guide: Fall-through: commented -->
<module name="FinalClass"/> <!-- Java Coding Guidelines: Private constructors -->
<module name="GenericWhitespace"> <!-- Java Style Guide: Horizontal whitespace -->
<message key="ws.followed" value="GenericWhitespace ''{0}'' is followed by whitespace."/>
<message key="ws.preceded" value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
Expand Down Expand Up @@ -367,10 +369,6 @@
<property name="format" value="\bIOUtils\.toString\("/>
<property name="message" value="Prefer Guava''s [CharStreams,Files,Resources].toString to avoid charset/stream closing issues."/>
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="static enum"/>
<property name="message" value="Redundant ''static'' modifier."/>
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="\/\/TODO|\/\/ TODO(?!\([^()\s]+\): )"/>
<property name="message" value="TODO format: // TODO(#issue): explanation"/>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.netflix.nebula:nebula-publishing-plugin:14.1.1'
classpath 'com.netflix.nebula:gradle-info-plugin:5.2.0'
classpath 'com.palantir.baseline:gradle-baseline-java:2.27.0'
classpath 'com.palantir.baseline:gradle-baseline-java:2.30.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 @@ -20,7 +20,7 @@
import static com.google.common.base.Preconditions.checkNotNull;

/** An error that prevented formatting from succeeding. */
public class FormatterDiagnostic {
public final class FormatterDiagnostic {
private final int lineNumber;
private final String message;
private final int column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* directly against our primary goals.
*/
@Immutable
public class JavaFormatterOptions {
public final class JavaFormatterOptions {

public enum Style {
/** The default Palantir Java Style configuration. */
Expand Down Expand Up @@ -86,7 +86,7 @@ public static Builder builder() {
}

/** A builder for {@link JavaFormatterOptions}. */
public static class Builder {
public static final class Builder {
// default is still GOOGLE just because lots of hand-rolled tests rely on this behaviour
private Style style = Style.GOOGLE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static Iterator<String> lineIterator(String input) {
return new LineIterator(input);
}

private static class LineOffsetIterator implements Iterator<Integer> {
private static final class LineOffsetIterator implements Iterator<Integer> {

private int curr = 0;
private int idx = 0;
Expand Down Expand Up @@ -150,7 +150,7 @@ public void remove() {
}
}

private static class LineIterator implements Iterator<String> {
private static final class LineIterator implements Iterator<String> {

int idx;
String curr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private void add(Op op) {
}

/** Add a list of {@link Op}s. */
public final void addAll(List<Op> ops) {
public void addAll(List<Op> ops) {
for (Op op : ops) {
add(op);
}
Expand All @@ -187,7 +187,7 @@ public OpsBuilder(Input input, Output output) {
}

/** Get the {@code OpsBuilder}'s {@link Input}. */
public final Input getInput() {
public Input getInput() {
return input;
}

Expand Down Expand Up @@ -218,7 +218,7 @@ public FormatterDiagnostic diagnostic(String message) {
*
* @param inputPosition the {@code 0}-based input position
*/
public final void sync(int inputPosition) {
public void sync(int inputPosition) {
if (inputPosition > this.inputPosition) {
ImmutableList<? extends Input.Token> tokens = input.getTokens();
int tokensN = tokens.size();
Expand All @@ -233,7 +233,7 @@ public final void sync(int inputPosition) {
}

/** Output any remaining tokens from the input stream (e.g. terminal whitespace). */
public final void drain() {
public void drain() {
int inputPosition = input.getText().length() + 1;
if (inputPosition > this.inputPosition) {
ImmutableList<? extends Input.Token> tokens = input.getTokens();
Expand All @@ -256,7 +256,7 @@ public final void drain() {
*
* @param plusIndent the extra indent for the new level
*/
public final void open(Indent plusIndent) {
public void open(Indent plusIndent) {
add(OpenOp.make(plusIndent));
}

Expand All @@ -266,7 +266,7 @@ public final void open(Indent plusIndent) {
* @param debugName a representative name for this lambda
* @param plusIndent the extra indent for the new level
*/
public final void open(String debugName, Indent plusIndent) {
public void open(String debugName, Indent plusIndent) {
add(OpenOp.builder().plusIndent(plusIndent).debugName(debugName).build());
}

Expand All @@ -277,31 +277,30 @@ public final void open(String debugName, Indent plusIndent) {
* @param breakBehaviour how to decide whether to break this level or not
* @param breakabilityIfLastLevel if last level, when to break this rather than parent
*/
public final void open(
Indent plusIndent, BreakBehaviour breakBehaviour, LastLevelBreakability breakabilityIfLastLevel) {
public void open(Indent plusIndent, BreakBehaviour breakBehaviour, LastLevelBreakability breakabilityIfLastLevel) {
add(OpenOp.builder()
.plusIndent(plusIndent)
.breakBehaviour(breakBehaviour)
.breakabilityIfLastLevel(breakabilityIfLastLevel)
.build());
}

public final void open(OpenOp openOp) {
public void open(OpenOp openOp) {
add(openOp);
}

/** Close the current level, by emitting a {@link CloseOp}. */
public final void close() {
public void close() {
add(CloseOp.make());
}

/** Return the text of the next {@link Input.Token}, or absent if there is none. */
public final Optional<String> peekToken() {
public Optional<String> peekToken() {
return peekToken(0);
}

/** Return the text of an upcoming {@link Input.Token}, or absent if there is none. */
public final Optional<String> peekToken(int skip) {
public Optional<String> peekToken(int skip) {
ImmutableList<? extends Input.Token> tokens = input.getTokens();
int idx = tokenI + skip;
return idx < tokens.size() ? Optional.of(tokens.get(idx).getTok().getOriginalText()) : Optional.empty();
Expand All @@ -313,11 +312,11 @@ public final Optional<String> peekToken(int skip) {
*
* @param token the optional token
*/
public final void guessToken(String token) {
public void guessToken(String token) {
token(token, Token.RealOrImaginary.IMAGINARY, ZERO, /* breakAndIndentTrailingComment= */ Optional.empty());
}

public final void token(
public void token(
String token,
Token.RealOrImaginary realOrImaginary,
Indent plusIndentCommentsBefore,
Expand Down Expand Up @@ -346,7 +345,7 @@ public final void token(
*
* @param op the operator to emit
*/
public final void op(String op) {
public void op(String op) {
int opN = op.length();
for (int i = 0; i < opN; i++) {
token(
Expand All @@ -358,12 +357,12 @@ public final void op(String op) {
}

/** Emit a {@link Space}. */
public final void space() {
public void space() {
add(Space.make());
}

/** Emit a {@link Break}. */
public final void breakOp() {
public void breakOp() {
breakOp(FillMode.UNIFIED, "", ZERO);
}

Expand All @@ -372,17 +371,17 @@ public final void breakOp() {
*
* @param plusIndent extra indent if taken
*/
public final void breakOp(Indent plusIndent) {
public void breakOp(Indent plusIndent) {
breakOp(FillMode.UNIFIED, "", plusIndent);
}

/** Emit a filled {@link Break}. */
public final void breakToFill() {
public void breakToFill() {
breakOp(FillMode.INDEPENDENT, "", ZERO);
}

/** Emit a forced {@link Break}. */
public final void forcedBreak() {
public void forcedBreak() {
breakOp(FillMode.FORCED, "", ZERO);
}

Expand All @@ -391,7 +390,7 @@ public final void forcedBreak() {
*
* @param plusIndent extra indent if taken
*/
public final void forcedBreak(Indent plusIndent) {
public void forcedBreak(Indent plusIndent) {
breakOp(FillMode.FORCED, "", plusIndent);
}

Expand All @@ -400,7 +399,7 @@ public final void forcedBreak(Indent plusIndent) {
*
* @param flat the {@link Break} when not broken
*/
public final void breakOp(String flat) {
public void breakOp(String flat) {
breakOp(FillMode.UNIFIED, flat, ZERO);
}

Expand All @@ -409,7 +408,7 @@ public final void breakOp(String flat) {
*
* @param flat the {@link Break} when not broken
*/
public final void breakToFill(String flat) {
public void breakToFill(String flat) {
breakOp(FillMode.INDEPENDENT, flat, ZERO);
}

Expand All @@ -420,7 +419,7 @@ public final void breakToFill(String flat) {
* @param flat the {@link Break} when not broken
* @param plusIndent extra indent if taken
*/
public final void breakOp(FillMode fillMode, String flat, Indent plusIndent) {
public void breakOp(FillMode fillMode, String flat, Indent plusIndent) {
breakOp(fillMode, flat, plusIndent, /* optionalTag= */ Optional.empty());
}

Expand All @@ -432,7 +431,7 @@ public final void breakOp(FillMode fillMode, String flat, Indent plusIndent) {
* @param plusIndent extra indent if taken
* @param optionalTag an optional tag for remembering whether the break was taken
*/
public final void breakOp(FillMode fillMode, String flat, Indent plusIndent, Optional<BreakTag> optionalTag) {
public void breakOp(FillMode fillMode, String flat, Indent plusIndent, Optional<BreakTag> optionalTag) {
add(Break.make(fillMode, flat, plusIndent, optionalTag));
}

Expand Down Expand Up @@ -461,7 +460,7 @@ public void markForPartialFormat() {
*
* @param wanted whether to force ({@code true}) or suppress {@code false}) the blank line
*/
public final void blankLineWanted(BlankLineWanted wanted) {
public void blankLineWanted(BlankLineWanted wanted) {
output.blankLine(getI(input.getTokens().get(tokenI)), wanted);
}

Expand All @@ -481,7 +480,7 @@ private static int getI(Input.Token token) {
*
* @return the list of {@link Op}s
*/
public final ImmutableList<Op> build() {
public ImmutableList<Op> build() {
markForPartialFormat();
// Rewrite the ops to insert comments.
Multimap<Integer, Op> tokOps = ArrayListMultimap.create();
Expand Down Expand Up @@ -648,7 +647,7 @@ private static List<Op> makeComment(Input.Tok comment) {
}

@Override
public final String toString() {
public String toString() {
return MoreObjects.toStringHelper(this)
.add("input", input)
.add("ops", ops)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.openjdk.tools.javac.parser.Tokens.TokenKind;

/** Orders imports in Java source code. */
public class ImportOrderer {
public final class ImportOrderer {

private static final Splitter DOT_SPLITTER = Splitter.on('.');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,16 +278,16 @@ boolean isYes() {
private final Indent.Const plusTwo;
private final Indent.Const plusFour;

private static final ImmutableList<Op> breakList(Optional<BreakTag> breakTag) {
private static ImmutableList<Op> breakList(Optional<BreakTag> breakTag) {
return ImmutableList.of(Break.make(FillMode.UNIFIED, " ", ZERO, breakTag));
}

private static final ImmutableList<Op> breakFillList(Optional<BreakTag> breakTag) {
private static ImmutableList<Op> breakFillList(Optional<BreakTag> breakTag) {
return ImmutableList.of(
OpenOp.make(ZERO), Break.make(FillMode.INDEPENDENT, " ", ZERO, breakTag), CloseOp.make());
}

private static final ImmutableList<Op> forceBreakList(Optional<BreakTag> breakTag) {
private static ImmutableList<Op> forceBreakList(Optional<BreakTag> breakTag) {
return ImmutableList.of(Break.make(FillMode.FORCED, "", Indent.Const.ZERO, breakTag));
}

Expand Down Expand Up @@ -3580,7 +3580,7 @@ private Direction fieldAnnotationDirection(ModifiersTree modifiers) {
*
* @param token the {@link String} to wrap in a {@link Token}
*/
final void token(String token) {
void token(String token) {
builder.token(token, Token.RealOrImaginary.REAL, ZERO, /* breakAndIndentTrailingComment= */ Optional.empty());
}

Expand All @@ -3590,7 +3590,7 @@ final void token(String token) {
* @param token the {@link String} to wrap in a {@link Token}
* @param plusIndentCommentsBefore extra indent for comments before this token
*/
final void token(String token, Indent plusIndentCommentsBefore) {
void token(String token, Indent plusIndentCommentsBefore) {
builder.token(
token,
Token.RealOrImaginary.REAL,
Expand All @@ -3599,7 +3599,7 @@ final void token(String token, Indent plusIndentCommentsBefore) {
}

/** Emit a {@link Token}, and breaks and indents trailing javadoc or block comments. */
final void tokenBreakTrailingComment(String token, Indent breakAndIndentTrailingComment) {
void tokenBreakTrailingComment(String token, Indent breakAndIndentTrailingComment) {
builder.token(token, Token.RealOrImaginary.REAL, ZERO, Optional.of(breakAndIndentTrailingComment));
}

Expand All @@ -3615,12 +3615,12 @@ private void markForPartialFormat() {
*
* @param node the ASTNode holding the input position
*/
final void sync(Tree node) {
void sync(Tree node) {
builder.sync(((JCTree) node).getStartPosition());
}

@Override
public final String toString() {
public String toString() {
return MoreObjects.toStringHelper(this).add("builder", builder).toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class Main {
private static final int MAX_THREADS = 20;
private static final String STDIN_FILENAME = "<stdin>";

static final String versionString() {
static String versionString() {
return "palantir-java-format: Version " + Main.class.getPackage().getImplementationVersion();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public class RemoveUnusedImports {
// This is still reasonably effective in practice because type names differ
// from other kinds of names in casing convention, and simple name
// clashes between imported and declared types are rare.
private static class UnusedImportScanner extends TreePathScanner<Void, Void> {
private static final class UnusedImportScanner extends TreePathScanner<Void, Void> {

private final Set<String> usedNames = new LinkedHashSet<>();
private final Multimap<String, Range<Integer>> usedInJavadoc = HashMultimap.create();
Expand Down
Loading

0 comments on commit 5245770

Please sign in to comment.