Skip to content

Commit

Permalink
Enable detection of Extract Method in commit
Browse files Browse the repository at this point in the history
spring-projects/spring-boot@793aca6
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootWar.java
  • Loading branch information
tsantalis committed Jan 20, 2025
1 parent 04c74d6 commit 3617ca3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ public String getExpression() {
}

public Replacement makeReplacementWithTernaryOnTheRight(String statement, Map<String, String> parameterToArgumentMap) {
if(getElseExpression().getString().equals(statement)) {
if(getElseExpression().getString().equals(statement) || getElseExpression().getString().equals(statement + ".get()")) {
return new Replacement(statement, getElseExpression().getString(), ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_ELSE);
}
if(getThenExpression().getString().equals(statement)) {
if(getThenExpression().getString().equals(statement) || getThenExpression().getString().equals(statement + ".get()")) {
return new Replacement(statement, getThenExpression().getString(), ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_THEN);
}
if(getCondition().getString().equals(statement) || getCondition().getString().equals(statement + ".get()")) {
return new Replacement(statement, getCondition().getString(), ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_CONDITION);
}
String temp = new String(statement);
for(String key : parameterToArgumentMap.keySet()) {
if(!key.equals(parameterToArgumentMap.get(key))) {
Expand All @@ -69,17 +72,23 @@ public Replacement makeReplacementWithTernaryOnTheRight(String statement, Map<St
if(getThenExpression().getString().equals(temp)) {
return new Replacement(statement, getThenExpression().getString(), ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_THEN);
}
if(getCondition().getString().equals(temp)) {
return new Replacement(statement, getCondition().getString(), ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_CONDITION);
}
}
return null;
}

public Replacement makeReplacementWithTernaryOnTheLeft(String statement, Map<String, String> parameterToArgumentMap) {
if(getElseExpression().getString().equals(statement)) {
if(getElseExpression().getString().equals(statement) || getElseExpression().getString().equals(statement + ".get()")) {
return new Replacement(getElseExpression().getString(), statement, ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_ELSE);
}
if(getThenExpression().getString().equals(statement)) {
if(getThenExpression().getString().equals(statement) || getThenExpression().getString().equals(statement + ".get()")) {
return new Replacement(getThenExpression().getString(), statement, ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_THEN);
}
if(getCondition().getString().equals(statement) || getCondition().getString().equals(statement + ".get()")) {
return new Replacement(getCondition().getString(), statement, ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_CONDITION);
}
String temp = new String(statement);
for(String key : parameterToArgumentMap.keySet()) {
if(!key.equals(parameterToArgumentMap.get(key))) {
Expand All @@ -93,6 +102,9 @@ public Replacement makeReplacementWithTernaryOnTheLeft(String statement, Map<Str
if(getThenExpression().getString().equals(temp)) {
return new Replacement(getThenExpression().getString(), statement, ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_THEN);
}
if(getCondition().getString().equals(temp)) {
return new Replacement(getCondition().getString(), statement, ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_CONDITION);
}
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public enum ReplacementType {
ARRAY_INITIALIZER_REPLACED_WITH_METHOD_INVOCATION_ARGUMENTS,
EXPRESSION_REPLACED_WITH_TERNARY_ELSE,
EXPRESSION_REPLACED_WITH_TERNARY_THEN,
EXPRESSION_REPLACED_WITH_TERNARY_CONDITION,
INFIX_EXPRESSION,
COMPOSITE,
CONCATENATION, CONDITIONAL,
Expand Down

0 comments on commit 3617ca3

Please sign in to comment.