Skip to content

Commit 7decb4d

Browse files
author
Vincent Potucek
committed
Add rewrite support for tech.picnic.errorprone.refasterrules.FileRulesRecipes
1 parent 469ffda commit 7decb4d

File tree

81 files changed

+284
-195
lines changed

Some content is hidden

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

81 files changed

+284
-195
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,10 @@ jobs:
318318
POPULATE_REMOTE_GRADLE_CACHE: ${{ github.event_name == 'push' && github.repository == 'hibernate/hibernate-orm' && 'true' || 'false' }}
319319
DEVELOCITY_ACCESS_KEY: "${{ secrets.DEVELOCITY_ACCESS_KEY }}"
320320

321+
- name: Run rewriteDryRun
322+
run: ./gradlew rewriteDryRun -Dorg.gradle.jvmargs=-Xmx8G
323+
# https://docs.openrewrite.org/reference/faq#im-getting-javalangoutofmemoryerror-java-heap-space-when-running-openrewrite
324+
321325
# For jobs running on 'pull_request', upload build scan data.
322326
# The actual publishing must be done in a separate job (see ci-report.yml).
323327
# We don't write to the remote cache as that would be unsafe.

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ plugins {
3333
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.10'
3434
id 'eclipse'
3535
id "com.dorongold.task-tree" version "4.0.1"
36+
id 'org.openrewrite.rewrite' version '7.12.1' apply false
3637
}
3738

39+
apply from: rootProject.file('gradle/rewrite.gradle')
3840

3941
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4042
// Releasing

gradle/rewrite.gradle

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
apply plugin: 'org.openrewrite.rewrite'
2+
3+
rewrite {
4+
// immense
5+
//activeRecipe("org.openrewrite.java.RemoveUnusedImports")
6+
//activeRecipe("org.openrewrite.java.migrate.UpgradeToJava17")
7+
//activeRecipe("org.openrewrite.staticanalysis.RemoveUnusedLocalVariables")
8+
//activeRecipe("org.openrewrite.staticanalysis.RemoveUnusedPrivateFields")
9+
//activeRecipe("org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods")
10+
//activeRecipe("org.openrewrite.staticanalysis.UnnecessaryParentheses") why spotless dull?
11+
//activeRecipe("tech.picnic.errorprone.refasterrules.BugCheckerRulesRecipes")
12+
//activeRecipe("tech.picnic.errorprone.refasterrules.SuggestedFixRulesRecipes")
13+
// bug
14+
//activeRecipe("org.openrewrite.staticanalysis.NoToStringOnStringType")
15+
//activeRecipe("org.openrewrite.staticanalysis.NoValueOfOnStringType")
16+
activeRecipe("org.openrewrite.gradle.GradleBestPractices")
17+
activeRecipe("org.openrewrite.staticanalysis.UnnecessaryCloseInTryWithResources")
18+
activeRecipe("org.openrewrite.staticanalysis.UnnecessaryReturnAsLastStatement")
19+
activeRecipe("tech.picnic.errorprone.refasterrules.FileRulesRecipes")
20+
// bug
21+
exclusions.add("**StatisticsImpl.java")
22+
exclusions.add("**RevisionsOfEntityQuery.java")
23+
exportDatatables = true
24+
failOnDryRunResults = true
25+
}
26+
27+
dependencies {
28+
//rewrite("org.openrewrite.recipe:rewrite-migrate-java:3.14.1")
29+
rewrite("org.openrewrite.recipe:rewrite-static-analysis:2.14.0")
30+
rewrite("org.openrewrite.recipe:rewrite-third-party:0.24.1")
31+
rewrite("org.openrewrite.recipe:rewrite-rewrite:0.10.1")
32+
}
33+
34+
// FYI: https://github.com/SonarSource/sonarqube/pull/3389
35+
//activeRecipe(
36+
// "org.openrewrite.gradle.GradleBestPractices",
37+
// //"org.openrewrite.java.RemoveUnusedImports",
38+
// //"org.openrewrite.java.migrate.UpgradeToJava17",
39+
// //"org.openrewrite.java.recipes.JavaRecipeBestPractices",
40+
// //"org.openrewrite.java.recipes.RecipeNullabilityBestPractices",
41+
// //"org.openrewrite.java.recipes.RecipeTestingBestPractices",
42+
// //"org.openrewrite.staticanalysis.CodeCleanup",
43+
// //"org.openrewrite.staticanalysis.CommonStaticAnalysis",
44+
// //"org.openrewrite.staticanalysis.EqualsAvoidsNull",
45+
// //"org.openrewrite.staticanalysis.JavaApiBestPractices",
46+
// //"org.openrewrite.staticanalysis.LowercasePackage",
47+
// //"org.openrewrite.staticanalysis.MissingOverrideAnnotation",
48+
// //"org.openrewrite.staticanalysis.ModifierOrder",
49+
// //"org.openrewrite.staticanalysis.NoFinalizer",
50+
// //"org.openrewrite.staticanalysis.RemoveUnusedLocalVariables",
51+
// //"org.openrewrite.staticanalysis.RemoveUnusedPrivateFields",
52+
// //"org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods",
53+
// //"org.openrewrite.staticanalysis.UnnecessaryThrows",
54+
// //"org.sonar.openrewrite.java.AddLicenseHeader", https://github.com/openrewrite/rewrite/issues/5762
55+
// //"tech.picnic.errorprone.refasterrules.BigDecimalRulesRecipes",
56+
// //"tech.picnic.errorprone.refasterrules.BugCheckerRulesRecipes",
57+
// //"tech.picnic.errorprone.refasterrules.CharSequenceRulesRecipes",
58+
// //"tech.picnic.errorprone.refasterrules.ClassRulesRecipes",
59+
// //"tech.picnic.errorprone.refasterrules.CollectionRulesRecipes", bug
60+
// //"tech.picnic.errorprone.refasterrules.ComparatorRulesRecipes",
61+
// //"tech.picnic.errorprone.refasterrules.EqualityRulesRecipes",
62+
// //"tech.picnic.errorprone.refasterrules.FileRulesRecipes",
63+
// //"tech.picnic.errorprone.refasterrules.JUnitRulesRecipes",
64+
// //"tech.picnic.errorprone.refasterrules.MicrometerRulesRecipes",
65+
// //"tech.picnic.errorprone.refasterrules.NullRulesRecipes",
66+
// //"tech.picnic.errorprone.refasterrules.OptionalRulesRecipes",
67+
// //"tech.picnic.errorprone.refasterrules.PatternRulesRecipes",
68+
// //"tech.picnic.errorprone.refasterrules.PreconditionsRulesRecipes",
69+
// //"tech.picnic.errorprone.refasterrules.PrimitiveRulesRecipes",
70+
// //"tech.picnic.errorprone.refasterrules.StreamRulesRecipes",
71+
// //"tech.picnic.errorprone.refasterrules.StringRulesRecipes",
72+
// //"tech.picnic.errorprone.refasterrules.SuggestedFixRulesRecipes",
73+
// //"tech.picnic.errorprone.refasterrules.TimeRulesRecipes",
74+
//)

