Skip to content

Commit

Permalink
upgrade errorprone-support static analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Nov 2, 2024
1 parent 3457bf5 commit 12e5741
Show file tree
Hide file tree
Showing 24 changed files with 99 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Dependency Review
uses: actions/dependency-review-action@a6993e2c61fd5dc440b409aa1d6904921c5e1894 # v4.3.5
uses: actions/dependency-review-action@4081bf99e2866ebe428fc0477b69eb4fcda7220a # v4.4.0
with:
license-check: false
comment-summary-in-pr: on-failure
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qodana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: check -x test
- name: Qodana - Code Inspection
uses: JetBrains/qodana-action@4f04143e8d52028fee27c2a219c8856035094962 # v2024.2.5
uses: JetBrains/qodana-action@31d6f3309b31c566758e1314a3d9ef0dff75ecbd # v2024.2.6
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spelling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
objects.githubusercontent.com:443
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Typos
uses: crate-ci/typos@0d9e0c2c1bd7f770f6eb90f87780848ca02fc12c # v1.26.8
uses: crate-ci/typos@d01f29c66d1bf1a08730750f61d86c210b0d039d # v1.27.0
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Year;
import java.time.ZoneId;
import java.util.ArrayList;
Expand Down Expand Up @@ -144,6 +143,7 @@ private NavigableMap<String, ImmutableSet<Feature>> getClassNameToFeatures() {
return classNameToFeatures;
}

