From 755b093c50454bbbfe2a12ce74a2d7fa9ac1ada0 Mon Sep 17 00:00:00 2001 From: Judit Knoll Date: Tue, 3 Dec 2024 16:09:46 +0100 Subject: [PATCH] move default to the end of switch-case --- .../detect/CheckAnalysisContextContainedAnnotation.java | 4 ++-- .../src/main/java/edu/umd/cs/findbugs/detect/ViewCFG.java | 6 +++--- .../edu/umd/cs/findbugs/visitclass/DismantleBytecode.java | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/CheckAnalysisContextContainedAnnotation.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/CheckAnalysisContextContainedAnnotation.java index f313ad755ce..1c04448c681 100644 --- a/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/CheckAnalysisContextContainedAnnotation.java +++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/CheckAnalysisContextContainedAnnotation.java @@ -102,8 +102,6 @@ public void visit(Code code) { @Override public void sawOpcode(int seen) { switch (seen) { - default: - break; case Const.IF_ICMPEQ: case Const.IF_ICMPNE: OpcodeStack.Item left = stack.getStackItem(1); @@ -114,6 +112,8 @@ public void sawOpcode(int seen) { .addString("Just check the sign of the result of compare or compareTo, not specific values such as 1 or -1"), this); } break; + default: + break; } } diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ViewCFG.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ViewCFG.java index b4d1738f836..3c83f104770 100644 --- a/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ViewCFG.java +++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ViewCFG.java @@ -112,9 +112,6 @@ private void analyzeMethod(ClassContext classContext, Method method, Path classD BasicBlock src = edge.getSource(); BasicBlock tgt = edge.getTarget(); switch (edge.getType()) { - default: - out.println(" Node" + src.getLabel() + " -> Node" + tgt.getLabel() + ";"); - break; case IFCMP_EDGE: out.println(" Node" + src.getLabel() + " -> Node" + tgt.getLabel() + " [shape=plaintext label=\" True branch\"];"); @@ -161,6 +158,9 @@ private void analyzeMethod(ClassContext classContext, Method method, Path classD out.println(" Node" + src.getLabel() + " -> Node" + tgt.getLabel() + " [shape=plaintext label=\" GOTO statement\"];"); break; + default: + out.println(" Node" + src.getLabel() + " -> Node" + tgt.getLabel() + ";"); + break; } } out.println("}"); diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/DismantleBytecode.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/DismantleBytecode.java index 4c708849c4a..489e30991e6 100644 --- a/spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/DismantleBytecode.java +++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/DismantleBytecode.java @@ -200,14 +200,13 @@ public ClassDescriptor getClassDescriptorOperand() { public boolean isMethodCall() { switch (opcode) { - default: - return false; case Const.INVOKEINTERFACE: case Const.INVOKESPECIAL: case Const.INVOKEVIRTUAL: case Const.INVOKESTATIC: return true; - + default: + return false; } }