gradle/wrapper/gradle-wrapper.jar

-19.5 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME
77
zipStorePath=wrapper/dists
8+
distributionSha256Sum=bd71102213493060956ec229d946beee57158dbd89d0e62b91bca0fa2c5f3531

gradlew

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
8890

8991
# Use the maximum available, or set MAX_FD != -1 to use that value.
9092
MAX_FD=maximum

gradlew.bat

100644100755
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
4345
%JAVA_EXE% -version >NUL 2>&1
4446
if %ERRORLEVEL% equ 0 goto execute
4547

46-
echo.
47-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48-
echo.
49-
echo Please set the JAVA_HOME variable in your environment to match the
50-
echo location of your Java installation.
48+
echo. 1>&2
49+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50+
echo. 1>&2
51+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52+
echo location of your Java installation. 1>&2
5153

5254
goto fail
5355

@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5759

5860
if exist "%JAVA_EXE%" goto execute
5961

60-
echo.
61-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62-
echo.
63-
echo Please set the JAVA_HOME variable in your environment to match the
64-
echo location of your Java installation.
62+
echo. 1>&2
63+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64+
echo. 1>&2
65+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66+
echo location of your Java installation. 1>&2
6567

6668
goto fail
6769

hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,9 +1066,6 @@ private void normalizeDataAccess(
10661066
DEPRECATION_LOGGER.deprecatedSetting( JPA_JDBC_DRIVER, JAKARTA_JDBC_DRIVER );
10671067
}
10681068
applyJdbcSettings( url, driver, integrationSettingsCopy, mergedSettings );
1069-
// EARLY EXIT!!
1070-
//noinspection UnnecessaryReturnStatement
1071-
return;
10721069
}
10731070
}
10741071

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/onetoone/OneToOneJoinTableUniquenessTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected Class<?>[] getAnnotatedClasses() {
4444
protected void configure(Configuration configuration) {
4545

4646
try {
47-
output = File.createTempFile( "update_script", ".sql" );
47+
output = Files.createTempFile( "update_script", ".sql" ).toFile();
4848
}
4949
catch (IOException e) {
5050
e.printStackTrace();

hibernate-core/src/test/java/org/hibernate/orm/test/generatedkeys/generated/GeneratedTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void test(SessionFactoryScope scope) {
7070
@Test
7171
@JiraKey("HHH-15900")
7272
public void testGeneratedKeyNotIdentityColumn(SessionFactoryScope scope) throws IOException {
73-
File output = File.createTempFile( "schema_export", ".sql" );
73+
File output = Files.createTempFile( "schema_export", ".sql" ).toFile();
7474
output.deleteOnExit();
7575

7676
final SchemaExport schemaExport = new SchemaExport();

0 commit comments

Comments
 (0)