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 #419

Merged
merged 1 commit into from
Jul 26, 2021
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
61 changes: 20 additions & 41 deletions .baseline/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<!--
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--
Palantir Baseline Checkstyle configuration.
Authors: Robert Fink, Brian Worth, Merrick Zoubeiri, and many other contributors. Based in part on http://checkstyle.sourceforge.net/google_style.html
Please keep checks alphabetized with one exception: "relaxed" checks are grouped together at the bottom for easier disabling.
Check-specific comments reference documents internal to Palantir and can be safely ignored or removed.
-->

--><!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" "https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="error"/>
Expand Down Expand Up @@ -47,6 +41,10 @@
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
<module name="LineLength"> <!-- Java Style Guide: No line-wrapping -->
<property name="max" value="120"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<module name="TreeWalker">
<module name="SuppressionCommentFilter"/> <!-- baseline-gradle: README.md -->
<module name="SuppressionCommentFilter">
Expand Down Expand Up @@ -77,14 +75,7 @@
</module>
<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.*,
org.apache.commons.lang3.Validate.*,
org.assertj.core.api.Assertions.*,
org.mockito.Mockito.*"/>
<property name="excludes" value="com.google.common.base.Preconditions.*, com.palantir.logsafe.Preconditions.*, java.util.Collections.*, java.util.stream.Collectors.*, 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 Expand Up @@ -134,12 +125,12 @@
<module name="IllegalImport"> <!-- Java Coding Guidelines: Import the canonical package -->
<property name="id" value="BanShadedClasses"/>
<property name="illegalPkgs" value=".*\.(repackaged|shaded|thirdparty)"/>
<property name="regexp" value="true" />
<property name="regexp" value="true"/>
<message key="import.illegal" value="Must not import repackaged classes."/>
</module>
<module name="IllegalImport">
<property name="illegalPkgs" value="^org\.gradle\.(internal|.*\.internal)"/>
<property name="regexp" value="true" />
<property name="regexp" value="true"/>
<message key="import.illegal" value="Do not rely on gradle internal classes as these may change in minor releases - use org.gradle.api versions instead."/>
</module>
<module name="IllegalImport">
Expand Down Expand Up @@ -192,11 +183,9 @@
<property name="separated" value="true"/>
<property name="sortStaticImportsAlphabetically" value="true"/>
</module>

<module name="InnerAssignment"/> <!-- Java Coding Guidelines: Inner assignments: Not used -->
<module name="LineLength"> <!-- Java Style Guide: No line-wrapping -->
<property name="max" value="120"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<!-- Java Style Guide: Nonempty blocks: K & R style -->
<module name="MemberName"> <!-- Java Style Guide: Non-constant field names -->
<property name="format" value="^[a-z][a-zA-Z0-9]+$"/>
<message key="name.invalidPattern" value="Member name ''{0}'' must match pattern ''{1}''."/>
Expand Down Expand Up @@ -237,6 +226,7 @@
<message key="name.invalidPattern" value="Package name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ParameterAssignment"/> <!-- Java Coding Guidelines: Final variables and parameters -->
<!-- Java Style Guide: Horizontal whitespace -->
<module name="RedundantImport"/> <!-- Java Style Guide: No unused imports -->
<module name="RedundantModifier"/> <!-- Java Coding Guidelines: Avoid redundant modifiers -->
<module name="RegexpSinglelineJava"> <!-- Java Coding Guidelines: Use appropriate assertion methods -->
Expand Down Expand Up @@ -352,7 +342,7 @@
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="\bCharset.defaultCharset\("/>
<property name="message" value="Use explicit charset (e.g. StandardCharsets.UTF-8) instead of default."/>
<property name="message" value="Use explicit charset (e.g. StandardCharsets.UTF_8) instead of default."/>
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="\bIOUtils\.toString\("/>
Expand All @@ -361,18 +351,19 @@
<module name="RegexpSinglelineJava">
<property name="format" value="\/\/TODO|\/\/ TODO(?!\([^()\s]+\): )"/>
<property name="message" value="TODO format: // TODO(#issue): explanation"/>
<property name="ignoreCase" value="true"/>
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="(void setUp\(\))|(void setup\(\))|(void setupStatic\(\))|(void setUpStatic\(\))|(void beforeTest\(\))|(void teardown\(\))|(void tearDown\(\))|(void beforeStatic\(\))|(void afterStatic\(\))"/>
<property name="message" value="Test setup/teardown methods are called before(), beforeClass(), after(), afterClass(), but not setUp, teardown, etc."/>
</module>
<module name="RightCurly"> <!-- Java Style Guide: Nonempty blocks: K & R style -->
<property name="option" value="same"/>
<property name="tokens" value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_DO"/>
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_DO"/>
</module>
<module name="RightCurly"> <!-- Java Style Guide: Nonempty blocks: K & R style -->
<property name="option" value="alone"/>
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT, INSTANCE_INIT"/>
<property name="tokens" value="LITERAL_FOR, LITERAL_WHILE, STATIC_INIT, INSTANCE_INIT"/>
</module>
<module name="SeparatorWrap"> <!-- Java Style Guide: Where to break -->
<property name="tokens" value="DOT"/>
Expand All @@ -390,7 +381,7 @@
<module name="SuppressWarnings">
<property name="format" value="serial"/>
</module>
<module name="SuppressWarningsHolder" /> <!-- Required for SuppressWarningsFilter -->
<module name="SuppressWarningsHolder"/> <!-- Required for SuppressWarningsFilter -->
<module name="TypeName"> <!-- Java Style Guide: Class names -->
<message key="name.invalidPattern" value="Type name ''{0}'' must match pattern ''{1}''."/>
</module>
Expand All @@ -401,16 +392,7 @@
<module name="UpperEll"/> <!-- Java Style Guide: Numeric Literals -->
<module name="VisibilityModifier"/> <!-- Java Coding Guidelines: Minimize mutability -->
<module name="WhitespaceAfter"/> <!-- Java Style Guide: Horizontal whitespace -->
<module name="WhitespaceAround"> <!-- Java Style Guide: Horizontal whitespace -->
<property name="allowEmptyConstructors" value="true"/>
<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."/>
</module>


