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 e92d50a commit 53f8787
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public String getFactoryType() {
}

public static LoggingFramework fromOption(@Nullable String option) {
if(option != null) {
if (option != null) {
for (LoggingFramework value : values()) {
if (value.toString().equalsIgnoreCase(option)) {
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private static Object getLiteralValue(J.Literal literal) {
}
return literal
.getValueSource()
.substring(1, literal.getValueSource().length() -1)
.substring(1, literal.getValueSource().length() - 1)
.replace("\\", "\\\\");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,23 @@ public enum Level {
@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
String methodPattern = "org.slf4j.Logger " + from.name().toLowerCase() + "(..)";
return Preconditions.check(new UsesMethod<>(methodPattern), new JavaIsoVisitor<ExecutionContext>() {
return Preconditions.check(new UsesMethod<>(methodPattern), new JavaIsoVisitor<ExecutionContext>() {
final MethodMatcher logMatcher = new MethodMatcher(methodPattern);
@Override
public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
J.MethodInvocation m = super.visitMethodInvocation(method, ctx);
if(!logMatcher.matches(m)) {
if (!logMatcher.matches(m)) {
return m;
}
List<Expression> args = m.getArguments();
if(args.size() == 0) {
if (args.size() == 0) {
return m;
}
J.Literal lit = leftMostLiteral(args.get(0));
if(lit == null || lit.getValue() == null) {
if (lit == null || lit.getValue() == null) {
return m;
}
if(!StringUtils.isBlank(startsWith) && !lit.getValue().toString().startsWith(startsWith)) {
if (!StringUtils.isBlank(startsWith) && !lit.getValue().toString().startsWith(startsWith)) {
return m;
}
m = (J.MethodInvocation) new ChangeMethodName(methodPattern, to.name().toLowerCase(), true, null)
Expand All @@ -100,10 +100,10 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu

@Nullable
J.Literal leftMostLiteral(Expression arg) {
if(arg instanceof J.Literal) {
if (arg instanceof J.Literal) {
return (J.Literal) arg;
}
if(arg instanceof J.Binary) {
if (arg instanceof J.Binary) {
return leftMostLiteral(((J.Binary) arg).getLeft());
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method,
Expression lastParameter = args.get(args.size() - 1);

boolean isLastParameterAnException = lastParameter instanceof J.Identifier &&
TypeUtils.isAssignableTo("java.lang.Throwable",lastParameter.getType());
TypeUtils.isAssignableTo("java.lang.Throwable", lastParameter.getType());
if (isLastParameterAnException) {
return method;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void method() {

@Issue("https://github.com/openrewrite/rewrite-logging-frameworks/issues/101")
@Test
void doNotChangeGetClassOnNonFinalClass(){
void doNotChangeGetClassOnNonFinalClass() {
//language=java
rewriteRun(
java(
Expand Down

0 comments on commit 53f8787

Please sign in to comment.