IG: don't count default branch for "'if' replaceable with 'switch'" inspection (IDEA-192179)

This commit is contained in:
Bas Leijdekkers
2018-09-28 18:18:42 +02:00
parent d8fbb19781
commit 365be9d58d
3 changed files with 3 additions and 18 deletions
@@ -81,9 +81,6 @@ public class SwitchUtils {
}
final PsiStatement elseBranch = statement.getElseBranch();
if (!(elseBranch instanceof PsiIfStatement)) {
if (elseBranch != null) {
branchCount++;
}
if (branchCount < minimumBranches) {
return null;
}
@@ -7,6 +7,7 @@ switches when the project language level is Java 7 or higher.
<p>
Use the text field below to indicate the minimum
number of <b>case</b> branches the resulting <b>switch</b> statement should have.
The <b>default</b> branch is not counted.
<p>
Use the first checkbox below to have this inspection suggest <b>switch</b> statements on
primitive and boxed numbers and characters.
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.siyeh.ig.migration;
import com.intellij.codeInspection.InspectionProfileEntry;
@@ -31,6 +17,7 @@ public class IfCanBeSwitchInspectionTest extends LightInspectionTestCase {
final IfCanBeSwitchInspection inspection = new IfCanBeSwitchInspection();
inspection.suggestIntSwitches = true;
inspection.suggestEnumSwitches = true;
inspection.minimumBranches = 2;
inspection.setOnlySuggestNullSafe(true);
return inspection;
}