Skip to content

Commit

Permalink
refactor: Common static analysis issues
Browse files Browse the repository at this point in the history
Use this link to re-run the recipe: https://app.moderne.io/recipes/builder/ggZMncs1O?organizationId=T3BlblJld3JpdGU%3D

Co-authored-by: Moderne <team@moderne.io>
  • Loading branch information
2 people authored and app committed Mar 12, 2024
1 parent 9712137 commit 71a71c8
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void test() {

String formattedAssertBefore = assertBefore.formatted(chainedAssertion, firstArg, assertToReplace, secondArg);

String finalArgument = firstArg.isEmpty() && !secondArg.equals("0") ? secondArg : firstArg;
String finalArgument = firstArg.isEmpty() && !"0".equals(secondArg) ? secondArg : firstArg;
finalArgument = finalArgument.contains(".") ? finalArgument.split("\\.")[0] : finalArgument;

String before = String.format(template, formattedAssertBefore);
Expand Down Expand Up @@ -180,7 +180,7 @@ void test() {

String formattedAssertBefore = assertBefore.formatted(chainedAssertion, firstArg, assertToReplace, secondArg);

String finalArgument = firstArg.equals("") && !secondArg.equals("0") ? secondArg : firstArg;
String finalArgument = "".equals(firstArg) && !"0".equals(secondArg) ? secondArg : firstArg;
finalArgument = finalArgument.contains(".") ? finalArgument.split("\\.")[0] : finalArgument;

String before = String.format(template, formattedAssertBefore);
Expand Down Expand Up @@ -226,7 +226,7 @@ void test() {

String formattedAssertBefore = assertBefore.formatted(chainedAssertion, firstArg, assertToReplace, secondArg);

String finalArgument = firstArg.equals("") && !secondArg.equals("0") ? secondArg : firstArg;
String finalArgument = "".equals(firstArg) && !"0".equals(secondArg) ? secondArg : firstArg;
finalArgument = finalArgument.contains(".") ? finalArgument.split("\\.")[0] : finalArgument;

String before = String.format(template, formattedAssertBefore);
Expand Down Expand Up @@ -273,7 +273,7 @@ void test(Collection<String> collection, Collection<String> otherCollection) {

String formattedAssertBefore = assertBefore.formatted(chainedAssertion, firstArg, assertToReplace, secondArg);

String finalArgument = firstArg.equals("") ? secondArg : firstArg;
String finalArgument = "".equals(firstArg) ? secondArg : firstArg;

String before = String.format(template, formattedAssertBefore);
String after = String.format(template, assertAfter.formatted(dedicatedAssertion, finalArgument));
Expand Down Expand Up @@ -318,14 +318,14 @@ void test() {
}
""";
String assertBefore = "assertThat(map.%s(%s)).%s(%s);";
String assertAfter = !firstArg.equals("") && !secondArg.equals("") ? "assertThat(map).%s(%s, %s);" : "assertThat(map).%s(%s);";
String assertAfter = !"".equals(firstArg) && !"".equals(secondArg) ? "assertThat(map).%s(%s, %s);" : "assertThat(map).%s(%s);";

String formattedAssertBefore = assertBefore.formatted(chainedAssertion, firstArg, assertToReplace, secondArg);
String before = String.format(template, formattedAssertBefore);

String finalArgument = firstArg.equals("") ? secondArg : firstArg;
String finalArgument = "".equals(firstArg) ? secondArg : firstArg;
List<String> formattedArgs = new ArrayList<>(Arrays.asList(dedicatedAssertion, finalArgument));
if (!firstArg.equals("") && !secondArg.equals("")) {
if (!"".equals(firstArg) && !"".equals(secondArg)) {
formattedArgs.add(secondArg);
}
String after = String.format(template, assertAfter.formatted(formattedArgs.toArray()));
Expand Down

0 comments on commit 71a71c8

Please sign in to comment.