NOAM tests
This commit is contained in:
@ -34,6 +34,7 @@ public class AllMetricsTest extends SimpleAggregatorTst {
|
|||||||
addRule(RULESET, "LocTest");
|
addRule(RULESET, "LocTest");
|
||||||
addRule(RULESET, "NPathTest");
|
addRule(RULESET, "NPathTest");
|
||||||
addRule(RULESET, "NopaTest");
|
addRule(RULESET, "NopaTest");
|
||||||
|
addRule(RULESET, "NoamTest");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sourceforge.pmd.lang.java.metrics.impl;
|
||||||
|
|
||||||
|
import net.sourceforge.pmd.lang.java.metrics.api.JavaClassMetricKey;
|
||||||
|
import net.sourceforge.pmd.lang.java.metrics.api.JavaOperationMetricKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Clément Fournier
|
||||||
|
* @since 6.0.0
|
||||||
|
*/
|
||||||
|
public class NoamTestRule extends AbstractMetricTestRule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JavaClassMetricKey getClassKey() {
|
||||||
|
return JavaClassMetricKey.NOAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JavaOperationMetricKey getOpKey() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<test-data>
|
||||||
|
|
||||||
|
<code-fragment id="full-example"><![CDATA[
|
||||||
|
public class Foo {
|
||||||
|
private int value;
|
||||||
|
private double speed;
|
||||||
|
private MutableInt mutX;
|
||||||
|
private boolean bool;
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBool() {
|
||||||
|
return bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int value() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isBool() {
|
||||||
|
return bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int value() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]></code-fragment>
|
||||||
|
|
||||||
|
|
||||||
|
<test-code>
|
||||||
|
<description>Full example</description>
|
||||||
|
<expected-problems>1</expected-problems>
|
||||||
|
<expected-messages>
|
||||||
|
<message>'.Foo' has value 3.</message>
|
||||||
|
</expected-messages>
|
||||||
|
<code-ref id="full-example"/>
|
||||||
|
</test-code>
|
||||||
|
|
||||||
|
<test-code>
|
||||||
|
<description>Test no fields</description>
|
||||||
|
<expected-problems>1</expected-problems>
|
||||||
|
<expected-messages>
|
||||||
|
<message>'.Foo' has value 0.</message>
|
||||||
|
</expected-messages>
|
||||||
|
<code><![CDATA[
|
||||||
|
public class Foo {
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
|
||||||
|
<test-code>
|
||||||
|
<description>NOPA doesn't support enums, interfaces or annotations</description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public interface Foo {
|
||||||
|
|
||||||
|
public final int h;
|
||||||
|
|
||||||
|
enum Bar{
|
||||||
|
FOO;
|
||||||
|
public int bel = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@interface Tag {
|
||||||
|
public static final int num = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
|
||||||
|
</test-data>
|
@ -45,4 +45,10 @@
|
|||||||
metrics="true">
|
metrics="true">
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
|
<rule name="NoamTest"
|
||||||
|
message = "''{0}'' has value {1}."
|
||||||
|
class="net.sourceforge.pmd.lang.java.metrics.impl.NoamTestRule"
|
||||||
|
metrics="true">
|
||||||
|
</rule>
|
||||||
|
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
Reference in New Issue
Block a user