Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,15 @@ public final class IfChainToSwitch extends BugChecker implements IfTreeMatcher {
private final boolean enableMain;
private final boolean enableSafe;
private final int maxChainLength;
private final int minChainLength;
private final ConstantExpressions constantExpressions;

@Inject
IfChainToSwitch(ErrorProneFlags flags, ConstantExpressions constantExpressions) {
enableMain = flags.getBoolean("IfChainToSwitch:EnableMain").orElse(false);
enableMain = flags.getBoolean("IfChainToSwitch:EnableMain").orElse(true);
enableSafe = flags.getBoolean("IfChainToSwitch:EnableSafe").orElse(false);
maxChainLength = flags.getInteger("IfChainToSwitch:MaxChainLength").orElse(50);
minChainLength = flags.getInteger("IfChainToSwitch:MinChainLength").orElse(5);
this.constantExpressions = constantExpressions;
}

Expand Down Expand Up @@ -184,7 +186,7 @@ private Description analyzeIfTree(IfTree ifTree, VisitorState state) {

if (!ifChainAnalysisState.validity().equals(Validity.VALID)
// Exclude short if-chains, since they may be more readable as-is
|| ifChainAnalysisState.depth() < 3) {
|| ifChainAnalysisState.depth() < minChainLength) {
return NO_MATCH;
}

Expand Down
Loading
Loading