Skip to content

Commit fdf465d

Browse files
author
Vincent Potucek
committed
Add rewrite support for gradle.GradleBestPractices
1 parent 469ffda commit fdf465d

File tree

45 files changed

+254
-162
lines changed

Some content is hidden

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

45 files changed

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

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-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import org.hibernate.query.sqm.CastType;
5959
import org.hibernate.query.common.FetchClauseType;
6060
import org.hibernate.query.sqm.IntervalType;
61-
import org.hibernate.dialect.NullOrdering;
6261
import org.hibernate.query.common.TemporalUnit;
6362
import org.hibernate.query.sqm.mutation.spi.BeforeUseAction;
6463
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableInsertStrategy;

hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/AltibaseFunctionsTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
import org.hibernate.testing.orm.junit.RequiresDialect;
1111
import org.hibernate.testing.orm.junit.SessionFactory;
1212
import org.hibernate.testing.orm.junit.SessionFactoryScope;
13-
import org.junit.jupiter.api.*;
13+
import org.junit.jupiter.api.AfterAll;
14+
import org.junit.jupiter.api.BeforeAll;
15+
import org.junit.jupiter.api.Test;
1416

1517
import java.sql.Date;
1618
import java.sql.SQLException;

hibernate-core/src/main/java/org/hibernate/id/PersistentIdentifierGenerator.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44
*/
55
package org.hibernate.id;
66

7-
import java.util.Properties;
8-
9-
import org.hibernate.generator.GeneratorCreationContext;
10-
117
/**
128
* An {@link IdentifierGenerator} that requires creation of database objects.
139
* <p>
1410
* All instances have access to a special mapping parameter in their
15-
* {@link #configure(GeneratorCreationContext, Properties)} method: schema
11+
* {@link #configure( GeneratorCreationContext, Properties )} method: schema
1612
*
1713
* @author Gavin King
1814
* @author Steve Ebersole

0 commit comments

Comments
 (0)