Skip to content

Commit bac4896

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

File tree

18 files changed

+68
-22
lines changed

18 files changed

+68
-22
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
name: Build Pull Request
1+
name: Build Pull Request 🏭️
22
on: pull_request
33
permissions:
44
contents: read
55
jobs:
66
build:
7-
name: Build Pull Request
7+
name: Build 🏗
88
if: ${{ github.repository == 'spring-projects/spring-boot' }}
99
runs-on: ${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }}
1010
steps:
11-
- name: Check Out Code
11+
- name: Checkout Code 📥
1212
uses: actions/checkout@v6
13-
- name: Build
13+
- name: Build 📦
1414
id: build
1515
uses: ./.github/actions/build
16-
- name: Print JVM Thread Dumps When Cancelled
16+
- name: Log Potentially Cancelled JVM Thread Dumps 📋
1717
if: cancelled()
1818
uses: ./.github/actions/print-jvm-thread-dumps
19-
- name: Upload Build Reports
19+
- name: Upload Build Report 📊
2020
if: failure()
2121
uses: actions/upload-artifact@v6
2222
with:

.github/workflows/distribute.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ permissions:
1919
contents: read
2020
jobs:
2121
distribute-spring-enterprise-release-bundle:
22+
name: Distribute Release Bundle 📦
2223
runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }}
2324
steps:
2425
- name: Create Bundle

.github/workflows/run-codeql-analysis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
name: "Run CodeQL Analysis"
1+
name: Run CodeQL Analysis 📊
22
on:
33
push:
44
pull_request:
55
workflow_dispatch:
66
permissions: read-all
77
jobs:
88
run-analysis:
9+
name: Inspect 🔎
910
permissions:
1011
actions: read
1112
contents: read

.github/workflows/sanity.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Sanity Check 🕊️
2+
on:
3+
pull_request:
4+
permissions: read-all
5+
jobs:
6+
verify:
7+
name: Inspect 🔎
8+
runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }}
9+
steps:
10+
- name: Checkout Code 📥
11+
uses: actions/checkout@v6
12+
- name: Build 📦
13+
id: build
14+
uses: ./.github/actions/build
15+
- name: Rewrite ♻️
16+
run: ./gradlew rewriteDryRun -Dorg.gradle.jvmargs=-Xmx10G

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/main/java/org/springframework/boot/buildpack/platform/build/Cache.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ public String getDescription() {
7070
* @return the cache, or {@code null} if it is not a volume cache
7171
*/
7272
public @Nullable Volume getVolume() {
73-
return (this.format.equals(Format.VOLUME)) ? (Volume) this : null;
73+
return (this.format == Format.VOLUME) ? (Volume) this : null;
7474
}
7575

7676
/**
7777
* Return the details of the cache if it is a bind cache.
7878
* @return the cache, or {@code null} if it is not a bind cache
7979
*/
8080
public @Nullable Bind getBind() {
81-
return (this.format.equals(Format.BIND)) ? (Bind) this : null;
81+
return (this.format == Format.BIND) ? (Bind) this : null;
8282
}
8383

8484
/**
@@ -120,7 +120,7 @@ public boolean equals(@Nullable Object obj) {
120120
return false;
121121
}
122122
Cache other = (Cache) obj;
123-
return Objects.equals(this.format, other.format);
123+
return this.format == other.format;
124124
}
125125

126126
@Override

core/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCapture.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public String getAll() {
122122
*/
123123
@Override
124124
public String getOut() {
125-
return get(this.out, Type.OUT::equals);
125+
return get(this.out, (v) -> v == Type.OUT);
126126
}
127127

128128
/**
@@ -131,7 +131,7 @@ public String getOut() {
131131
*/
132132
@Override
133133
public String getErr() {
134-
return get(this.err, Type.ERR::equals);
134+
return get(this.err, (v) -> v == Type.ERR);
135135
}
136136

137137
/**

core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private void addToSources(MutablePropertySources sources, Type type, String name
211211
}
212212
}
213213
Map<String, Object> source = new LinkedHashMap<>(this.properties);
214-
sources.addFirst((type.equals(Type.MAP) ? new MapPropertySource(name, source)
214+
sources.addFirst((type == Type.MAP ? new MapPropertySource(name, source)
215215
: new SystemEnvironmentPropertySource(name, source)));
216216
}
217217

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
project.apply(plugin: "org.openrewrite.rewrite")
2+
repositories {
3+
mavenCentral()
4+
}
5+
rewrite {
6+
activeRecipe("org.springframework.boot.openrewrite.SanityCheck")
7+
configFile = project.getRootProject().file("${rootDir}/gradle/plugins/config/sanity.yml")
8+
setExportDatatables(true)
9+
setFailOnDryRunResults(true)
10+
}

gradle/plugins/config/sanity.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
type: specs.openrewrite.org/v1beta/recipe
3+
name: org.springframework.boot.openrewrite.SanityCheck
4+
displayName: Apply all common best practices
5+
description: Comprehensive code quality recipe combining modernization, security, and best practices.
6+
recipeList:
7+
- tech.picnic.errorprone.refasterrules.EqualityRulesRecipes
8+
# - org.openrewrite.java.testing.junit.JupiterBestPractices
9+
# - org.openrewrite.java.testing.junit5.CleanupAssertions
10+
# - org.openrewrite.java.testing.junit5.StaticImports
11+
# - org.openrewrite.staticanalysis.EqualsAvoidsNull
12+
# - tech.picnic.errorprone.refasterrules.NullRulesRecipes
13+
# - tech.picnic.errorprone.refasterrules.StringRulesRecipes
14+
# - tech.picnic.errorprone.refasterrules.TimeRulesRecipes
15+
---

0 commit comments

Comments
 (0)