Skip to content

Commit

Permalink
redundant variable should ignore large expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Luro02 committed Apr 2, 2024
1 parent efb3bb8 commit 7625570
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

@ExecutableCheck(reportedProblems = {ProblemType.REDUNDANT_VARIABLE})
public class RedundantVariable extends IntegratedCheck {
private static final int MAX_EXPRESSION_SIZE = 40;

/**
* Checks if the given statement does not influence the variable returned by the return statement.
*
Expand All @@ -32,7 +34,7 @@ private boolean isAllowedStatement(CtStatement ctStatement) {
}

private boolean isComplexExpression(CtExpression<?> ctExpression) {
return ctExpression instanceof CtSwitchExpression<?,?>;
return ctExpression instanceof CtSwitchExpression<?,?> || ctExpression.toString().length() > MAX_EXPRESSION_SIZE;
}

private void checkVariableRead(CtStatement ctStatement, CtVariableRead<?> ctVariableRead) {
Expand Down

0 comments on commit 7625570

Please sign in to comment.