From a431e71aa093d8571aef62ddf21d6a19f54ae5da Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Mon, 28 Oct 2024 12:52:05 +0100 Subject: [PATCH] Apply formatter --- .../batch/MigrateStepBuilderFactory.java | 6 ++--- .../batch/RemoveDefaultBatchConfigurer.java | 2 +- .../ReplaceSupportClassWithItsInterface.java | 24 +++++++++---------- .../RemoveConstructorBindingAnnotation.java | 2 +- .../MigrateWebMvcConfigurerAdapter.java | 12 +++++----- ...pagateAuthenticationServiceExceptions.java | 4 ++-- .../security6/UseSha256InRememberMe.java | 10 ++++---- .../test/SpringRulesToJUnitExtension.java | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/openrewrite/java/spring/batch/MigrateStepBuilderFactory.java b/src/main/java/org/openrewrite/java/spring/batch/MigrateStepBuilderFactory.java index 3482715c..b38c5eb9 100644 --- a/src/main/java/org/openrewrite/java/spring/batch/MigrateStepBuilderFactory.java +++ b/src/main/java/org/openrewrite/java/spring/batch/MigrateStepBuilderFactory.java @@ -80,7 +80,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDeclarat } @Override - public J.@Nullable MethodDeclaration visitMethodDeclaration(J.MethodDeclaration md, ExecutionContext ctx) { + public J.@Nullable MethodDeclaration visitMethodDeclaration(J.MethodDeclaration md, ExecutionContext ctx) { // Add JobRepository parameter to method if StepBuilderFactory.get(..) is used further down if (!FindMethods.find(md, STEP_BUILDER_FACTORY_GET).isEmpty()) { List params = md.getParameters().stream() @@ -120,13 +120,13 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDeclarat private boolean isJobRepositoryParameter(Statement statement) { return statement instanceof J.VariableDeclarations && TypeUtils.isOfClassType(((J.VariableDeclarations) statement).getType(), - "org.springframework.batch.core.repository.JobRepository"); + "org.springframework.batch.core.repository.JobRepository"); } private boolean isJobBuilderFactoryParameter(Statement statement) { return statement instanceof J.VariableDeclarations && TypeUtils.isOfClassType(((J.VariableDeclarations) statement).getType(), - "org.springframework.batch.core.configuration.annotation.StepBuilderFactory"); + "org.springframework.batch.core.configuration.annotation.StepBuilderFactory"); } } diff --git a/src/main/java/org/openrewrite/java/spring/batch/RemoveDefaultBatchConfigurer.java b/src/main/java/org/openrewrite/java/spring/batch/RemoveDefaultBatchConfigurer.java index f5d1b783..93f7ea42 100644 --- a/src/main/java/org/openrewrite/java/spring/batch/RemoveDefaultBatchConfigurer.java +++ b/src/main/java/org/openrewrite/java/spring/batch/RemoveDefaultBatchConfigurer.java @@ -66,7 +66,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex } @Override - public J.@Nullable MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, ExecutionContext ctx) { + public J.@Nullable MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, ExecutionContext ctx) { J.MethodDeclaration md = super.visitMethodDeclaration(method, ctx); if (overridesDefaultBatchConfigurerMethod(md) || callsDefaultBatchConfigurerSuperConstructor(md)) { // Strip @Override diff --git a/src/main/java/org/openrewrite/java/spring/batch/ReplaceSupportClassWithItsInterface.java b/src/main/java/org/openrewrite/java/spring/batch/ReplaceSupportClassWithItsInterface.java index 7e5f89b1..fd57b303 100644 --- a/src/main/java/org/openrewrite/java/spring/batch/ReplaceSupportClassWithItsInterface.java +++ b/src/main/java/org/openrewrite/java/spring/batch/ReplaceSupportClassWithItsInterface.java @@ -40,7 +40,7 @@ public String getDisplayName() { @Override public String getDescription() { return "As of spring-batch 5.x Listeners has default methods (made possible by a Java 8 baseline) and can be " + - "implemented directly without the need for this adapter."; + "implemented directly without the need for this adapter."; } @Option(displayName = "Fully qualified class name", @@ -63,7 +63,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext ctx) { J.ClassDeclaration cd = super.visitClassDeclaration(classDecl, ctx); if (cd.getExtends() != null && - TypeUtils.isOfClassType(cd.getExtends().getType(), fullyQualifiedClassName)) { + TypeUtils.isOfClassType(cd.getExtends().getType(), fullyQualifiedClassName)) { cd = cd.withExtends(null); updateCursor(cd); // This is an interesting one... JobExecutionListenerSupport implements @@ -77,14 +77,14 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, } cd = JavaTemplate - .builder(JavaType.ShallowClass.build(fullyQualifiedInterfaceName).getClassName()) - .imports(fullyQualifiedInterfaceName) - .javaParser(JavaParser.fromJavaVersion().classpathFromResources(ctx, "spring-batch-core-5", "spring-batch-infrastructure-5")) - .build() - .apply( - getCursor(), - cd.getCoordinates().addImplementsClause() - ); + .builder(JavaType.ShallowClass.build(fullyQualifiedInterfaceName).getClassName()) + .imports(fullyQualifiedInterfaceName) + .javaParser(JavaParser.fromJavaVersion().classpathFromResources(ctx, "spring-batch-core-5", "spring-batch-infrastructure-5")) + .build() + .apply( + getCursor(), + cd.getCoordinates().addImplementsClause() + ); cd = (J.ClassDeclaration) new RemoveSuperStatementVisitor().visitNonNull(cd, ctx, getCursor().getParentOrThrow()); maybeRemoveImport(fullyQualifiedClassName); maybeAddImport(fullyQualifiedInterfaceName); @@ -98,8 +98,8 @@ class RemoveSuperStatementVisitor extends JavaIsoVisitor { final MethodMatcher wm = new MethodMatcher(fullyQualifiedClassName + " *(..)"); @Override - public J.@Nullable MethodInvocation visitMethodInvocation(J.MethodInvocation method, - ExecutionContext ctx) { + public J.@Nullable MethodInvocation visitMethodInvocation(J.MethodInvocation method, + ExecutionContext ctx) { J.MethodInvocation mi = super.visitMethodInvocation(method, ctx); if (wm.matches(method.getMethodType())) { //noinspection DataFlowIssue diff --git a/src/main/java/org/openrewrite/java/spring/boot3/RemoveConstructorBindingAnnotation.java b/src/main/java/org/openrewrite/java/spring/boot3/RemoveConstructorBindingAnnotation.java index 253b609d..39ce8bc8 100644 --- a/src/main/java/org/openrewrite/java/spring/boot3/RemoveConstructorBindingAnnotation.java +++ b/src/main/java/org/openrewrite/java/spring/boot3/RemoveConstructorBindingAnnotation.java @@ -150,7 +150,7 @@ public RemoveTargetAnnotation(J.Annotation targetToRemove) { } @Override - public J.@Nullable Annotation visitAnnotation(J.Annotation annotation, ExecutionContext ctx) { + public J.@Nullable Annotation visitAnnotation(J.Annotation annotation, ExecutionContext ctx) { if (targetToRemove == annotation) { return null; } diff --git a/src/main/java/org/openrewrite/java/spring/framework/MigrateWebMvcConfigurerAdapter.java b/src/main/java/org/openrewrite/java/spring/framework/MigrateWebMvcConfigurerAdapter.java index b3caf5e8..5c4f4b2f 100644 --- a/src/main/java/org/openrewrite/java/spring/framework/MigrateWebMvcConfigurerAdapter.java +++ b/src/main/java/org/openrewrite/java/spring/framework/MigrateWebMvcConfigurerAdapter.java @@ -58,11 +58,11 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex updateCursor(cd); } cd = JavaTemplate.builder("WebMvcConfigurer") - .contextSensitive() - .imports("org.springframework.web.servlet.config.annotation.WebMvcConfigurer") - .javaParser(JavaParser.fromJavaVersion() - .classpathFromResources(ctx, "spring-webmvc-5.*")) - .build().apply(getCursor(), cd.getCoordinates().addImplementsClause()); + .contextSensitive() + .imports("org.springframework.web.servlet.config.annotation.WebMvcConfigurer") + .javaParser(JavaParser.fromJavaVersion() + .classpathFromResources(ctx, "spring-webmvc-5.*")) + .build().apply(getCursor(), cd.getCoordinates().addImplementsClause()); updateCursor(cd); cd = (J.ClassDeclaration) new RemoveSuperStatementVisitor().visitNonNull(cd, ctx, getCursor().getParentOrThrow()); maybeRemoveImport("org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter"); @@ -75,7 +75,7 @@ class RemoveSuperStatementVisitor extends JavaIsoVisitor { final MethodMatcher wm = new MethodMatcher("org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter *(..)"); @Override - public J.@Nullable MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { + public J.@Nullable MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { J.MethodInvocation mi = super.visitMethodInvocation(method, ctx); if (wm.matches(method.getMethodType())) { return null; diff --git a/src/main/java/org/openrewrite/java/spring/security6/PropagateAuthenticationServiceExceptions.java b/src/main/java/org/openrewrite/java/spring/security6/PropagateAuthenticationServiceExceptions.java index df5a6057..c417e686 100644 --- a/src/main/java/org/openrewrite/java/spring/security6/PropagateAuthenticationServiceExceptions.java +++ b/src/main/java/org/openrewrite/java/spring/security6/PropagateAuthenticationServiceExceptions.java @@ -40,7 +40,7 @@ public String getDisplayName() { @Override public String getDescription() { return "Remove any calls matching `AuthenticationEntryPointFailureHandler.setRethrowAuthenticationServiceException(true)`. " + - "See the corresponding [Sprint Security 6.0 migration step](https://docs.spring.io/spring-security/reference/6.0.0/migration/servlet/authentication.html#_propagate_authenticationserviceexceptions) for details."; + "See the corresponding [Sprint Security 6.0 migration step](https://docs.spring.io/spring-security/reference/6.0.0/migration/servlet/authentication.html#_propagate_authenticationserviceexceptions) for details."; } @Override @@ -48,7 +48,7 @@ public TreeVisitor getVisitor() { return Preconditions.check(new UsesType<>("org.springframework.security.web.authentication.AuthenticationEntryPointFailureHandler", true), new JavaIsoVisitor() { @Override - public J.@Nullable MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { + public J.@Nullable MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { method = super.visitMethodInvocation(method, ctx); if (method.getSelect() != null && method.getArguments().size() == 1 && MATCHER.matches(method)) { Expression arg0 = method.getArguments().get(0); diff --git a/src/main/java/org/openrewrite/java/spring/security6/UseSha256InRememberMe.java b/src/main/java/org/openrewrite/java/spring/security6/UseSha256InRememberMe.java index 54a3e332..783640fd 100644 --- a/src/main/java/org/openrewrite/java/spring/security6/UseSha256InRememberMe.java +++ b/src/main/java/org/openrewrite/java/spring/security6/UseSha256InRememberMe.java @@ -33,10 +33,10 @@ public class UseSha256InRememberMe extends Recipe { private static final JavaType.Class REMEMBER_ME_TOKEN_ALGORITHM_TYPE = (JavaType.Class) JavaType.buildType("org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices$RememberMeTokenAlgorithm"); private static final MethodMatcher REMEMBER_ME_SERVICES_CONSTRUCTOR_MATCHER = new MethodMatcher("org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices (String, org.springframework.security.core.userdetails.UserDetailsService, " + - REMEMBER_ME_TOKEN_ALGORITHM_TYPE.getFullyQualifiedName() + ")"); + REMEMBER_ME_TOKEN_ALGORITHM_TYPE.getFullyQualifiedName() + ")"); private static final MethodMatcher REMEMBER_ME_SERVICES_SET_MATCHING_ALGORITHM_MATCHER = new MethodMatcher("org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices setMatchingAlgorithm(" + - REMEMBER_ME_TOKEN_ALGORITHM_TYPE.getFullyQualifiedName() + ")"); + REMEMBER_ME_TOKEN_ALGORITHM_TYPE.getFullyQualifiedName() + ")"); @Override public String getDisplayName() { @@ -46,7 +46,7 @@ public String getDisplayName() { @Override public String getDescription() { return "As of Spring Security 6.0 the SHA-256 algorithm is the default for the encoding and matching algorithm used by `TokenBasedRememberMeServices` and does thus no longer need to be explicitly configured. " + - "See the corresponding [Sprint Security 6.0 migration step](https://docs.spring.io/spring-security/reference/6.0.0/migration/servlet/authentication.html#servlet-opt-in-sha256-rememberme) for details."; + "See the corresponding [Sprint Security 6.0 migration step](https://docs.spring.io/spring-security/reference/6.0.0/migration/servlet/authentication.html#servlet-opt-in-sha256-rememberme) for details."; } @Override @@ -65,10 +65,10 @@ public J.NewClass visitNewClass(J.NewClass newClass, ExecutionContext ctx) { @Override @SuppressWarnings("DataFlowIssue") - public J.@Nullable MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { + public J.@Nullable MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { method = super.visitMethodInvocation(method, ctx); if (method.getSelect() != null && method.getArguments().size() == 1 && - REMEMBER_ME_SERVICES_SET_MATCHING_ALGORITHM_MATCHER.matches(method)) { + REMEMBER_ME_SERVICES_SET_MATCHING_ALGORITHM_MATCHER.matches(method)) { if (isSha256Algorithm(method.getArguments().get(0), getCursor())) { return null; } diff --git a/src/main/java/org/openrewrite/java/spring/test/SpringRulesToJUnitExtension.java b/src/main/java/org/openrewrite/java/spring/test/SpringRulesToJUnitExtension.java index b6207604..3e1c569a 100644 --- a/src/main/java/org/openrewrite/java/spring/test/SpringRulesToJUnitExtension.java +++ b/src/main/java/org/openrewrite/java/spring/test/SpringRulesToJUnitExtension.java @@ -59,7 +59,7 @@ public TreeVisitor getVisitor() { new JavaIsoVisitor() { @Override - public J.@Nullable VariableDeclarations visitVariableDeclarations(J.VariableDeclarations multiVariable, ExecutionContext ctx) { + public J.@Nullable VariableDeclarations visitVariableDeclarations(J.VariableDeclarations multiVariable, ExecutionContext ctx) { J.VariableDeclarations vd = super.visitVariableDeclarations(multiVariable, ctx); if (TypeUtils.isOfClassType(vd.getTypeAsFullyQualified(), SPRING_CLASS_RULE) || TypeUtils.isOfClassType(vd.getTypeAsFullyQualified(), SPRING_METHOD_RULE)) {