diff --git a/src/main/java/org/openrewrite/java/spring/AutowiredFieldIntoConstructorParameterVisitor.java b/src/main/java/org/openrewrite/java/spring/AutowiredFieldIntoConstructorParameterVisitor.java index bfe5d9060..6514ed869 100644 --- a/src/main/java/org/openrewrite/java/spring/AutowiredFieldIntoConstructorParameterVisitor.java +++ b/src/main/java/org/openrewrite/java/spring/AutowiredFieldIntoConstructorParameterVisitor.java @@ -112,9 +112,9 @@ public J visitVariableDeclarations(VariableDeclarations multiVariable, Execution return multiVariable; } VariableDeclarations mv = multiVariable; - if (blockCursor.getParent() != null && blockCursor.getParent().getValue() instanceof ClassDeclaration - && multiVariable.getVariables().size() == 1 - && fieldName.equals(multiVariable.getVariables().get(0).getName().getSimpleName())) { + if (blockCursor.getParent() != null && blockCursor.getParent().getValue() instanceof ClassDeclaration && + multiVariable.getVariables().size() == 1 && + fieldName.equals(multiVariable.getVariables().get(0).getName().getSimpleName())) { mv = (VariableDeclarations) new RemoveAnnotationVisitor(new AnnotationMatcher("@" + AUTOWIRED)).visitNonNull(multiVariable, p); if (mv != multiVariable && multiVariable.getTypeExpression() != null) { @@ -161,10 +161,10 @@ public J visitBlock(Block block, ExecutionContext p) { ClassDeclaration classDecl = (ClassDeclaration) n; JavaType.FullyQualified typeFqn = TypeUtils.asFullyQualified(type.getType()); if (typeFqn != null && classDecl.getKind() == ClassDeclaration.Kind.Type.Class && className.equals(classDecl.getSimpleName())) { - JavaTemplate.Builder template = JavaTemplate.builder("" - + classDecl.getSimpleName() + "(" + typeFqn.getClassName() + " " + fieldName + ") {\n" - + "this." + fieldName + " = " + fieldName + ";\n" - + "}\n" + JavaTemplate.Builder template = JavaTemplate.builder("" + + classDecl.getSimpleName() + "(" + typeFqn.getClassName() + " " + fieldName + ") {\n" + + "this." + fieldName + " = " + fieldName + ";\n" + + "}\n" ).contextSensitive(); FullyQualified fq = TypeUtils.asFullyQualified(type.getType()); if (fq != null) { diff --git a/src/main/java/org/openrewrite/java/spring/BeanMethodsNotPublic.java b/src/main/java/org/openrewrite/java/spring/BeanMethodsNotPublic.java index 002186c60..fc0434fd1 100644 --- a/src/main/java/org/openrewrite/java/spring/BeanMethodsNotPublic.java +++ b/src/main/java/org/openrewrite/java/spring/BeanMethodsNotPublic.java @@ -51,8 +51,8 @@ private static class BeanMethodsNotPublicVisitor extends JavaIsoVisitor(new MethodMatcher(method), null)); } diff --git a/src/main/java/org/openrewrite/java/spring/ChangeSpringPropertyKey.java b/src/main/java/org/openrewrite/java/spring/ChangeSpringPropertyKey.java index c2e953116..79a6d46f3 100644 --- a/src/main/java/org/openrewrite/java/spring/ChangeSpringPropertyKey.java +++ b/src/main/java/org/openrewrite/java/spring/ChangeSpringPropertyKey.java @@ -92,8 +92,8 @@ public TreeVisitor getVisitor() { } private String exceptRegex() { - return except == null || except.isEmpty() - ? "" - : "(?!(" + String.join("|", except) + "))"; + return except == null || except.isEmpty() ? + "" : + "(?!(" + String.join("|", except) + "))"; } } diff --git a/src/main/java/org/openrewrite/java/spring/ExpandProperties.java b/src/main/java/org/openrewrite/java/spring/ExpandProperties.java index 3d4fe64e1..c77ad2e71 100644 --- a/src/main/java/org/openrewrite/java/spring/ExpandProperties.java +++ b/src/main/java/org/openrewrite/java/spring/ExpandProperties.java @@ -78,29 +78,29 @@ private Yaml.Documents removeEmptyFirstLine(Yaml.Documents docs, ExecutionContex return (Yaml.Documents) new YamlIsoVisitor() { boolean doneTrimming; @Override - public Yaml.Scalar visitScalar(Yaml.Scalar scalar, ExecutionContext executionContext) { + public Yaml.Scalar visitScalar(Yaml.Scalar scalar, ExecutionContext ctx) { doneTrimming = true; return scalar.withPrefix(trimNewlineBeforeComment(scalar.getPrefix())); } @Override - public Yaml.Mapping.Entry visitMappingEntry(Yaml.Mapping.Entry entry, ExecutionContext executionContext) { + public Yaml.Mapping.Entry visitMappingEntry(Yaml.Mapping.Entry entry, ExecutionContext ctx) { doneTrimming = true; return entry.withPrefix(trimNewlineBeforeComment(entry.getPrefix())); } @Override - public Yaml.Sequence.Entry visitSequenceEntry(Yaml.Sequence.Entry entry, ExecutionContext executionContext) { + public Yaml.Sequence.Entry visitSequenceEntry(Yaml.Sequence.Entry entry, ExecutionContext ctx) { doneTrimming = true; return entry.withPrefix(trimNewlineBeforeComment(entry.getPrefix())); } @Override - public @Nullable Yaml visit(@Nullable Tree tree, ExecutionContext executionContext) { + public @Nullable Yaml visit(@Nullable Tree tree, ExecutionContext ctx) { if (doneTrimming) { return (Yaml) tree; } - return super.visit(tree, executionContext); + return super.visit(tree, ctx); } private String trimNewlineBeforeComment(String prefix) { @@ -114,8 +114,8 @@ private String trimNewlineBeforeComment(String prefix) { } }; return sourceFileMask != null ? - Preconditions.check(new FindSourceFiles(sourceFileMask), visitor) - : visitor; + Preconditions.check(new FindSourceFiles(sourceFileMask), visitor) : + visitor; } private static class ExpandEntriesVisitor extends YamlVisitor { diff --git a/src/main/java/org/openrewrite/java/spring/NoRepoAnnotationOnRepoInterface.java b/src/main/java/org/openrewrite/java/spring/NoRepoAnnotationOnRepoInterface.java index b20d7faa6..008dd199e 100644 --- a/src/main/java/org/openrewrite/java/spring/NoRepoAnnotationOnRepoInterface.java +++ b/src/main/java/org/openrewrite/java/spring/NoRepoAnnotationOnRepoInterface.java @@ -50,8 +50,8 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex J.ClassDeclaration c = super.visitClassDeclaration(classDecl, ctx); if (c.getKind() == J.ClassDeclaration.Kind.Type.Interface) { boolean hasRepoAnnotation = c.getLeadingAnnotations().stream().anyMatch(annotation -> { - if (annotation.getArguments() == null || annotation.getArguments().isEmpty() - || annotation.getArguments().get(0) instanceof J.Empty) { + if (annotation.getArguments() == null || annotation.getArguments().isEmpty() || + annotation.getArguments().get(0) instanceof J.Empty) { JavaType.FullyQualified type = TypeUtils.asFullyQualified(annotation.getType()); return type != null && ANNOTATION_REPOSITORY.equals(type.getFullyQualifiedName()); } diff --git a/src/main/java/org/openrewrite/java/spring/NoRequestMappingAnnotation.java b/src/main/java/org/openrewrite/java/spring/NoRequestMappingAnnotation.java index cb52ef3f2..1b1f4b034 100644 --- a/src/main/java/org/openrewrite/java/spring/NoRequestMappingAnnotation.java +++ b/src/main/java/org/openrewrite/java/spring/NoRequestMappingAnnotation.java @@ -127,9 +127,9 @@ private Optional requestMethodArgument(J.Annotation annotation) { return Optional.empty(); } return annotation.getArguments().stream() - .filter(arg -> arg instanceof J.Assignment - && ((J.Assignment) arg).getVariable() instanceof J.Identifier - && "method".equals(((J.Identifier) ((J.Assignment) arg).getVariable()).getSimpleName())) + .filter(arg -> arg instanceof J.Assignment && + ((J.Assignment) arg).getVariable() instanceof J.Identifier && + "method".equals(((J.Identifier) ((J.Assignment) arg).getVariable()).getSimpleName())) .map(J.Assignment.class::cast) .findFirst(); } diff --git a/src/main/java/org/openrewrite/java/spring/RenameBean.java b/src/main/java/org/openrewrite/java/spring/RenameBean.java index 04afa912e..84ed34f0a 100644 --- a/src/main/java/org/openrewrite/java/spring/RenameBean.java +++ b/src/main/java/org/openrewrite/java/spring/RenameBean.java @@ -80,8 +80,8 @@ public String getDescription() { * @return a recipe for this methodDeclaration if it declares a bean, or null if it does not declare a bean */ public static @Nullable RenameBean fromDeclaration(J.MethodDeclaration methodDeclaration, String newName) { - return methodDeclaration.getMethodType() == null ? null - : fromDeclaration(methodDeclaration, newName, methodDeclaration.getMethodType().getReturnType().toString()); + return methodDeclaration.getMethodType() == null ? null : + fromDeclaration(methodDeclaration, newName, methodDeclaration.getMethodType().getReturnType().toString()); } /** @@ -106,8 +106,8 @@ public String getDescription() { * @return a recipe for this classDeclaration if it declares a bean, or null if it does not declare a bean */ public static @Nullable RenameBean fromDeclaration(J.ClassDeclaration classDeclaration, String newName) { - return classDeclaration.getType() == null ? null - : fromDeclaration(classDeclaration, newName, classDeclaration.getType().toString()); + return classDeclaration.getType() == null ? null : + fromDeclaration(classDeclaration, newName, classDeclaration.getType().toString()); } /** @@ -182,12 +182,12 @@ public BeanSearchResult(boolean isBean, @Nullable String beanName) { } private TreeVisitor precondition() { - return type == null - ? Preconditions.or( + return type == null ? + Preconditions.or( new FindAnnotations("@" + FQN_QUALIFIER, false).getVisitor(), new FindAnnotations("@" + FQN_BEAN, false).getVisitor(), - new FindAnnotations("@" + FQN_COMPONENT, true).getVisitor()) - : Preconditions.or(new UsesType<>(type, false), new DeclaresType<>(type)); + new FindAnnotations("@" + FQN_COMPONENT, true).getVisitor()) : + Preconditions.or(new UsesType<>(type, false), new DeclaresType<>(type)); } @Override diff --git a/src/main/java/org/openrewrite/java/spring/batch/MigrateItemWriterWrite.java b/src/main/java/org/openrewrite/java/spring/batch/MigrateItemWriterWrite.java index 580367ff4..de6ad64e1 100644 --- a/src/main/java/org/openrewrite/java/spring/batch/MigrateItemWriterWrite.java +++ b/src/main/java/org/openrewrite/java/spring/batch/MigrateItemWriterWrite.java @@ -59,8 +59,8 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex } J.VariableDeclarations parameter = (J.VariableDeclarations) m.getParameters().get(0); - if (!(parameter.getTypeExpression() instanceof J.ParameterizedType) - || ((J.ParameterizedType) parameter.getTypeExpression()).getTypeParameters() == null) { + if (!(parameter.getTypeExpression() instanceof J.ParameterizedType) || + ((J.ParameterizedType) parameter.getTypeExpression()).getTypeParameters() == null) { return m; } String chunkTypeParameter = ((J.ParameterizedType) parameter.getTypeExpression()).getTypeParameters().get(0).toString(); diff --git a/src/main/java/org/openrewrite/java/spring/batch/MigrateJobBuilderFactory.java b/src/main/java/org/openrewrite/java/spring/batch/MigrateJobBuilderFactory.java index 5a2c705cf..cbfa1d1a1 100644 --- a/src/main/java/org/openrewrite/java/spring/batch/MigrateJobBuilderFactory.java +++ b/src/main/java/org/openrewrite/java/spring/batch/MigrateJobBuilderFactory.java @@ -148,14 +148,14 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration methodDecl } private boolean isJobRepositoryParameter(Statement statement) { - return statement instanceof J.VariableDeclarations - && TypeUtils.isOfClassType(((J.VariableDeclarations) statement).getType(), + return statement instanceof J.VariableDeclarations && + TypeUtils.isOfClassType(((J.VariableDeclarations) statement).getType(), "org.springframework.batch.core.repository.JobRepository"); } private boolean isJobBuilderFactoryParameter(Statement statement) { - return statement instanceof J.VariableDeclarations - && TypeUtils.isOfClassType(((J.VariableDeclarations) statement).getType(), + return statement instanceof J.VariableDeclarations && + TypeUtils.isOfClassType(((J.VariableDeclarations) statement).getType(), "org.springframework.batch.core.configuration.annotation.JobBuilderFactory"); } } 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 5d74b8afe..50eb6c78b 100644 --- a/src/main/java/org/openrewrite/java/spring/batch/MigrateStepBuilderFactory.java +++ b/src/main/java/org/openrewrite/java/spring/batch/MigrateStepBuilderFactory.java @@ -65,8 +65,8 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDeclarat // Remove StepBuilderFactory field if StepBuilderFactory.get(..) is used further down if (!FindMethods.find(classDeclaration, STEP_BUILDER_FACTORY_GET).isEmpty()) { cd = cd.withBody(cd.getBody().withStatements(ListUtils.map(cd.getBody().getStatements(), statement -> { - if (statement instanceof J.VariableDeclarations - && ((J.VariableDeclarations) statement).getTypeExpression() != null) { + if (statement instanceof J.VariableDeclarations && + ((J.VariableDeclarations) statement).getTypeExpression() != null) { if (TypeUtils.isOfClassType(((J.VariableDeclarations) statement).getTypeExpression().getType(), "org.springframework.batch.core.configuration.annotation.StepBuilderFactory")) { return null; @@ -118,14 +118,14 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration md, Execut } private boolean isJobRepositoryParameter(Statement statement) { - return statement instanceof J.VariableDeclarations - && TypeUtils.isOfClassType(((J.VariableDeclarations) statement).getType(), + return statement instanceof J.VariableDeclarations && + TypeUtils.isOfClassType(((J.VariableDeclarations) statement).getType(), "org.springframework.batch.core.repository.JobRepository"); } private boolean isJobBuilderFactoryParameter(Statement statement) { - return statement instanceof J.VariableDeclarations - && TypeUtils.isOfClassType(((J.VariableDeclarations) statement).getType(), + return statement instanceof J.VariableDeclarations && + TypeUtils.isOfClassType(((J.VariableDeclarations) statement).getType(), "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 9c5d8a2b5..691afc6c7 100644 --- a/src/main/java/org/openrewrite/java/spring/batch/RemoveDefaultBatchConfigurer.java +++ b/src/main/java/org/openrewrite/java/spring/batch/RemoveDefaultBatchConfigurer.java @@ -90,9 +90,9 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex // Strip calls to new DefaultBatchConfigurer() List statements = md.getBody().getStatements(); - if (statements.size() == 1 - && statements.get(0) instanceof J.Return - && new MethodMatcher(DEFAULT_BATCH_CONFIGURER + " (..)") + if (statements.size() == 1 && + statements.get(0) instanceof J.Return && + new MethodMatcher(DEFAULT_BATCH_CONFIGURER + " (..)") .matches(((J.Return) statements.get(0)).getExpression())) { maybeRemoveImport(BATCH_CONFIGURER); maybeRemoveImport(DEFAULT_BATCH_CONFIGURER); 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 5716af938..084b25ecb 100644 --- a/src/main/java/org/openrewrite/java/spring/batch/ReplaceSupportClassWithItsInterface.java +++ b/src/main/java/org/openrewrite/java/spring/batch/ReplaceSupportClassWithItsInterface.java @@ -61,8 +61,8 @@ public TreeVisitor getVisitor() { 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)) { + if (cd.getExtends() != null && + TypeUtils.isOfClassType(cd.getExtends().getType(), fullyQualifiedClassName)) { cd = cd.withExtends(null); updateCursor(cd); // This is an interesting one... JobExecutionListenerSupport implements diff --git a/src/main/java/org/openrewrite/java/spring/boot2/AddConfigurationAnnotationIfBeansPresent.java b/src/main/java/org/openrewrite/java/spring/boot2/AddConfigurationAnnotationIfBeansPresent.java index cdcd76c12..70dd85e99 100644 --- a/src/main/java/org/openrewrite/java/spring/boot2/AddConfigurationAnnotationIfBeansPresent.java +++ b/src/main/java/org/openrewrite/java/spring/boot2/AddConfigurationAnnotationIfBeansPresent.java @@ -64,8 +64,8 @@ private J.ClassDeclaration addConfigurationAnnotation(J.ClassDeclaration c) { maybeAddImport(FQN_CONFIGURATION); return JavaTemplate.builder("@" + CONFIGURATION_SIMPLE_NAME) .imports(FQN_CONFIGURATION) - .javaParser(JavaParser.fromJavaVersion().dependsOn("package " + CONFIGURATION_PACKAGE - + "; public @interface " + CONFIGURATION_SIMPLE_NAME + " {}")) + .javaParser(JavaParser.fromJavaVersion().dependsOn("package " + CONFIGURATION_PACKAGE + + "; public @interface " + CONFIGURATION_SIMPLE_NAME + " {}")) .build().apply( getCursor(), c.getCoordinates().addAnnotation(Comparator.comparing(J.Annotation::getSimpleName)) diff --git a/src/main/java/org/openrewrite/java/spring/boot2/ConditionalOnBeanAnyNestedCondition.java b/src/main/java/org/openrewrite/java/spring/boot2/ConditionalOnBeanAnyNestedCondition.java index 582fd4511..7baf78a39 100644 --- a/src/main/java/org/openrewrite/java/spring/boot2/ConditionalOnBeanAnyNestedCondition.java +++ b/src/main/java/org/openrewrite/java/spring/boot2/ConditionalOnBeanAnyNestedCondition.java @@ -82,9 +82,9 @@ public J.Annotation visitAnnotation(J.Annotation annotation, ExecutionContext ct // If class arguments are not found then search for an array of type arguments if (conditionalOnBeanCandidates.isEmpty()) { for (Expression arg : a.getArguments()) { - if (arg instanceof J.Assignment - && ((J.Assignment) arg).getAssignment() instanceof J.NewArray - && "type".equals(((J.Identifier) ((J.Assignment) arg).getVariable()).getSimpleName())) { + if (arg instanceof J.Assignment && + ((J.Assignment) arg).getAssignment() instanceof J.NewArray && + "type".equals(((J.Identifier) ((J.Assignment) arg).getVariable()).getSimpleName())) { J.NewArray na = (J.NewArray) ((J.Assignment) arg).getAssignment(); if (na.getInitializer() != null) { for (Expression l : na.getInitializer()) { diff --git a/src/main/java/org/openrewrite/java/spring/boot2/ConvertToSecurityDslVisitor.java b/src/main/java/org/openrewrite/java/spring/boot2/ConvertToSecurityDslVisitor.java index 128bb05f0..6642e825f 100644 --- a/src/main/java/org/openrewrite/java/spring/boot2/ConvertToSecurityDslVisitor.java +++ b/src/main/java/org/openrewrite/java/spring/boot2/ConvertToSecurityDslVisitor.java @@ -160,18 +160,18 @@ private boolean isApplicableMethod(J.MethodInvocation m) { JavaType.Method type = m.getMethodType(); if (type != null) { JavaType.FullyQualified declaringType = type.getDeclaringType(); - return securityFqn.equals(declaringType.getFullyQualifiedName()) - && (type.getParameterTypes().isEmpty() || hasHandleableArg(m)) - && convertableMethods.contains(m.getSimpleName()); + return securityFqn.equals(declaringType.getFullyQualifiedName()) && + (type.getParameterTypes().isEmpty() || hasHandleableArg(m)) && + convertableMethods.contains(m.getSimpleName()); } return false; } private boolean hasHandleableArg(J.MethodInvocation m) { - return argReplacements.containsKey(m.getSimpleName()) - && m.getMethodType() != null - && m.getMethodType().getParameterTypes().size() == 1 - && !TypeUtils.isAssignableTo(FQN_CUSTOMIZER, m.getMethodType().getParameterTypes().get(0)); + return argReplacements.containsKey(m.getSimpleName()) && + m.getMethodType() != null && + m.getMethodType().getParameterTypes().size() == 1 && + !TypeUtils.isAssignableTo(FQN_CUSTOMIZER, m.getMethodType().getParameterTypes().get(0)); } private Optional createDesiredReplacement(J.MethodInvocation m) { @@ -182,10 +182,10 @@ private Optional createDesiredReplacement(J.MethodInvocation m) JavaType.Parameterized customizerArgType = new JavaType.Parameterized(null, CUSTOMIZER_SHALLOW_TYPE, Collections.singletonList(methodType.getReturnType())); boolean keepArg = keepArg(m.getSimpleName()); - List paramNames = keepArg ? ListUtils.concat(methodType.getParameterNames(), "arg1") - : Collections.singletonList("arg0"); - List paramTypes = keepArg ? ListUtils.concat(methodType.getParameterTypes(), customizerArgType) - : Collections.singletonList(customizerArgType); + List paramNames = keepArg ? ListUtils.concat(methodType.getParameterNames(), "arg1") : + Collections.singletonList("arg0"); + List paramTypes = keepArg ? ListUtils.concat(methodType.getParameterTypes(), customizerArgType) : + Collections.singletonList(customizerArgType); return Optional.of(methodType.withReturnType(methodType.getDeclaringType()) .withName(methodRenames.getOrDefault(methodType.getName(), methodType.getName())) .withParameterNames(paramNames) diff --git a/src/main/java/org/openrewrite/java/spring/boot2/DatabaseComponentAndBeanInitializationOrdering.java b/src/main/java/org/openrewrite/java/spring/boot2/DatabaseComponentAndBeanInitializationOrdering.java index af4f27ac6..28f417def 100644 --- a/src/main/java/org/openrewrite/java/spring/boot2/DatabaseComponentAndBeanInitializationOrdering.java +++ b/src/main/java/org/openrewrite/java/spring/boot2/DatabaseComponentAndBeanInitializationOrdering.java @@ -83,8 +83,8 @@ public TreeVisitor getVisitor() { public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, ExecutionContext ctx) { J.MethodDeclaration md = super.visitMethodDeclaration(method, ctx); if (method.getMethodType() != null) { - if (!isInitializationAnnoPresent(md.getLeadingAnnotations()) && isBean(md) - && requiresInitializationAnnotation(method.getMethodType().getReturnType())) { + if (!isInitializationAnnoPresent(md.getLeadingAnnotations()) && isBean(md) && + requiresInitializationAnnotation(method.getMethodType().getReturnType())) { md = JavaTemplate.builder("@DependsOnDatabaseInitialization") .imports("org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitialization") .javaParser(JavaParser.fromJavaVersion() @@ -103,8 +103,8 @@ && requiresInitializationAnnotation(method.getMethodType().getReturnType())) { @Override public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext ctx) { J.ClassDeclaration cd = super.visitClassDeclaration(classDecl, ctx); - if (!isInitializationAnnoPresent(cd.getLeadingAnnotations()) && isComponent(cd) - && requiresInitializationAnnotation(cd.getType())) { + if (!isInitializationAnnoPresent(cd.getLeadingAnnotations()) && isComponent(cd) && + requiresInitializationAnnotation(cd.getType())) { cd = JavaTemplate.builder("@DependsOnDatabaseInitialization") .imports("org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitialization") .javaParser(JavaParser.fromJavaVersion() diff --git a/src/main/java/org/openrewrite/java/spring/boot2/MergeBootstrapYamlWithApplicationYaml.java b/src/main/java/org/openrewrite/java/spring/boot2/MergeBootstrapYamlWithApplicationYaml.java index 1a4150d7c..490b694fb 100644 --- a/src/main/java/org/openrewrite/java/spring/boot2/MergeBootstrapYamlWithApplicationYaml.java +++ b/src/main/java/org/openrewrite/java/spring/boot2/MergeBootstrapYamlWithApplicationYaml.java @@ -58,11 +58,11 @@ public TreeVisitor getScanner(Accumulator acc) { } SourceFile source = (SourceFile) tree; Path sourcePath = source.getSourcePath(); - if (acc.getBootstrapYaml() == null && source instanceof Yaml.Documents - && PathUtils.matchesGlob(sourcePath, "**/main/resources/bootstrap.yml")) { + if (acc.getBootstrapYaml() == null && source instanceof Yaml.Documents && + PathUtils.matchesGlob(sourcePath, "**/main/resources/bootstrap.yml")) { acc.setBootstrapYaml((Yaml.Documents) source); - } else if (acc.getApplicationYaml() == null - && PathUtils.matchesGlob(sourcePath, "**/main/resources/application.yml")) { + } else if (acc.getApplicationYaml() == null && + PathUtils.matchesGlob(sourcePath, "**/main/resources/application.yml")) { acc.setApplicationYaml((Yaml.Documents) source); } return source; diff --git a/src/main/java/org/openrewrite/java/spring/boot2/ReplaceDeprecatedEnvironmentTestUtils.java b/src/main/java/org/openrewrite/java/spring/boot2/ReplaceDeprecatedEnvironmentTestUtils.java index 02b3c4497..82a6b0df8 100644 --- a/src/main/java/org/openrewrite/java/spring/boot2/ReplaceDeprecatedEnvironmentTestUtils.java +++ b/src/main/java/org/openrewrite/java/spring/boot2/ReplaceDeprecatedEnvironmentTestUtils.java @@ -137,9 +137,9 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex } private boolean isCollectedContextOrEnvironment(List collectedMethods, J.MethodInvocation methodInvocation) { - if (methodInvocation.getArguments().isEmpty() - || collectedMethods.isEmpty() - || collectedMethods.get(0).getArguments().isEmpty()) { + if (methodInvocation.getArguments().isEmpty() || + collectedMethods.isEmpty() || + collectedMethods.get(0).getArguments().isEmpty()) { return false; } J.MethodInvocation collectedMethod = collectedMethods.get(0); @@ -150,10 +150,10 @@ private boolean isCollectedContextOrEnvironment(List collect Expression collectedEnvironmentName = getEnvironmentNameArgument(collectedMethod); return !(contextOrEnvironmentToCheck instanceof J.NewClass) && - SemanticallyEqual.areEqual(contextOrEnvironmentToCheck, collectedContextOrEnvironment) - && (environmentNameToCheck == null && collectedEnvironmentName == null) - || (environmentNameToCheck != null && collectedEnvironmentName != null - && SemanticallyEqual.areEqual(environmentNameToCheck, collectedEnvironmentName)); + SemanticallyEqual.areEqual(contextOrEnvironmentToCheck, collectedContextOrEnvironment) && + (environmentNameToCheck == null && collectedEnvironmentName == null) || + (environmentNameToCheck != null && collectedEnvironmentName != null && + SemanticallyEqual.areEqual(environmentNameToCheck, collectedEnvironmentName)); } private @Nullable Expression getEnvironmentNameArgument(J.MethodInvocation methodInvocation) { diff --git a/src/main/java/org/openrewrite/java/spring/boot2/ReplaceExtendWithAndContextConfiguration.java b/src/main/java/org/openrewrite/java/spring/boot2/ReplaceExtendWithAndContextConfiguration.java index 142e8d300..e477caf70 100644 --- a/src/main/java/org/openrewrite/java/spring/boot2/ReplaceExtendWithAndContextConfiguration.java +++ b/src/main/java/org/openrewrite/java/spring/boot2/ReplaceExtendWithAndContextConfiguration.java @@ -135,9 +135,9 @@ private static Optional findLoaderArgument(J.Annotation annotation return Optional.empty(); } return annotation.getArguments().stream() - .filter(arg -> arg instanceof J.Assignment - && ((J.Assignment) arg).getVariable() instanceof J.Identifier - && "loader".equals(((J.Identifier) ((J.Assignment) arg).getVariable()).getSimpleName())) + .filter(arg -> arg instanceof J.Assignment && + ((J.Assignment) arg).getVariable() instanceof J.Identifier && + "loader".equals(((J.Identifier) ((J.Assignment) arg).getVariable()).getSimpleName())) .map(J.Assignment.class::cast) .findFirst(); } diff --git a/src/main/java/org/openrewrite/java/spring/boot3/DowngradeServletApiWhenUsingJetty.java b/src/main/java/org/openrewrite/java/spring/boot3/DowngradeServletApiWhenUsingJetty.java index 33bd7aac9..0c8799a41 100644 --- a/src/main/java/org/openrewrite/java/spring/boot3/DowngradeServletApiWhenUsingJetty.java +++ b/src/main/java/org/openrewrite/java/spring/boot3/DowngradeServletApiWhenUsingJetty.java @@ -35,9 +35,9 @@ public String getDisplayName() { @Override public String getDescription() { - return "Jetty does not yet support Servlet 6.0. This recipe will detect the presence of the `spring-boot-starter-jetty` as a " - + "first-order dependency and will add the maven property `jakarta-servlet.version` setting it's value to `5.0.0`. This " - + "will downgrade the `jakarta-servlet` artifact if the pom's parent extends from the spring-boot-parent."; + return "Jetty does not yet support Servlet 6.0. This recipe will detect the presence of the `spring-boot-starter-jetty` as a " + + "first-order dependency and will add the maven property `jakarta-servlet.version` setting it's value to `5.0.0`. This " + + "will downgrade the `jakarta-servlet` artifact if the pom's parent extends from the spring-boot-parent."; } @Override diff --git a/src/main/java/org/openrewrite/java/spring/data/MigrateJpaSort.java b/src/main/java/org/openrewrite/java/spring/data/MigrateJpaSort.java index bef3cbbf4..266a4c986 100644 --- a/src/main/java/org/openrewrite/java/spring/data/MigrateJpaSort.java +++ b/src/main/java/org/openrewrite/java/spring/data/MigrateJpaSort.java @@ -45,8 +45,8 @@ private TreeVisitor precondition() { return new JavaIsoVisitor() { @Override public J.CompilationUnit visitCompilationUnit(J.CompilationUnit cu, ExecutionContext ctx) { - if (cu.getPackageDeclaration() != null - && "org.springframework.data.jpa.domain".equals(cu.getPackageDeclaration().getPackageName())) { + if (cu.getPackageDeclaration() != null && + "org.springframework.data.jpa.domain".equals(cu.getPackageDeclaration().getPackageName())) { return cu; } diff --git a/src/main/java/org/openrewrite/java/spring/framework/JdbcTemplateObjectArrayArgToVarArgs.java b/src/main/java/org/openrewrite/java/spring/framework/JdbcTemplateObjectArrayArgToVarArgs.java index 2bdcd81ca..646780c0e 100644 --- a/src/main/java/org/openrewrite/java/spring/framework/JdbcTemplateObjectArrayArgToVarArgs.java +++ b/src/main/java/org/openrewrite/java/spring/framework/JdbcTemplateObjectArrayArgToVarArgs.java @@ -70,10 +70,10 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu private boolean shouldSwapArgs(@Nullable JavaType arg1, @Nullable JavaType arg2) { return arg1 instanceof JavaType.Array && ( - (arg2 instanceof JavaType.Parameterized && ((JavaType.Parameterized) arg2).getTypeParameters().get(0) instanceof JavaType.Class) - || TypeUtils.isOfClassType(arg2, "org.springframework.jdbc.core.RowMapper") - || TypeUtils.isOfClassType(arg2, "org.springframework.jdbc.core.ResultSetExtractor") - || TypeUtils.isOfClassType(arg2, "org.springframework.jdbc.core.RowCallbackHandler") + (arg2 instanceof JavaType.Parameterized && ((JavaType.Parameterized) arg2).getTypeParameters().get(0) instanceof JavaType.Class) || + TypeUtils.isOfClassType(arg2, "org.springframework.jdbc.core.RowMapper") || + TypeUtils.isOfClassType(arg2, "org.springframework.jdbc.core.ResultSetExtractor") || + TypeUtils.isOfClassType(arg2, "org.springframework.jdbc.core.RowCallbackHandler") ); } diff --git a/src/main/java/org/openrewrite/java/spring/http/SimplifyMediaTypeParseCalls.java b/src/main/java/org/openrewrite/java/spring/http/SimplifyMediaTypeParseCalls.java index e456cc844..b6c790c66 100644 --- a/src/main/java/org/openrewrite/java/spring/http/SimplifyMediaTypeParseCalls.java +++ b/src/main/java/org/openrewrite/java/spring/http/SimplifyMediaTypeParseCalls.java @@ -59,8 +59,8 @@ public J visitMethodInvocation(J.MethodInvocation methodInvocation, ExecutionCon J.MethodInvocation mi = (J.MethodInvocation) j; if (new MethodMatcher(PARSE_MEDIA_TYPE).matches(mi) || new MethodMatcher(VALUE_OF).matches(mi)) { Expression methodArg = mi.getArguments().get(0); - if (methodArg instanceof J.FieldAccess - && TypeUtils.isOfClassType(((J.FieldAccess) methodArg).getTarget().getType(), MEDIA_TYPE)) { + if (methodArg instanceof J.FieldAccess && + TypeUtils.isOfClassType(((J.FieldAccess) methodArg).getTarget().getType(), MEDIA_TYPE)) { maybeRemoveImport(MEDIA_TYPE + ".parseMediaType"); maybeRemoveImport(MEDIA_TYPE + ".valueOf"); J.FieldAccess fieldAccess = (J.FieldAccess) methodArg; diff --git a/src/main/java/org/openrewrite/java/spring/security5/UpdateArgon2PasswordEncoder.java b/src/main/java/org/openrewrite/java/spring/security5/UpdateArgon2PasswordEncoder.java index 739cc22db..591e6d82c 100644 --- a/src/main/java/org/openrewrite/java/spring/security5/UpdateArgon2PasswordEncoder.java +++ b/src/main/java/org/openrewrite/java/spring/security5/UpdateArgon2PasswordEncoder.java @@ -63,8 +63,8 @@ public String getDisplayName() { @Override public String getDescription() { - return "In Spring Security 5.8 some `Argon2PasswordEncoder` constructors have been deprecated in favor of factory methods. " - + "Refer to the [ Spring Security migration docs](https://docs.spring.io/spring-security/reference/5.8/migration/index.html#_update_argon2passwordencoder) for more information."; + return "In Spring Security 5.8 some `Argon2PasswordEncoder` constructors have been deprecated in favor of factory methods. " + + "Refer to the [ Spring Security migration docs](https://docs.spring.io/spring-security/reference/5.8/migration/index.html#_update_argon2passwordencoder) for more information."; } @Override @@ -89,17 +89,17 @@ public J visitNewClass(J.NewClass newClass, ExecutionContext ctx) { Expression memory = arguments.get(3); Expression iterations = arguments.get(4); maybeAddImport(ARGON2_PASSWORD_ENCODER_CLASS); - if (resolvedValueMatchesLiteral(saltLength, DEFAULT_SALT_LENGTH) - && resolvedValueMatchesLiteral(hashLength, DEFAULT_HASH_LENGTH) - && resolvedValueMatchesLiteral(parallelism, DEFAULT_PARALLELISM) - && resolvedValueMatchesLiteral(memory, DEFAULT_MEMORY) - && resolvedValueMatchesLiteral(iterations, DEFAULT_ITERATIONS)) { + if (resolvedValueMatchesLiteral(saltLength, DEFAULT_SALT_LENGTH) && + resolvedValueMatchesLiteral(hashLength, DEFAULT_HASH_LENGTH) && + resolvedValueMatchesLiteral(parallelism, DEFAULT_PARALLELISM) && + resolvedValueMatchesLiteral(memory, DEFAULT_MEMORY) && + resolvedValueMatchesLiteral(iterations, DEFAULT_ITERATIONS)) { return newV58FactoryMethodTemplate(ctx).apply(getCursor(), newClass.getCoordinates().replace()); - } else if (resolvedValueMatchesLiteral(saltLength, DEFAULT_V52_SALT_LENGTH) - && resolvedValueMatchesLiteral(hashLength, DEFAULT_V52_HASH_LENGTH) - && resolvedValueMatchesLiteral(parallelism, DEFAULT_V52_PARALLELISM) - && resolvedValueMatchesLiteral(memory, DEFAULT_V52_MEMORY) - && resolvedValueMatchesLiteral(iterations, DEFAULT_V52_ITERATIONS)) { + } else if (resolvedValueMatchesLiteral(saltLength, DEFAULT_V52_SALT_LENGTH) && + resolvedValueMatchesLiteral(hashLength, DEFAULT_V52_HASH_LENGTH) && + resolvedValueMatchesLiteral(parallelism, DEFAULT_V52_PARALLELISM) && + resolvedValueMatchesLiteral(memory, DEFAULT_V52_MEMORY) && + resolvedValueMatchesLiteral(iterations, DEFAULT_V52_ITERATIONS)) { return newV52FactoryMethodTemplate(ctx).apply(getCursor(), newClass.getCoordinates().replace()); } } diff --git a/src/main/java/org/openrewrite/java/spring/security5/UpdatePbkdf2PasswordEncoder.java b/src/main/java/org/openrewrite/java/spring/security5/UpdatePbkdf2PasswordEncoder.java index 5c0eccdc4..85924ff0f 100644 --- a/src/main/java/org/openrewrite/java/spring/security5/UpdatePbkdf2PasswordEncoder.java +++ b/src/main/java/org/openrewrite/java/spring/security5/UpdatePbkdf2PasswordEncoder.java @@ -68,8 +68,8 @@ public String getDisplayName() { @Override public String getDescription() { - return "In Spring Security 5.8 some `Pbkdf2PasswordEncoder` constructors have been deprecated in favor of factory methods. " - + "Refer to the [ Spring Security migration docs](https://docs.spring.io/spring-security/reference/5.8/migration/index.html#_update_pbkdf2passwordencoder) for more information."; + return "In Spring Security 5.8 some `Pbkdf2PasswordEncoder` constructors have been deprecated in favor of factory methods. " + + "Refer to the [ Spring Security migration docs](https://docs.spring.io/spring-security/reference/5.8/migration/index.html#_update_pbkdf2passwordencoder) for more information."; } @Override @@ -100,8 +100,8 @@ public J visitNewClass(J.NewClass newClass, ExecutionContext ctx) { Expression secret = arguments.get(0); Expression saltLength = arguments.get(1); maybeAddImport(PBKDF2_PASSWORD_ENCODER_CLASS); - if (resolvedValueMatchesLiteral(secret, DEFAULT_SECRET) - && resolvedValueMatchesLiteral(saltLength, DEFAULT_SALT_LENGTH)) { + if (resolvedValueMatchesLiteral(secret, DEFAULT_SECRET) && + resolvedValueMatchesLiteral(saltLength, DEFAULT_SALT_LENGTH)) { return newFactoryMethodTemplate(ctx).apply(getCursor(), newClass.getCoordinates().replace()); } else { String algorithm = HASH_WIDTH_TO_ALGORITHM_MAP.get(DEFAULT_HASH_WIDTH); @@ -114,9 +114,9 @@ && resolvedValueMatchesLiteral(saltLength, DEFAULT_SALT_LENGTH)) { Expression hashWidth = arguments.get(2); Integer knownHashWidth = hashWidth instanceof J.Literal && hashWidth.getType() == JavaType.Primitive.Int ? (Integer) ((J.Literal) hashWidth).getValue() : null; maybeAddImport(PBKDF2_PASSWORD_ENCODER_CLASS); - if (resolvedValueMatchesLiteral(secret, DEFAULT_SECRET) - && resolvedValueMatchesLiteral(iterations, DEFAULT_ITERATIONS) - && DEFAULT_HASH_WIDTH.equals(knownHashWidth)) { + if (resolvedValueMatchesLiteral(secret, DEFAULT_SECRET) && + resolvedValueMatchesLiteral(iterations, DEFAULT_ITERATIONS) && + DEFAULT_HASH_WIDTH.equals(knownHashWidth)) { return newFactoryMethodTemplate(ctx).apply(getCursor(), newClass.getCoordinates().replace()); } else { String algorithm = HASH_WIDTH_TO_ALGORITHM_MAP.get(knownHashWidth); diff --git a/src/main/java/org/openrewrite/java/spring/security5/UpdateSCryptPasswordEncoder.java b/src/main/java/org/openrewrite/java/spring/security5/UpdateSCryptPasswordEncoder.java index db59721f6..c647a408d 100644 --- a/src/main/java/org/openrewrite/java/spring/security5/UpdateSCryptPasswordEncoder.java +++ b/src/main/java/org/openrewrite/java/spring/security5/UpdateSCryptPasswordEncoder.java @@ -63,8 +63,8 @@ public String getDisplayName() { @Override public String getDescription() { - return "In Spring Security 5.8 some `SCryptPasswordEncoder` constructors have been deprecated in favor of factory methods. " - + "Refer to the [ Spring Security migration docs](https://docs.spring.io/spring-security/reference/5.8/migration/index.html#_update_scryptpasswordencoder) for more information."; + return "In Spring Security 5.8 some `SCryptPasswordEncoder` constructors have been deprecated in favor of factory methods. " + + "Refer to the [ Spring Security migration docs](https://docs.spring.io/spring-security/reference/5.8/migration/index.html#_update_scryptpasswordencoder) for more information."; } @Override @@ -88,17 +88,17 @@ public J visitNewClass(J.NewClass newClass, ExecutionContext ctx) { Expression keyLength = arguments.get(3); Expression saltLength = arguments.get(4); maybeAddImport(SCRYPT_PASSWORD_ENCODER_CLASS); - if (resolvedValueMatchesLiteral(cpuCost, DEFAULT_CPU_COST) - && resolvedValueMatchesLiteral(memoryCost, DEFAULT_MEMORY_COST) - && resolvedValueMatchesLiteral(parallelization, DEFAULT_PARALLELIZATION) - && resolvedValueMatchesLiteral(keyLength, DEFAULT_KEY_LENGTH) - && resolvedValueMatchesLiteral(saltLength, DEFAULT_SALT_LENGTH)) { + if (resolvedValueMatchesLiteral(cpuCost, DEFAULT_CPU_COST) && + resolvedValueMatchesLiteral(memoryCost, DEFAULT_MEMORY_COST) && + resolvedValueMatchesLiteral(parallelization, DEFAULT_PARALLELIZATION) && + resolvedValueMatchesLiteral(keyLength, DEFAULT_KEY_LENGTH) && + resolvedValueMatchesLiteral(saltLength, DEFAULT_SALT_LENGTH)) { return newV58FactoryMethodTemplate(ctx).apply(getCursor(), newClass.getCoordinates().replace()); - } else if (resolvedValueMatchesLiteral(cpuCost, DEFAULT_V41_CPU_COST) - && resolvedValueMatchesLiteral(memoryCost, DEFAULT_V41_MEMORY_COST) - && resolvedValueMatchesLiteral(parallelization, DEFAULT_V41_PARALLELIZATION) - && resolvedValueMatchesLiteral(keyLength, DEFAULT_V41_KEY_LENGTH) - && resolvedValueMatchesLiteral(saltLength, DEFAULT_V41_SALT_LENGTH)) { + } else if (resolvedValueMatchesLiteral(cpuCost, DEFAULT_V41_CPU_COST) && + resolvedValueMatchesLiteral(memoryCost, DEFAULT_V41_MEMORY_COST) && + resolvedValueMatchesLiteral(parallelization, DEFAULT_V41_PARALLELIZATION) && + resolvedValueMatchesLiteral(keyLength, DEFAULT_V41_KEY_LENGTH) && + resolvedValueMatchesLiteral(saltLength, DEFAULT_V41_SALT_LENGTH)) { return newV41FactoryMethodTemplate(ctx).apply(getCursor(), newClass.getCoordinates().replace()); } } diff --git a/src/main/java/org/openrewrite/java/spring/security5/UseNewRequestMatchers.java b/src/main/java/org/openrewrite/java/spring/security5/UseNewRequestMatchers.java index 3c896e5c6..4e092d974 100644 --- a/src/main/java/org/openrewrite/java/spring/security5/UseNewRequestMatchers.java +++ b/src/main/java/org/openrewrite/java/spring/security5/UseNewRequestMatchers.java @@ -64,8 +64,8 @@ public TreeVisitor getVisitor() { public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { J.MethodInvocation mi = super.visitMethodInvocation(method, ctx); boolean isCsrfMatcher = CSRF_MATCHERS.matches(mi); - if ((ANT_MATCHERS.matches(mi) || MVC_MATCHERS.matches(mi) || REGEX_MATCHERS.matches(mi) || isCsrfMatcher) - && mi.getSelect() != null) { + if ((ANT_MATCHERS.matches(mi) || MVC_MATCHERS.matches(mi) || REGEX_MATCHERS.matches(mi) || isCsrfMatcher) && + mi.getSelect() != null) { String parametersTemplate = mi.getArguments().stream().map(arg -> "#{any()}").collect(joining(", ")); String replacementMethodName = isCsrfMatcher ? "ignoringRequestMatchers" : "requestMatchers"; J.MethodInvocation applied = JavaTemplate.builder(String.format("%s(%s)", replacementMethodName, parametersTemplate)) diff --git a/src/main/java/org/openrewrite/java/spring/security5/WebSecurityConfigurerAdapter.java b/src/main/java/org/openrewrite/java/spring/security5/WebSecurityConfigurerAdapter.java index 33c31fc19..f3b70fbc5 100644 --- a/src/main/java/org/openrewrite/java/spring/security5/WebSecurityConfigurerAdapter.java +++ b/src/main/java/org/openrewrite/java/spring/security5/WebSecurityConfigurerAdapter.java @@ -101,8 +101,8 @@ public TreeVisitor getVisitor() { @Override public J.@Nullable ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext ctx) { - boolean isWebSecurityConfigurerAdapterClass = TypeUtils.isAssignableTo(FQN_WEB_SECURITY_CONFIGURER_ADAPTER, classDecl.getType()) - && isAnnotatedWith(classDecl.getLeadingAnnotations(), FQN_CONFIGURATION); + boolean isWebSecurityConfigurerAdapterClass = TypeUtils.isAssignableTo(FQN_WEB_SECURITY_CONFIGURER_ADAPTER, classDecl.getType()) && + isAnnotatedWith(classDecl.getLeadingAnnotations(), FQN_CONFIGURATION); boolean hasConflict = false; if (isWebSecurityConfigurerAdapterClass) { for (Statement s : classDecl.getBody().getStatements()) { @@ -235,9 +235,9 @@ private boolean isConflictingMethod(J.MethodDeclaration m) { String methodName = m.getSimpleName(); JavaType.Method methodType = m.getMethodType(); return (methodType == null && ("authenticationManagerBean".equals(methodName) || "userDetailsServiceBean".equals(methodName))) || - (USER_DETAILS_SERVICE_BEAN_METHOD_MATCHER.matches(methodType) - || AUTHENTICATION_MANAGER_BEAN_METHOD_MATCHER.matches(methodType) - || (CONFIGURE_AUTH_MANAGER_SECURITY_METHOD_MATCHER.matches(methodType) && inConflictingAuthConfigMethod(m))); + (USER_DETAILS_SERVICE_BEAN_METHOD_MATCHER.matches(methodType) || + AUTHENTICATION_MANAGER_BEAN_METHOD_MATCHER.matches(methodType) || + (CONFIGURE_AUTH_MANAGER_SECURITY_METHOD_MATCHER.matches(methodType) && inConflictingAuthConfigMethod(m))); } private boolean inConflictingAuthConfigMethod(J.MethodDeclaration m) { 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 48f32c1f5..394ed4d64 100644 --- a/src/main/java/org/openrewrite/java/spring/security6/PropagateAuthenticationServiceExceptions.java +++ b/src/main/java/org/openrewrite/java/spring/security6/PropagateAuthenticationServiceExceptions.java @@ -38,8 +38,8 @@ 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."; + 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."; } @Override diff --git a/src/main/java/org/openrewrite/java/spring/security6/RequireExplicitSavingOfSecurityContextRepository.java b/src/main/java/org/openrewrite/java/spring/security6/RequireExplicitSavingOfSecurityContextRepository.java index aca4d63fa..89910eab7 100644 --- a/src/main/java/org/openrewrite/java/spring/security6/RequireExplicitSavingOfSecurityContextRepository.java +++ b/src/main/java/org/openrewrite/java/spring/security6/RequireExplicitSavingOfSecurityContextRepository.java @@ -47,8 +47,8 @@ public String getDisplayName() { @Override public String getDescription() { - return "Remove explicit `SecurityContextConfigurer.requireExplicitSave(true)` opt-in as that is the new default in Spring Security 6. " - + "See the corresponding [Sprint Security 6.0 migration step](https://docs.spring.io/spring-security/reference/6.0.0/migration/servlet/session-management.html#_require_explicit_saving_of_securitycontextrepository) for details."; + return "Remove explicit `SecurityContextConfigurer.requireExplicitSave(true)` opt-in as that is the new default in Spring Security 6. " + + "See the corresponding [Sprint Security 6.0 migration step](https://docs.spring.io/spring-security/reference/6.0.0/migration/servlet/session-management.html#_require_explicit_saving_of_securitycontextrepository) for details."; } @Override @@ -57,14 +57,14 @@ public TreeVisitor getVisitor() { @Override public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { method = super.visitMethodInvocation(method, ctx); - if (method.getSelect() != null && method.getArguments().size() == 1 - && REQUIRE_EXPLICIT_SAVE_MATCHER.matches(method) - && isTrue(method.getArguments().get(0))) { + if (method.getSelect() != null && method.getArguments().size() == 1 && + REQUIRE_EXPLICIT_SAVE_MATCHER.matches(method) && + isTrue(method.getArguments().get(0))) { return ToBeRemoved.withMarker(method); } else if (method.getSelect() instanceof J.MethodInvocation && ToBeRemoved.hasMarker(method.getSelect())) { return method.withSelect(((J.MethodInvocation) method.getSelect()).getSelect()); - } else if (method.getArguments().stream().anyMatch(ToBeRemoved::hasMarker) - && method.getSelect() != null && TypeUtils.isAssignableTo(HTTP_SECURITY_TYPE, method.getSelect().getType())) { + } else if (method.getArguments().stream().anyMatch(ToBeRemoved::hasMarker) && + method.getSelect() != null && TypeUtils.isAssignableTo(HTTP_SECURITY_TYPE, method.getSelect().getType())) { if (method.getArguments().stream().allMatch(ToBeRemoved::hasMarker)) { return ToBeRemoved.withMarker(method); } 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 f73514dea..76ab23316 100644 --- a/src/main/java/org/openrewrite/java/spring/security6/UseSha256InRememberMe.java +++ b/src/main/java/org/openrewrite/java/spring/security6/UseSha256InRememberMe.java @@ -31,11 +31,11 @@ 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() + ")"); + new MethodMatcher("org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices (String, org.springframework.security.core.userdetails.UserDetailsService, " + + 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() + ")"); + new MethodMatcher("org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices setMatchingAlgorithm(" + + REMEMBER_ME_TOKEN_ALGORITHM_TYPE.getFullyQualifiedName() + ")"); @Override public String getDisplayName() { @@ -44,8 +44,8 @@ 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."; + 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."; } @Override @@ -66,8 +66,8 @@ public J.NewClass visitNewClass(J.NewClass newClass, ExecutionContext ctx) { @SuppressWarnings("DataFlowIssue") public J.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)) { + if (method.getSelect() != null && method.getArguments().size() == 1 && + 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/maven/spring/UpgradeExplicitSpringBootDependencies.java b/src/main/java/org/openrewrite/maven/spring/UpgradeExplicitSpringBootDependencies.java index 28a1285e5..36bffcd51 100644 --- a/src/main/java/org/openrewrite/maven/spring/UpgradeExplicitSpringBootDependencies.java +++ b/src/main/java/org/openrewrite/maven/spring/UpgradeExplicitSpringBootDependencies.java @@ -85,16 +85,16 @@ public Xml.Tag visitTag(Xml.Tag tag, ExecutionContext ctx) { Xml.Tag resultTag = super.visitTag(tag, ctx); if (isManagedDependencyTag()) { ResolvedManagedDependency managedDependency = findManagedDependency(resultTag); - if (managedDependency != null && managedDependency.getGroupId().equals(SPRINGBOOT_GROUP) - && satisfiesOldVersionPattern(managedDependency.getVersion())) { + if (managedDependency != null && managedDependency.getGroupId().equals(SPRINGBOOT_GROUP) && + satisfiesOldVersionPattern(managedDependency.getVersion())) { return SearchResult.found(resultTag); } } if (isDependencyTag()) { ResolvedDependency dependency = findDependency(resultTag); - if ((dependency != null) && dependency.getGroupId().equals(SPRINGBOOT_GROUP) - && satisfiesOldVersionPattern(dependency.getVersion())) { + if ((dependency != null) && dependency.getGroupId().equals(SPRINGBOOT_GROUP) && + satisfiesOldVersionPattern(dependency.getVersion())) { return SearchResult.found(resultTag); } }