Skip to content
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

Excavator: Upgrades Baseline to the latest version #129

Merged
merged 6 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 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 @@ -84,11 +87,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 All @@ -110,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 @@ -369,10 +373,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 Expand Up @@ -422,6 +422,7 @@
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLoops" value="true"/>
<property name="allowEmptyLambdas" value="true"/>
<property name="ignoreEnhancedForColon" value="false"/>
<message key="ws.notFollowed" value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
<message key="ws.notPreceded" value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
Expand All @@ -435,7 +436,7 @@
</module>
<module name="CyclomaticComplexity"/> <!-- Java Coding Guidelines: Reduce Cyclomatic Complexity -->
<module name="DesignForExtension"> <!-- Java Coding Guidelines: Design for extension -->
<property name="ignoredAnnotations" value="Test, Before, BeforeEach, After, AfterEach, BeforeClass, BeforeAll, AfterClass, AfterAll"/>
<property name="ignoredAnnotations" value="ParameterizedTest, Test, Before, BeforeEach, After, AfterEach, BeforeClass, BeforeAll, AfterClass, AfterAll"/>
</module>
<module name="JavadocMethod"> <!-- Java Style Guide: Where Javadoc is used -->
<property name="scope" value="public"/>
Expand Down Expand Up @@ -468,10 +469,9 @@
<module name="NestedTryDepth"/> <!-- Java Coding Guide: Try/catch blocks: never nested -->
<module name="NonEmptyAtclauseDescription"/> <!-- Java Style Guide: At-clauses -->
<module name="ParameterName"> <!-- Java Style Guide: Parameter names -->
<property name="format" value="^[a-z][a-zA-Z0-9]+$"/>
<property name="format" value="^_?[a-z][a-zA-Z0-9]+$"/>
<message key="name.invalidPattern" value="Parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="SingleLineJavadoc"/> <!-- Java Style Guide: General form -->
<module name="SummaryJavadocCheck"> <!-- Java Coding Guidelines: Javadoc -->
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
</module>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ buildscript {
classpath 'com.netflix.nebula:gradle-info-plugin:7.1.4'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
classpath 'com.netflix.nebula:nebula-publishing-plugin:16.0.0'
classpath 'com.palantir.baseline:gradle-baseline-java:0.65.0'
classpath 'com.palantir.baseline:gradle-baseline-java:2.49.1'
classpath 'com.palantir.gradle.gitversion:gradle-git-version:0.12.3'
}
}
Expand Down
1 change: 1 addition & 0 deletions human-readable-types/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ apply from: "$rootDir/gradle/publish-jar.gradle"
dependencies {
compile 'com.fasterxml.jackson.core:jackson-databind'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-guava'
implementation 'com.palantir.safe-logging:preconditions'

testCompile 'junit:junit'
testCompile 'org.assertj:assertj-core'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.palantir.logsafe.Preconditions;
import com.palantir.logsafe.SafeArg;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Locale;
Expand Down Expand Up @@ -145,7 +147,7 @@ public static HumanReadableByteCount valueOf(String byteCount) {
try {
Matcher matcher = BYTE_COUNT_PATTERN.matcher(lower);

Preconditions.checkArgument(matcher.matches(), "Invalid byte string: %s", byteCount);
Preconditions.checkArgument(matcher.matches(), "Invalid byte string", SafeArg.of("byteCount", byteCount));

long size = Long.parseLong(matcher.group(1));
String suffix = matcher.group(2);
Expand Down Expand Up @@ -274,7 +276,8 @@ enum ByteUnit {
}

public long toBytes(long sizeValue) {
Preconditions.checkArgument(sizeValue >= 0, "Negative size value. Size must be positive: %s", sizeValue);
Preconditions.checkArgument(sizeValue >= 0, "Negative size value. Size must be positive",
SafeArg.of("size", sizeValue));
return sizeValue * multiplier;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.palantir.logsafe.Preconditions;
import com.palantir.logsafe.SafeArg;
import com.palantir.logsafe.exceptions.SafeIllegalArgumentException;
import java.io.Serializable;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -138,17 +140,19 @@ public static HumanReadableDuration days(long count) {
*
* @param duration the string HumanReadableDuration of this duration
* @return the parsed {@link HumanReadableDuration}
* @throws IllegalArgumentException if the provided duration is invalid
* @throws SafeIllegalArgumentException if the provided duration is invalid
*/
@JsonCreator
public static HumanReadableDuration valueOf(String duration) {
final Matcher matcher = DURATION_PATTERN.matcher(duration);
Preconditions.checkArgument(matcher.matches(), "Invalid duration: %s", duration);
Preconditions.checkArgument(matcher.matches(), "Invalid duration", SafeArg.of("duration", duration));

final long count = Long.parseLong(matcher.group(1));
final TimeUnit unit = SUFFIXES.get(matcher.group(2));
if (unit == null) {
throw new IllegalArgumentException("Invalid duration: " + duration + ". Wrong time unit");
throw new SafeIllegalArgumentException(
"Invalid duration. Wrong time unit",
SafeArg.of("duration", duration));
}

return new HumanReadableDuration(count, unit);
Expand Down Expand Up @@ -240,7 +244,7 @@ public Duration toJavaDuration() {
* @return the converted unit, not null
*/
private static ChronoUnit chronoUnit(TimeUnit unit) {
Objects.requireNonNull(unit, "unit");
Preconditions.checkNotNull(unit, "unit");
switch (unit) {
case NANOSECONDS:
return ChronoUnit.NANOS;
Expand All @@ -257,7 +261,7 @@ private static ChronoUnit chronoUnit(TimeUnit unit) {
case DAYS:
return ChronoUnit.DAYS;
}
throw new IllegalArgumentException("Unknown TimeUnit constant");
throw new SafeIllegalArgumentException("Unknown TimeUnit constant");
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void testParsePebiBytes() {
public void testInvalidString() {
assertThatThrownBy(() -> HumanReadableByteCount.valueOf("Ten bytes"))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Invalid byte string: Ten bytes");
.hasMessage("Invalid byte string: {byteCount=Ten bytes}");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ public void testParseDays() {
public void testInvalidPattern() {
assertThatThrownBy(() -> HumanReadableDuration.valueOf("One hour"))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Invalid duration: One hour");
.hasMessage("Invalid duration: {duration=One hour}");
}

@Test
public void testInvalidUnits() {
assertThatThrownBy(() -> HumanReadableDuration.valueOf("10 weeks"))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Invalid duration: 10 weeks. Wrong time unit");
.hasMessage("Invalid duration. Wrong time unit: {duration=10 weeks}");
}

@Test
Expand Down
3 changes: 2 additions & 1 deletion versions.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
com.fasterxml.jackson.*:jackson-* = 2.11.0
com.google.code.findbugs:jsr305 = 3.0.2
com.google.errorprone:error_prone_annotations = 2.3.4
com.google.errorprone:* = 2.3.4
com.google.guava:guava = 27.0.1-jre
com.palantir.safe-logging:* = 1.13.0
junit:junit = 4.13
org.assertj:* = 3.16.0
org.checkerframework:checker-qual = 2.5.3