From abc70c6cf683d92f66ad44a4951cd655c487983d Mon Sep 17 00:00:00 2001 From: oowekyala Date: Sun, 13 Aug 2017 18:42:46 +0200 Subject: [PATCH] Fix test --- .../rule/metrics/xml/CyclomaticComplexity.xml | 91 ++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/metrics/xml/CyclomaticComplexity.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/metrics/xml/CyclomaticComplexity.xml index 2747ddcab4..e134bd68c4 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/metrics/xml/CyclomaticComplexity.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/metrics/xml/CyclomaticComplexity.xml @@ -348,6 +348,95 @@ } } + public void example1() { + if (a && b || b && d) { + if (y == z) { + x = 2; + } else if (y == t && !d) { + x = 2; + } else { + x = 2; + } + } + } + + public void example2() { + if (c && d) { + while (z < y) { + x = 2; + } + } + } + + public void example12() { + if (a && b || b && d) { + if (y == z) { + x = 2; + } else if (y == t && !d) { + x = 2; + } else { + x = 2; + } + } + } + + public void example22() { + if (c && d) { + while (z < y) { + x = 2; + } + } + } + + public void example3() { + if (a && !b) { + for (int n = 0; n < t; n++) { + x = 2; + } + } + } + + public void example32() { + if (a && !b) { + for (int n = 0; n < t; n++) { + x = 2; + } + } + } + + public void example4() { + switch (x) { + case 1: + x = 2; + break; + + case 2: + case 3: + x = 2; + break; + + default: + x = 2; + break; + } + } + + public void example42() { + switch (x) { + case 1: + x = 2; + break; + + case 2: + case 3: + x = 2; + break; + + default: + x = 2; + break; + } + } } ]]> @@ -357,7 +446,7 @@ Test many unreported methods 1 - The class 'Complicated' has a total cyclomatic complexity of 40 (highest 8). + The class 'Complicated' has a total cyclomatic complexity of 80 (highest 8).