Skip to content

Commit 03a5db9

Browse files
committed
Some linting
1 parent 46b2744 commit 03a5db9

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

framework/codemodder-base/src/main/java/io/codemodder/remediation/DefaultFixCandidateSearcher.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ public FixCandidateSearchResults<T> search(
7373
n, issueStartLine, issueEndLine, column))
7474
.orElse(nodePositionMatcher.match(n, issueStartLine, issueEndLine)))
7575
.toList();
76-
System.out.println(issueStartLine);
77-
System.out.println(maybeColumn);
78-
System.out.println(nodesForIssue);
7976
if (nodesForIssue.isEmpty()) {
8077
continue;
8178
}

framework/codemodder-base/src/main/java/io/codemodder/remediation/errorexposure/ErrorMessageExposureFixStrategy.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
/** Removes exposure from error messages. */
1515
public final class ErrorMessageExposureFixStrategy extends MatchAndFixStrategy {
1616

17-
private static List<String> printErrorMethods = List.of("printStackTrace");
18-
private static List<String> printMethods = List.of("println", "print", "sendError");
17+
private static final List<String> printErrorMethods = List.of("printStackTrace");
18+
private static final List<String> printMethods = List.of("println", "print", "sendError");
1919

2020
/**
2121
* Test if the node is an expression that is the argument of a method call
@@ -45,27 +45,25 @@ public boolean match(final Node node) {
4545

4646
@Override
4747
public SuccessOrReason fix(final CompilationUnit cu, final Node node) {
48-
// we know from the match that this is true
49-
Expression expr = (Expression) node;
5048
// find encompassing statement
5149
Optional<Statement> maybeStmt =
5250
Optional.<MethodCallExpr>empty()
5351
// grab the relevant method call from the two cases
5452
.or(
5553
() ->
5654
Optional.of(node)
57-
.map(n -> n instanceof Expression ? (Expression) n : null)
55+
.map(n -> n instanceof Expression e ? e : null)
5856
.flatMap(ASTs::isArgumentOfMethodCall)
5957
.filter(mce -> printMethods.contains(mce.getNameAsString())))
6058
// is itself a method call that send errors: e.g. err.printStackTrace()
6159
.or(
6260
() ->
6361
Optional.of(node)
64-
.map(n -> n instanceof Expression ? (Expression) n : null)
65-
.flatMap(e -> e.toMethodCallExpr())
62+
.map(n -> n instanceof Expression e ? e : null)
63+
.flatMap(Expression::toMethodCallExpr)
6664
.filter(mce -> printErrorMethods.contains(mce.getNameAsString())))
6765
// check if the method call is in a statement by itself
68-
.flatMap(mce -> mce.getParentNode())
66+
.flatMap(Node::getParentNode)
6967
.map(p -> p instanceof ExpressionStmt ? (ExpressionStmt) p : null);
7068
// Remove it
7169
if (maybeStmt.isPresent()) {

0 commit comments

Comments
 (0)