Skip to content

Commit da8537f

Browse files
author
Vincent Potucek
committed
Add UseStaticImport #48630
Signed-off-by: Vincent Potucek <vpotucek@me.com>
1 parent 927b2ee commit da8537f

69 files changed

Lines changed: 282 additions & 151 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/build/action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ runs:
6969
COMMERCIAL_REPO_USERNAME: ${{ inputs.commercial-repository-username }}
7070
COMMERCIAL_SNAPSHOT_REPO_URL: ${{ inputs.commercial-snapshot-repository-url }}
7171
run: ./gradlew build
72+
- name: Sanity Check
73+
id: sanity
74+
if: ${{ inputs.publish == 'false' }}
75+
shell: bash
76+
env:
77+
COMMERCIAL_RELEASE_REPO_URL: ${{ inputs.commercial-release-repository-url }}
78+
COMMERCIAL_REPO_PASSWORD: ${{ inputs.commercial-repository-password }}
79+
COMMERCIAL_REPO_USERNAME: ${{ inputs.commercial-repository-username }}
80+
COMMERCIAL_SNAPSHOT_REPO_URL: ${{ inputs.commercial-snapshot-repository-url }}
81+
run: ./gradlew rewriteDryRun -Dorg.gradle.jvmargs=-Xmx12G
7282
- name: Publish
7383
id: publish
7484
if: ${{ inputs.publish == 'true' }}

.github/workflows/build-pull-request.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ jobs:
1313
- name: Build
1414
id: build
1515
uses: ./.github/actions/build
16+
- name: Sanity
17+
id: sanity
18+
uses: ./.github/actions/build
1619
- name: Print JVM Thread Dumps When Cancelled
1720
if: cancelled()
1821
uses: ./.github/actions/print-jvm-thread-dumps

build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
import org.gradle.api.tasks.Optional;
3838
import org.jspecify.annotations.Nullable;
3939