<!-- Stricter checks begin: delete some or all of the following for faster prototyping, but please restore before pushing to production. -->

Expand All @@ -423,13 +405,10 @@
<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"/>
<property name="accessModifiers" value="public"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="minLineCount" value="99999999"/>
<property name="allowedAnnotations" value="Override, Test"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
</module>
<module name="JavadocStyle"/> <!-- Java Style Guide: Javadoc -->
<module name="JavadocTagContinuationIndentation"> <!-- Java Style Guide: At-clauses -->
Expand Down Expand Up @@ -462,4 +441,4 @@

<!-- Stricter checks end -->
</module>
</module>
</module>
12 changes: 12 additions & 0 deletions .baseline/idea/intellij-java-palantir-style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@
<package name="" withSubpackages="true" static="false" />
</value>
</option>
<DO_NOT_IMPORT_INNER>
<CLASS name="Builder" />
<CLASS name="Callback" />
<CLASS name="Class" />
<CLASS name="Entry" />
<CLASS name="Enum" />
<CLASS name="Factory" />
<CLASS name="Type" />
<CLASS name="Key" />
<CLASS name="Id" />
<CLASS name="Provider" />
</DO_NOT_IMPORT_INNER>
</GroovyCodeStyleSettings>
<option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
<option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
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.palantir.javaformat:gradle-palantir-java-format:1.0.1'
classpath 'com.gradle.publish:plugin-publish-plugin:0.15.0'
classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.0.0'
classpath 'com.palantir.baseline:gradle-baseline-java:3.23.0'
classpath 'com.palantir.baseline:gradle-baseline-java:4.9.0'
classpath 'com.palantir.gradle.conjure:gradle-conjure:5.10.0'
classpath 'com.palantir.gradle.gitversion:gradle-git-version:0.12.3'
classpath 'gradle.plugin.org.inferred:gradle-processors:3.3.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,27 +185,25 @@ private static Optional<List<MetricSchema>> inferProjectDependencyMetrics(Projec
return Optional.of(ObjectMappers.loadMetricSchema(file));
}

private static java.util.Optional<List<MetricSchema>> getExternalMetrics(
ComponentIdentifier id, ResolvedArtifact artifact) {
private static Optional<List<MetricSchema>> getExternalMetrics(ComponentIdentifier id, ResolvedArtifact artifact) {
if (!artifact.getFile().exists()) {
log.debug("Artifact did not exist: {}", artifact.getFile());
return java.util.Optional.empty();
return Optional.empty();
} else if (!Files.getFileExtension(artifact.getFile().getName()).equals("jar")) {
log.debug("Artifact is not jar: {}", artifact.getFile());
return java.util.Optional.empty();
return Optional.empty();
}

try {
ZipFile zipFile = new ZipFile(artifact.getFile());
ZipEntry manifestEntry = zipFile.getEntry(MetricSchemaPlugin.METRIC_SCHEMA_RESOURCE);
if (manifestEntry == null) {
log.debug("Manifest file does not exist in JAR: {}", id);
return java.util.Optional.empty();
return Optional.empty();
}

try (InputStream is = zipFile.getInputStream(manifestEntry)) {
return java.util.Optional.of(
ObjectMappers.mapper.readValue(is, new TypeReference<List<MetricSchema>>() {}));
return Optional.of(ObjectMappers.mapper.readValue(is, new TypeReference<List<MetricSchema>>() {}));
}
} catch (IOException e) {
throw new RuntimeException("Failed to load external monitors");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.util.regex.Pattern;
import org.immutables.value.Value;

// Automatically suppressed to unblock enforcement in new code
@SuppressWarnings("ImmutablesStyle")
@Value.Immutable
@Value.Style(
visibility = Value.Style.ImplementationVisibility.PACKAGE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.palantir.metric.schema.MetricNamespace;
import org.immutables.value.Value;

// Automatically suppressed to unblock enforcement in new code
@SuppressWarnings("ImmutablesStyle")
@Value.Immutable
@Value.Style(
overshadowImplementation = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.List;
import org.immutables.value.Value;

// Automatically suppressed to unblock enforcement in new code
@SuppressWarnings("ImmutablesStyle")
@Value.Immutable
@Value.Style(
overshadowImplementation = true,
Expand Down