diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/SwitchUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/SwitchUtils.java index 929e312aceb8..ae6d2f4a54d4 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/SwitchUtils.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/SwitchUtils.java @@ -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; } diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IfCanBeSwitch.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IfCanBeSwitch.html index f5b62d541bf8..0d9c37dcdf9d 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/IfCanBeSwitch.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IfCanBeSwitch.html @@ -7,6 +7,7 @@ switches when the project language level is Java 7 or higher.
Use the text field below to indicate the minimum number of case branches the resulting switch statement should have. +The default branch is not counted.
Use the first checkbox below to have this inspection suggest switch statements on primitive and boxed numbers and characters. diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/migration/IfCanBeSwitchInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/migration/IfCanBeSwitchInspectionTest.java index 0ba9d39fbcf5..ae4c065585ce 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/migration/IfCanBeSwitchInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/migration/IfCanBeSwitchInspectionTest.java @@ -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; }