40+
import static java.util.Collections.emptySet;
41+
4042
/**
4143
* The properties that are written into the {@code build-info.properties} file.
4244
*
@@ -148,7 +150,7 @@ Map<String, String> getAdditionalIfNotExcluded() {
148150
}
149151

150152
private <T> @Nullable T getIfNotExcluded(Property<T> property, String name, Supplier<@Nullable T> defaultValue) {
151-
if (this.excludes.getOrElse(Collections.emptySet()).contains(name)) {
153+
if (this.excludes.getOrElse(emptySet()).contains(name)) {
152154
return null;
153155
}
154156
if (property.isPresent()) {
@@ -172,7 +174,7 @@ private Map<String, String> coerceToStringValues(Map<String, Object> input) {
172174

173175
private Map<String, Object> applyExclusions(Map<String, Object> input) {
174176
Map<String, Object> output = new HashMap<>();
175-
Set<String> exclusions = this.excludes.getOrElse(Collections.emptySet());
177+
Set<String> exclusions = this.excludes.getOrElse(emptySet());
176178
input.forEach((key, value) -> {
177179
boolean isExcluded = exclusions.contains(key);
178180
if (!isExcluded) {

build-plugin/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/ArtifactsLibrariesTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.springframework.boot.loader.tools.LibraryCoordinates;
4242
import org.springframework.boot.loader.tools.LibraryScope;
4343

44+
import static java.util.Collections.emptySet;
4445
import static org.assertj.core.api.Assertions.assertThat;
4546
import static org.mockito.ArgumentMatchers.assertArg;
4647
import static org.mockito.BDDMockito.given;
@@ -200,7 +201,7 @@ void nonIncludedArtifact() throws IOException {
200201
MavenProject mavenProject = mock(MavenProject.class);
201202
given(mavenProject.getArtifact()).willReturn(artifact);
202203
this.artifacts = Collections.singleton(artifact);
203-
new ArtifactsLibraries(this.artifacts, Collections.emptySet(), Collections.singleton(mavenProject), null,
204+
new ArtifactsLibraries(this.artifacts, emptySet(), Collections.singleton(mavenProject), null,
204205
mock(Log.class))
205206
.doWithLibraries((library) -> assertThat(library.isIncluded()).isFalse());
206207
}

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
plugins {
1818
id "base"
19+
id "org.openrewrite.rewrite" version "7.23.0" apply false
1920
}
2021

2122
description = "Spring Boot Build"
@@ -46,3 +47,5 @@ subprojects {
4647
resolutionStrategy.cacheChangingModulesFor 0, "minutes"
4748
}
4849
}
50+
51+
apply from: rootProject.file("gradle/plugins/config/sanity.gradle")

buildpack/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/io/FilePermissionsTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.nio.file.attribute.FileAttribute;
2424
import java.nio.file.attribute.PosixFilePermission;
2525
import java.nio.file.attribute.PosixFilePermissions;
26-
import java.util.Collections;
2726
import java.util.Set;
2827

2928
import org.junit.jupiter.api.Test;
@@ -32,6 +31,7 @@
3231
import org.junit.jupiter.api.condition.OS;
3332
import org.junit.jupiter.api.io.TempDir;
3433

34+
import static java.util.Collections.emptySet;
3535
import static org.assertj.core.api.Assertions.assertThat;
3636
import static org.assertj.core.api.Assertions.assertThatIOException;
3737
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@@ -86,7 +86,7 @@ void posixPermissionsToUmask() {
8686

8787
@Test
8888
void posixPermissionsToUmaskWithEmptyPermissions() {
89-
Set<PosixFilePermission> permissions = Collections.emptySet();
89+
Set<PosixFilePermission> permissions = emptySet();
9090
assertThat(FilePermissions.posixPermissionsToUmask(permissions)).isZero();
9191
}
9292

configuration-metadata/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/VariableTree.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616

1717
package org.springframework.boot.configurationprocessor.fieldvalues.javac;
1818

19-
import java.util.Collections;
2019
import java.util.Set;
2120

2221
import javax.lang.model.element.Modifier;
2322

23+
import static java.util.Collections.emptySet;
24+
2425
/**
2526
* Reflection based access to {@code com.sun.source.tree.VariableTree}.
2627
*
@@ -49,7 +50,7 @@ ExpressionTree getInitializer() throws Exception {
4950
Set<Modifier> getModifierFlags() throws Exception {
5051
Object modifiers = findMethod("getModifiers").invoke(getInstance());
5152
if (modifiers == null) {
52-
return Collections.emptySet();
53+
return emptySet();
5354
}
5455
return (Set<Modifier>) findMethod(findClass("com.sun.source.tree.ModifiersTree"), "getFlags").invoke(modifiers);
5556
}

core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
import org.springframework.util.CollectionUtils;
6262
import org.springframework.util.StringUtils;
6363

64+
import static java.util.Collections.emptySet;
65+
6466
/**
6567
* {@link DeferredImportSelector} to handle {@link EnableAutoConfiguration
6668
* auto-configuration}. This class can also be subclassed if a custom variant of
@@ -546,7 +548,7 @@ protected static class AutoConfigurationEntry {
546548

547549
private AutoConfigurationEntry() {
548550
this.configurations = Collections.emptyList();
549-
this.exclusions = Collections.emptySet();
551+
this.exclusions = emptySet();
550552
}
551553

552554
/**

core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
import org.springframework.core.type.classreading.MetadataReaderFactory;
3838
import org.springframework.util.Assert;
3939

40+
import static java.util.Collections.emptySet;
41+
4042
/**
4143
* Sort {@link EnableAutoConfiguration auto-configuration} classes into priority order by
4244
* reading {@link AutoConfigureOrder @AutoConfigureOrder},
@@ -226,7 +228,7 @@ private Set<String> getClassNames(String metadataKey, Class<? extends Annotation
226228

227229
private Set<String> getSet(String metadataKey) {
228230
Assert.state(this.autoConfigurationMetadata != null, "'autoConfigurationMetadata' must not be null");
229-
return this.autoConfigurationMetadata.getSet(this.className, metadataKey, Collections.emptySet());
231+
return this.autoConfigurationMetadata.getSet(this.className, metadataKey, emptySet());
230232
}
231233

232234
private Set<String> applyReplacements(Set<String> values) {
@@ -265,7 +267,7 @@ private Set<String> getAnnotationValue(Class<?> annotation) {
265267
Map<String, @Nullable Object> attributes = getAnnotationMetadata()
266268
.getAnnotationAttributes(annotation.getName(), true);
267269
if (attributes == null) {
268-
return Collections.emptySet();
270+
return emptySet();
269271
}
270272
Set<String> result = new LinkedHashSet<>();
271273
String[] value = (String[]) attributes.get("value");

core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
import org.springframework.util.ReflectionUtils;
7373
import org.springframework.util.StringUtils;
7474

75+
import static java.util.Collections.emptySet;
76+
7577
/**
7678
* {@link Condition} that checks for the presence or absence of specific beans.
7779
*
@@ -315,7 +317,7 @@ private Set<String> getNamesOfBeansIgnoredByType(ListableBeanFactory beanFactory
315317
.keySet();
316318
result = addAll(result, ignoredNames);
317319
}
318-
return (result != null) ? result : Collections.emptySet();
320+
return (result != null) ? result : emptySet();
319321
}
320322

321323
private Map<String, @Nullable BeanDefinition> getBeanDefinitionsForType(ListableBeanFactory beanFactory,
@@ -607,7 +609,7 @@ protected Set<String> extractTypes(@Nullable MultiValueMap<String, @Nullable Obj
607609
private Set<String> extract(@Nullable MultiValueMap<String, @Nullable Object> attributes,
608610
String... attributeNames) {
609611
if (CollectionUtils.isEmpty(attributes)) {
610-
return Collections.emptySet();
612+
return emptySet();
611613
}
612614
Set<String> result = new LinkedHashSet<>();
613615
for (String attributeName : attributeNames) {
@@ -621,7 +623,7 @@ else if (value instanceof String string) {
621623
}
622624
}
623625
}
624-
return result.isEmpty() ? Collections.emptySet() : result;
626+
return result.isEmpty() ? emptySet() : result;
625627
}
626628

627629
private void merge(Set<String> result, String... additional) {

0 commit comments

Comments
 (0)