From 9492ca02c171e52a11814712f4951b1aa404eba9 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 18 Feb 2020 11:53:00 +0000 Subject: [PATCH] Add test for non-nested if statements --- .../impl/xml/CognitiveComplexityTest.xml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/metrics/impl/xml/CognitiveComplexityTest.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/metrics/impl/xml/CognitiveComplexityTest.xml index f1123e76dc..ae79cff889 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/metrics/impl/xml/CognitiveComplexityTest.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/metrics/impl/xml/CognitiveComplexityTest.xml @@ -48,4 +48,31 @@ ]]> + + + Non nested if statements don't incur a penalty + 1 + + 'c__Foo#foo(Integer)' has value 3. + + + 0) { // +1 + return "positive"; + } + + if (n == 0) { // +1 + return "zero"; + } + + if (n < 0) { // +1 + return "negative"; + } + } + } + ]]> + + \ No newline at end of file