Skip to content

Commit

Permalink
refactor: Spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider and TeamModerne committed Sep 26, 2023
1 parent a7c3d5f commit 23e0c1b
Show file tree
Hide file tree
Showing 25 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ public boolean isAcceptable(SourceFile sourceFile, ExecutionContext ctx) {

@Override
public @Nullable Tree visit(@Nullable Tree t, ExecutionContext ctx) {
if (t instanceof Yaml.Documents && sourcePathMatches(((SourceFile)t).getSourcePath(), ctx)) {
if (t instanceof Yaml.Documents && sourcePathMatches(((SourceFile) t).getSourcePath(), ctx)) {
t = createMergeYamlVisitor().getVisitor().visit(t, ctx);
} else if (t instanceof Properties.File && sourcePathMatches(((SourceFile)t).getSourcePath(), ctx)) {
} else if (t instanceof Properties.File && sourcePathMatches(((SourceFile) t).getSourcePath(), ctx)) {
t = new AddProperty(property, value, null).getVisitor().visit(t, ctx);
}
return t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public TreeVisitor<?, ExecutionContext> getVisitor(ApiManifest acc) {
return Preconditions.check(!acc.isGenerate(), new PlainTextVisitor<ExecutionContext>() {
@Override
public PlainText visitText(PlainText text, ExecutionContext executionContext) {
if(text.getSourcePath().equals(Paths.get("META-INF/api-manifest.txt"))) {
if (text.getSourcePath().equals(Paths.get("META-INF/api-manifest.txt"))) {
return text.withText(generateManifest(acc.getApis()).getText());
}
return text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private J.MethodInvocation createDefaultsCall(JavaType type) {
}
maybeAddImport(methodType.getDeclaringType().getFullyQualifiedName(), methodType.getName());
return new J.MethodInvocation(Tree.randomId(), Space.EMPTY, Markers.EMPTY, null, null,
new J.Identifier(Tree.randomId(), Space.EMPTY, Markers.EMPTY, emptyList(),"withDefaults", null, null),
new J.Identifier(Tree.randomId(), Space.EMPTY, Markers.EMPTY, emptyList(), "withDefaults", null, null),
JContainer.empty(), methodType)
.withSelect(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex
new J.VariableDeclarations.NamedVariable(Tree.randomId(),
Space.format(" "),
Markers.EMPTY,
new J.Identifier(Tree.randomId(), Space.EMPTY, Markers.EMPTY, emptyList(), variableName, CAPTURED_OUTPUT_TYPE, null),
new J.Identifier(Tree.randomId(), Space.EMPTY, Markers.EMPTY, emptyList(), variableName, CAPTURED_OUTPUT_TYPE, null),
emptyList(),
null,
null),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private J.ClassDeclaration handleRepoType(J.ClassDeclaration typeDecl) {
int domainTypeIndex = 0;
int idTypeIndex = 1;
int idTypeIndexInChain = repoTypeChain.size() - 1;
for (int i = repoTypeChain.size() - 1; i >=0 && (idType == null || idType instanceof JavaType.GenericTypeVariable || domainType == null || domainType instanceof JavaType.GenericTypeVariable); i--) {
for (int i = repoTypeChain.size() - 1; i >= 0 && (idType == null || idType instanceof JavaType.GenericTypeVariable || domainType == null || domainType instanceof JavaType.GenericTypeVariable); i--) {
JavaType.FullyQualified repoType = repoTypeChain.get(i);
List<JavaType> typeParams = repoType.getTypeParameters();
boolean domainTypeChanged = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public String getDescription() {
@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
return new JavaVisitor<ExecutionContext>() {
private void changeTypesAfterVisit(){
private void changeTypesAfterVisit() {
doAfterVisit(new ChangeType(
"org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry",
"org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer.AuthorizationManagerRequestMatcherRegistry",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ && 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());
return newV52FactoryMethodTemplate(ctx).apply(getCursor(), newClass.getCoordinates().replace());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void loggingFileSubproperties() {
logging.file.max-size=10MB
logging.file.max-history=10
logging.path=${user.home}/some-folder
""","""
""", """
logging.file.max-size=10MB
logging.file.max-history=10
logging.file.path=${user.home}/some-folder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void useTls() {
@Test
void useTlsEmptyProperties() {
rewriteRun(
spec -> spec.recipe(new UseTlsAmqpConnectionString("", 5672, 5671, null, null)),
spec -> spec.recipe(new UseTlsAmqpConnectionString("", 5672, 5671, null, null)),
yaml(
"""
spring:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Stream<ModuleDownload> download(String version) {
"maven", "tests", "spring-boot-versions");
HttpUrlConnectionSender httpSender = new HttpUrlConnectionSender();

HttpSender.Request request = HttpSender.Request.build((version.contains("-RC") ? milestoneRepositoryUrl : repositoryUrl) + "/org/springframework/boot", httpSender)
HttpSender.Request request = HttpSender.Request.build((version.contains("-RC") ? milestoneRepositoryUrl : repositoryUrl) + "/org/springframework/boot", httpSender)
.withMethod(HttpSender.Method.GET)
.build();

Expand All @@ -71,20 +71,20 @@ public Stream<ModuleDownload> download(String version) {
return modules.stream()
.map(module -> {
HttpSender.Request moduleRequest = HttpSender.Request
.build((version.contains("-RC") ? milestoneRepositoryUrl : repositoryUrl) + "/org/springframework/boot/" + module + "/" + version +
.build((version.contains("-RC") ? milestoneRepositoryUrl : repositoryUrl) + "/org/springframework/boot/" + module + "/" + version +
"/" + module + "-" + version + ".jar", httpSender)
.withMethod(HttpSender.Method.GET)
.build();

try(HttpSender.Response moduleResponse = httpSender.send(moduleRequest)) {
try (HttpSender.Response moduleResponse = httpSender.send(moduleRequest)) {
if (!moduleResponse.isSuccessful()) {
if (moduleResponse.getCode() == 404) {
return null;
}
throw new IOException("Unexpected code " + moduleResponse);
}
byte[] body = moduleResponse.getBodyAsBytes();
if(body.length == 0) {
if (body.length == 0) {
return null;
}
return new ModuleDownload(module, body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ReplaceDeprecatedEnvironmentTestUtilsTest implements RewriteTest {
@Override
public void defaults(RecipeSpec spec) {
spec.recipe(new ReplaceDeprecatedEnvironmentTestUtils())
.parser(JavaParser.fromJavaVersion().classpath("spring-beans","spring-core","spring-context","spring-boot-test","spring-web"));
.parser(JavaParser.fromJavaVersion().classpath("spring-beans", "spring-core", "spring-context", "spring-boot-test", "spring-web"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CustomMvcConfigurer(String someArg) {
this.someArg = someArg;
}
}
""","""
""", """
package a.b.c;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void test() {
);
}

@Disabled ("see an error: AST contains missing or invalid type information")
@Disabled("see an error: AST contains missing or invalid type information")
@Test
void constructorWithAttributeArray() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Map<String, Object> foo() {
return Map.of("foo", "bar");
}
}
""","""
""", """
import java.util.Map;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -113,7 +113,7 @@ Map<String, Object> foo() {
return Map.of("foo", "bar");
}
}
""","""
""", """
import java.util.Map;
import org.springframework.http.MediaType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new ReplaceGlobalMethodSecurityWithMethodSecurity())
.parser(JavaParser.fromJavaVersion()
.logCompilationWarningsAndErrors(true)
.classpathFromResources(new InMemoryExecutionContext(),"spring-security-config-5.8.+"));
.classpathFromResources(new InMemoryExecutionContext(), "spring-security-config-5.8.+"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new UpdateArgon2PasswordEncoder())
.parser(JavaParser.fromJavaVersion()
.logCompilationWarningsAndErrors(true)
.classpathFromResources(new InMemoryExecutionContext(),"spring-security-crypto-5.8.+"));
.classpathFromResources(new InMemoryExecutionContext(), "spring-security-crypto-5.8.+"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new UpdatePbkdf2PasswordEncoder())
.parser(JavaParser.fromJavaVersion()
.logCompilationWarningsAndErrors(true)
.classpathFromResources(new InMemoryExecutionContext(),"spring-security-crypto-5.8.+"));
.classpathFromResources(new InMemoryExecutionContext(), "spring-security-crypto-5.8.+"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new UpdateSCryptPasswordEncoder())
.parser(JavaParser.fromJavaVersion()
.logCompilationWarningsAndErrors(true)
.classpathFromResources(new InMemoryExecutionContext(),"spring-security-crypto-5.8.+"));
.classpathFromResources(new InMemoryExecutionContext(), "spring-security-crypto-5.8.+"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ SecurityFilterChain securityFilterChain(HttpSecurity http) {
return http.build();
}
}
""","""
""", """
package com.example.demo;
import org.springframework.context.annotation.Bean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new PropagateAuthenticationServiceExceptions())
.parser(JavaParser.fromJavaVersion()
.logCompilationWarningsAndErrors(true)
.classpathFromResources(new InMemoryExecutionContext(),"spring-context-5.3.+", "spring-beans-5.3.+", "spring-web-5.3.+", "spring-security-web-5.8.+", "spring-security-config-5.8.+"));
.classpathFromResources(new InMemoryExecutionContext(), "spring-context-5.3.+", "spring-beans-5.3.+", "spring-web-5.3.+", "spring-security-web-5.8.+", "spring-security-config-5.8.+"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new RemoveFilterSecurityInterceptorOncePerRequest())
.parser(JavaParser.fromJavaVersion()
.logCompilationWarningsAndErrors(true)
.classpathFromResources(new InMemoryExecutionContext(),"spring-context-5.3.+", "spring-beans-5.3.+", "spring-web-5.3.+", "spring-security-web-5.8.+", "spring-security-config-5.8.+"));
.classpathFromResources(new InMemoryExecutionContext(), "spring-context-5.3.+", "spring-beans-5.3.+", "spring-web-5.3.+", "spring-security-web-5.8.+", "spring-security-config-5.8.+"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new RemoveOauth2LoginConfig())
.parser(JavaParser.fromJavaVersion()
.logCompilationWarningsAndErrors(true)
.classpathFromResources(new InMemoryExecutionContext(),"spring-context-5.3.+", "spring-beans-5.3.+", "spring-web-5.3.+", "spring-security-web-5.8.+", "spring-security-config-5.8.+"));
.classpathFromResources(new InMemoryExecutionContext(), "spring-context-5.3.+", "spring-beans-5.3.+", "spring-web-5.3.+", "spring-security-web-5.8.+", "spring-security-config-5.8.+"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new RequireExplicitSavingOfSecurityContextRepository())
.parser(JavaParser.fromJavaVersion()
.logCompilationWarningsAndErrors(true)
.classpathFromResources(new InMemoryExecutionContext(),"spring-security-config-5.8.+", "spring-security-web-5.8.+"));
.classpathFromResources(new InMemoryExecutionContext(), "spring-security-config-5.8.+", "spring-security-web-5.8.+"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new UpdateRequestCache())
.parser(JavaParser.fromJavaVersion()
.logCompilationWarningsAndErrors(true)
.classpathFromResources(new InMemoryExecutionContext(),"spring-context-5.3.+", "spring-beans-5.3.+", "spring-web-5.3.+", "spring-security-web-5.8.+", "spring-security-config-5.8.+"));
.classpathFromResources(new InMemoryExecutionContext(), "spring-context-5.3.+", "spring-beans-5.3.+", "spring-web-5.3.+", "spring-security-web-5.8.+", "spring-security-config-5.8.+"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new UseSha256InRememberMe())
.parser(JavaParser.fromJavaVersion()
.logCompilationWarningsAndErrors(true)
.classpathFromResources(new InMemoryExecutionContext(),"spring-beans-6.0.+", "spring-context-6.0.+", "spring-security-core-6.0.+", "spring-security-config-6.0.+", "spring-security-web-6.0.+"));
.classpathFromResources(new InMemoryExecutionContext(), "spring-beans-6.0.+", "spring-context-6.0.+", "spring-security-core-6.0.+", "spring-security-config-6.0.+", "spring-security-web-6.0.+"));
}

@DocumentExample
Expand Down

0 comments on commit 23e0c1b

Please sign in to comment.