diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/impl/AllMetricsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/impl/AllMetricsTest.java
index 4f60d06fa6..f829c0ee65 100644
--- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/impl/AllMetricsTest.java
+++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/impl/AllMetricsTest.java
@@ -20,6 +20,7 @@ public class AllMetricsTest extends SimpleAggregatorTst {
public void setUp() {
addRule(RULESET, "CycloTest");
addRule(RULESET, "WmcTest");
+ addRule(RULESET, "CognitiveComplexityTest");
}
}
diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/impl/CognitiveComplexityTestRule.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/impl/CognitiveComplexityTestRule.java
new file mode 100644
index 0000000000..c7e9194967
--- /dev/null
+++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/impl/CognitiveComplexityTestRule.java
@@ -0,0 +1,19 @@
+package net.sourceforge.pmd.lang.apex.metrics.impl;
+
+import net.sourceforge.pmd.lang.apex.metrics.api.ApexClassMetricKey;
+import net.sourceforge.pmd.lang.apex.metrics.api.ApexOperationMetricKey;
+
+/**
+ * @author Gwilym Kuiper
+ */
+public class CognitiveComplexityTestRule extends AbstractApexMetricTestRule {
+ @Override
+ protected ApexClassMetricKey getClassKey() {
+ return null;
+ }
+
+ @Override
+ protected ApexOperationMetricKey getOpKey() {
+ return ApexOperationMetricKey.COGNITIVE;
+ }
+}
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
new file mode 100644
index 0000000000..b5a09067e0
--- /dev/null
+++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/metrics/impl/xml/CognitiveComplexityTest.xml
@@ -0,0 +1,26 @@
+
+
+
+ If statements have complexity 1
+ 1
+
+ 'c__Foo#foo(Integer)' has value 1.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pmd-apex/src/test/resources/rulesets/apex/metrics_test.xml b/pmd-apex/src/test/resources/rulesets/apex/metrics_test.xml
index b9980f7571..cbb1c7324f 100644
--- a/pmd-apex/src/test/resources/rulesets/apex/metrics_test.xml
+++ b/pmd-apex/src/test/resources/rulesets/apex/metrics_test.xml
@@ -19,4 +19,9 @@
class="net.sourceforge.pmd.lang.apex.metrics.impl.WmcTestRule">
+
+
+