@SuppressWarnings("SetsImmutableEnumSetIterable")
private ImmutableSet<Feature> getFeatures(List<Object> combination) {
var features = new LinkedHashSet<Feature>();
features.add(((Boolean) combination.get(0)) ? Feature.STRONG_KEYS : Feature.WEAK_KEYS);
Expand All @@ -156,6 +156,7 @@ private ImmutableSet<Feature> getFeatures(List<Object> combination) {
if (features.contains(Feature.MAXIMUM_WEIGHT)) {
features.remove(Feature.MAXIMUM_SIZE);
}
// In featureByIndex order for class naming
return ImmutableSet.copyOf(features);
}

Expand All @@ -164,6 +165,7 @@ private Set<List<Object>> combinations() {
return Sets.cartesianProduct(sets);
}

@SuppressWarnings("SetsImmutableEnumSetIterable")
private TypeSpec makeLocalCacheSpec(String className,
boolean isFinal, ImmutableSet<Feature> features) {
TypeName superClass;
Expand All @@ -174,8 +176,9 @@ private TypeSpec makeLocalCacheSpec(String className,
generateFeatures = features;
superClass = BOUNDED_LOCAL_CACHE;
} else {
// Requires that parentFeatures is in featureByIndex order for super class naming
parentFeatures = ImmutableSet.copyOf(Iterables.limit(features, features.size() - 1));
generateFeatures = ImmutableSet.of(features.asList().get(features.size() - 1));
generateFeatures = Sets.immutableEnumSet(features.asList().get(features.size() - 1));
superClass = ParameterizedTypeName.get(ClassName.bestGuess(
encode(Feature.makeClassName(parentFeatures))), kTypeVar, vTypeVar);
}
Expand Down Expand Up @@ -208,6 +211,6 @@ private static String encode(String className) {
}

public static void main(String[] args) throws FormatterException, IOException {
new LocalCacheFactoryGenerator(Paths.get(args[0])).generate();
new LocalCacheFactoryGenerator(Path.of(args[0])).generate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Year;
import java.time.ZoneId;
import java.util.ArrayList;
Expand Down Expand Up @@ -146,6 +145,7 @@ private NavigableMap<String, ImmutableSet<Feature>> getClassNameToFeatures() {
return classNameToFeatures;
}

@SuppressWarnings("SetsImmutableEnumSetIterable")
private ImmutableSet<Feature> getFeatures(List<Object> combination) {
var features = new LinkedHashSet<Feature>();
features.add((Feature) combination.get(0));
Expand All @@ -158,9 +158,11 @@ private ImmutableSet<Feature> getFeatures(List<Object> combination) {
if (features.contains(Feature.MAXIMUM_WEIGHT)) {
features.remove(Feature.MAXIMUM_SIZE);
}
// In featureByIndex order for class naming
return ImmutableSet.copyOf(features);
}

@SuppressWarnings("SetsImmutableEnumSetIterable")
private TypeSpec makeNodeSpec(String className, boolean isFinal, ImmutableSet<Feature> features) {
TypeName superClass;
ImmutableSet<Feature> parentFeatures;
Expand All @@ -170,8 +172,9 @@ private TypeSpec makeNodeSpec(String className, boolean isFinal, ImmutableSet<Fe
generateFeatures = features;
superClass = TypeName.OBJECT;
} else {
// Requires that parentFeatures is in featureByIndex order for super class naming
parentFeatures = ImmutableSet.copyOf(Iterables.limit(features, features.size() - 1));
generateFeatures = ImmutableSet.of(features.asList().get(features.size() - 1));
generateFeatures = Sets.immutableEnumSet(features.asList().get(features.size() - 1));
superClass = ParameterizedTypeName.get(ClassName.get(PACKAGE_NAME,
encode(Feature.makeClassName(parentFeatures))), kTypeVar, vTypeVar);
}
Expand Down Expand Up @@ -215,6 +218,6 @@ private static String encode(String className) {
}

public static void main(String[] args) throws FormatterException, IOException {
new NodeFactoryGenerator(Paths.get(args[0])).generate();
new NodeFactoryGenerator(Path.of(args[0])).generate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public void getExpirationDelay_fuzzy(long clock, long duration, long[] times) {

@DataProvider(name = "clock")
public Iterator<Object> providesClock() {
return LongStream.of(CLOCKS).mapToObj(o -> (Object) o).iterator();
return LongStream.of(CLOCKS).mapToObj(Object.class::cast).iterator();
}

@DataProvider(name = "schedule")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,61 +89,64 @@ public static void initialize(CacheContext context) {
@SuppressWarnings("IdentityConversion")
private Set<List<Object>> combinations() {
var asyncLoader = ImmutableSet.of(true, false);
var loaders = ImmutableSet.copyOf(cacheSpec.loader());
var keys = filterTypes(options.keys(), cacheSpec.keys());
var values = filterTypes(options.values(), cacheSpec.values());
var statistics = filterTypes(options.stats(), cacheSpec.stats());
var computations = filterTypes(options.compute(), cacheSpec.compute());
var loaders = Sets.immutableEnumSet(Arrays.asList(cacheSpec.loader()));
var implementations = filterTypes(options.implementation(), cacheSpec.implementation());

if (isAsyncOnly) {
values = values.contains(ReferenceType.STRONG)
? ImmutableSet.of(ReferenceType.STRONG)
? Sets.immutableEnumSet(ReferenceType.STRONG)
: ImmutableSet.of();
computations = Sets.intersection(computations, Set.of(Compute.ASYNC));
computations = Sets.intersection(computations,
Sets.immutableEnumSet(Compute.ASYNC)).immutableCopy();
}
if (!isGuavaCompatible || isAsyncOnly || computations.equals(ImmutableSet.of(Compute.ASYNC))) {
implementations = Sets.difference(implementations, Set.of(Implementation.Guava));
if (!isGuavaCompatible || isAsyncOnly
|| computations.equals(Sets.immutableEnumSet(Compute.ASYNC))) {
implementations = Sets.difference(implementations,
Sets.immutableEnumSet(Implementation.Guava)).immutableCopy();
}
if (computations.equals(ImmutableSet.of(Compute.SYNC))) {
if (computations.equals(Sets.immutableEnumSet(Compute.SYNC))) {
asyncLoader = ImmutableSet.of(false);
}

if (isLoadingOnly) {
loaders = Sets.difference(loaders, Set.of(Loader.DISABLED)).immutableCopy();
loaders = Sets.difference(loaders, Sets.immutableEnumSet(Loader.DISABLED)).immutableCopy();
}

if (computations.isEmpty() || implementations.isEmpty()
|| keys.isEmpty() || values.isEmpty()) {
if (computations.isEmpty() || implementations.isEmpty() || keys.isEmpty() || values.isEmpty()) {
return ImmutableSet.of();
}
return Sets.cartesianProduct(
ImmutableSet.copyOf(cacheSpec.initialCapacity()),
ImmutableSet.copyOf(statistics),
ImmutableSet.copyOf(cacheSpec.weigher()),
ImmutableSet.copyOf(cacheSpec.maximumSize()),
ImmutableSet.copyOf(cacheSpec.expiry()),
ImmutableSet.copyOf(cacheSpec.expireAfterAccess()),
ImmutableSet.copyOf(cacheSpec.expireAfterWrite()),
ImmutableSet.copyOf(cacheSpec.refreshAfterWrite()),
ImmutableSet.copyOf(keys),
ImmutableSet.copyOf(values),
ImmutableSet.copyOf(cacheSpec.executor()),
ImmutableSet.copyOf(cacheSpec.scheduler()),
ImmutableSet.copyOf(cacheSpec.removalListener()),
ImmutableSet.copyOf(cacheSpec.evictionListener()),
ImmutableSet.copyOf(cacheSpec.population()),
ImmutableSet.copyOf(asyncLoader),
ImmutableSet.copyOf(computations),
ImmutableSet.copyOf(loaders),
ImmutableSet.copyOf(implementations));
Sets.immutableEnumSet(Arrays.asList(cacheSpec.initialCapacity())),
Sets.immutableEnumSet(statistics),
Sets.immutableEnumSet(Arrays.asList(cacheSpec.weigher())),
Sets.immutableEnumSet(Arrays.asList(cacheSpec.maximumSize())),
Sets.immutableEnumSet(Arrays.asList(cacheSpec.expiry())),
Sets.immutableEnumSet(Arrays.asList(cacheSpec.expireAfterAccess())),
Sets.immutableEnumSet(Arrays.asList(cacheSpec.expireAfterWrite())),
Sets.immutableEnumSet(Arrays.asList(cacheSpec.refreshAfterWrite())),
Sets.immutableEnumSet(keys),
Sets.immutableEnumSet(values),
Sets.immutableEnumSet(Arrays.asList(cacheSpec.executor())),
Sets.immutableEnumSet(Arrays.asList(cacheSpec.scheduler())),
Sets.immutableEnumSet(Arrays.asList(cacheSpec.removalListener())),
Sets.immutableEnumSet(Arrays.asList(cacheSpec.evictionListener())),
Sets.immutableEnumSet(Arrays.asList(cacheSpec.population())),
asyncLoader,
Sets.immutableEnumSet(computations),
Sets.immutableEnumSet(loaders),
Sets.immutableEnumSet(implementations));
}

/** Returns the set of options filtered if a specific type is specified. */
private static <T> Set<T> filterTypes(Optional<T> type, T[] options) {
private static <T extends Enum<T>> ImmutableSet<T> filterTypes(Optional<T> type, T[] options) {
return type.isPresent()
? Sets.intersection(Set.of(options), Set.of(type.orElseThrow()))
: ImmutableSet.copyOf(options);
? Sets.intersection(Sets.immutableEnumSet(Arrays.asList(options)),
Set.of(type.orElseThrow())).immutableCopy()
: Sets.immutableEnumSet(Arrays.asList(options));
}

/** Returns a new cache context based on the combination. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-2-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-2-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-2-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-2-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-2-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-2-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ auto-value = "1.11.0"
awaitility = "4.2.2"
bcel = "6.10.0"
bnd = "7.0.0"
bouncycastle-jdk18on = "1.78.1"
bouncycastle-jdk18on = "1.79"
cache2k = "2.6.1.Final"
caffeine = "3.1.8"
checker-framework = "3.48.1"
checkstyle = "10.18.2"
checker-framework = "3.48.2"
checkstyle = "10.20.0"
coherence = "22.06.2"
commons-collections4 = "4.4"
commons-compress = "1.27.1"
Expand All @@ -19,12 +19,12 @@ commons-text = "1.12.0"
concurrentlinkedhashmap = "1.4.2"
config = "1.4.3"
coveralls = "2.12.2"
dependency-check = "11.0.0"
dependency-check = "11.1.0"
eclipse-collections = "12.0.0.M3"
ehcache3 = "3.10.8"
errorprone = "2.35.1"
errorprone-plugin = "4.1.0"
errorprone-support = "0.18.0"
errorprone-support = "0.19.0"
expiring-map = "0.5.11"
fast-filter = "1.0.2"
fastutil = "8.5.15"
Expand All @@ -42,7 +42,7 @@ hazelcast = "5.3.7"
httpclient = "4.5.14"
idea = "1.1.9"
jackrabbit = "1.70.0"
jackson = "2.18.0"
jackson = "2.18.1"
jacoco = "0.8.12"
jakarta-inject = "2.0.1"
jamm = "0.4.0"
Expand All @@ -68,7 +68,7 @@ kotlin = "2.0.21"
lincheck = "2.34"
mockito = "5.14.2"
nexus-publish = "2.0.0"
nullaway = "0.12.0"
nullaway = "0.12.1"
nullaway-plugin = "2.1.0"
okhttp-bom = "4.12.0"
okio-bom = "3.9.1"
Expand All @@ -85,8 +85,8 @@ slf4j-test = "3.0.1"
snakeyaml = "2.3"
sonarqube = "5.1.0.4882"
spotbugs = "4.8.6"
spotbugs-contrib = "7.6.5"
spotbugs-plugin = "6.0.25"
spotbugs-contrib = "7.6.6"
spotbugs-plugin = "6.0.26"
stream = "2.9.8"
tcache = "2.0.1"
testng = "7.10.2"
Expand All @@ -96,7 +96,7 @@ versions = "0.51.0"
xz = "1.10"
ycsb = "0.17.0"
zero-allocation-hashing = "0.26ea0"
zstd = "1.5.6-6"
zstd = "1.5.6-7"

[libraries]
asm-bom = { module = "org.ow2.asm:asm-bom", version.ref = "asm" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies {

val javaVersion = JavaLanguageVersion.of(System.getenv("JAVA_VERSION")?.toIntOrNull() ?: 11)
val javaVendor = System.getenv("JAVA_VENDOR")?.let { JvmVendorSpec.matching(it) }
val javaLtsVersion = JavaLanguageVersion.of(21)
java.toolchain {
languageVersion = javaVersion
vendor = javaVendor
Expand All @@ -33,7 +34,7 @@ tasks.withType<JavaCompile>().configureEach {

javaCompiler = javaToolchains.compilerFor {
// jdk 17+ is required by compiler plugins, e.g. error-prone
languageVersion = maxOf(javaVersion, JavaLanguageVersion.of(21))
languageVersion = maxOf(javaVersion, javaLtsVersion)
}

options.compilerArgs.addAll(listOf("-Xlint:all", "-Xlint:-auxiliaryclass", "-Xlint:-classfile",
Expand Down Expand Up @@ -88,9 +89,8 @@ tasks.withType<Javadoc>().configureEach {
use()
quiet()
noTimestamp()
if (javaVersion.canCompileOrRun(18)) {
addStringOption("-link-modularity-mismatch", "info")
}
addStringOption("-release", javaVersion.toString())
addStringOption("-link-modularity-mismatch", "info")
links(
"https://checkerframework.org/api/",
"https://errorprone.info/api/latest/",
Expand All @@ -104,4 +104,7 @@ tasks.withType<Javadoc>().configureEach {
dependsOn(":caffeine:javadoc")
}
}
javadocTool = javaToolchains.javadocToolFor {
languageVersion = maxOf(javaVersion, javaLtsVersion)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ dependencies {
tasks.withType<Test>().configureEach {
inputs.property("javaVendor", java.toolchain.vendor.get().toString())

// Use --debug-jvm to remotely attach to the test task
jvmArgs("-XX:SoftRefLRUPolicyMSPerMB=0", "-XX:+EnableDynamicAgentLoading", "-Xshare:off")
if ("debug" in systemProperties) {
jvmArgs("-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
}
jvmArgs(defaultJvmArgs())
if (isCI()) {
reports.junitXml.includeSystemOutLog = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ fun errorChecks() = listOf(
fun disabledChecks() = listOf(
"AvoidObjectArrays",
"AndroidJdkLibsChecker",
"ConstantNaming",
"IsInstanceLambdaUsage",
"Java7ApiChecker",
"Java8ApiChecker",
"LexicographicalAnnotationListing",
"MissingSummary",
"MultipleTopLevelClasses",
"PatternMatchingInstanceof",
"Slf4jLoggerDeclaration",
"StaticImport",
"SuppressWarningsWithoutExplanation",
"UngroupedOverloads",
Expand Down
Loading

0 comments on commit 12e5741

Please sign in to comment.