Merge branch 'pr-644'
This commit is contained in:
@@ -180,6 +180,7 @@ a warning will now be produced suggesting users to adopt it for better performan
|
||||
* [#604](https://github.com/pmd/pmd/issues/604): \[core] Incremental analysis should detect changes to jars in classpath
|
||||
* [#608](https://github.com/pmd/pmd/issues/608): \[core] Add DEBUG log when applying incremental analysis
|
||||
* [#618](https://github.com/pmd/pmd/issues/618): \[core] Incremental Analysis doesn't close file correctly on Windows upon a cache hit
|
||||
* [#643](https://github.com/pmd/pmd/issues/643): \[core] PMD Properties (dev-properties) breaks markup on CodeClimateRenderer
|
||||
* apex
|
||||
* [#488](https://github.com/pmd/pmd/pull/488): \[apex] Use Apex lexer for CPD
|
||||
* [#489](https://github.com/pmd/pmd/pull/489): \[apex] Update Apex compiler
|
||||
@@ -324,3 +325,4 @@ a warning will now be produced suggesting users to adopt it for better performan
|
||||
* [#598](https://github.com/pmd/pmd/pull/598): \[java] Fix #388: controversial.AvoidLiteralsInIfCondition 0.0 false positive - [Clément Fournier](https://github.com/oowekyala)
|
||||
* [#602](https://github.com/pmd/pmd/pull/602): \[java] \[apex] Separate multifile analysis from metrics - [Clément Fournier](https://github.com/oowekyala)
|
||||
* [#620](https://github.com/pmd/pmd/pull/620): \[core] Moved properties to n.s.pmd.properties - [Clément Fournier](https://github.com/oowekyala)
|
||||
* [#644](https://github.com/pmd/pmd/pull/644): \[core] Prevent internal dev-properties from being displayed on CodeClimate renderer - [Filipe Esperandio](https://github.com/filipesperandio)
|
||||
|
@@ -35,6 +35,7 @@ public class CodeClimateRenderer extends AbstractIncrementingRenderer {
|
||||
|
||||
// Note: required by https://github.com/codeclimate/spec/blob/master/SPEC.md
|
||||
protected static final String NULL_CHARACTER = "\u0000";
|
||||
protected static final List<String> INTERNAL_DEV_PROPERTIES = Arrays.asList("version", "xpath");
|
||||
private final String pmdDeveloperUrl;
|
||||
private Rule rule;
|
||||
|
||||
@@ -170,6 +171,11 @@ public class CodeClimateRenderer extends AbstractIncrementingRenderer {
|
||||
result += "--- | --- | ---\\n";
|
||||
|
||||
for (PropertyDescriptor<?> property : rule.getPropertyDescriptors()) {
|
||||
String propertyName = property.name().replaceAll("\\_", "\\\\_");
|
||||
if (INTERNAL_DEV_PROPERTIES.contains(propertyName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
PropertyDescriptor<T> typed = (PropertyDescriptor<T>) property;
|
||||
T value = rule.getProperty(typed);
|
||||
@@ -179,10 +185,7 @@ public class CodeClimateRenderer extends AbstractIncrementingRenderer {
|
||||
}
|
||||
propertyValue = propertyValue.replaceAll("(\n|\r\n|\r)", "\\\\n");
|
||||
|
||||
String porpertyName = property.name();
|
||||
porpertyName = porpertyName.replaceAll("\\_", "\\\\_");
|
||||
|
||||
result += porpertyName + " | " + propertyValue + " | " + property.description() + "\\n";
|
||||
result += propertyName + " | " + propertyValue + " | " + property.description() + "\\n";
|
||||
}
|
||||
}
|
||||
return cleaned(result);
|
||||
|
@@ -75,7 +75,7 @@ public abstract class AbstractRendererTst {
|
||||
return new ParametricRuleViolation<Node>(new FooRule(), ctx, node, "blah");
|
||||
}
|
||||
|
||||
private static DummyNode createNode(int endColumn) {
|
||||
protected static DummyNode createNode(int endColumn) {
|
||||
DummyNode node = new DummyNode(1);
|
||||
node.testingOnlySetBeginLine(1);
|
||||
node.testingOnlySetBeginColumn(1);
|
||||
|
@@ -4,7 +4,18 @@
|
||||
|
||||
package net.sourceforge.pmd.renderers;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.Report;
|
||||
import net.sourceforge.pmd.ReportTest;
|
||||
import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.lang.ast.DummyNode;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
|
||||
import net.sourceforge.pmd.lang.rule.XPathRule;
|
||||
|
||||
public class CodeClimateRendererTest extends AbstractRendererTst {
|
||||
|
||||
@@ -74,4 +85,24 @@ public class CodeClimateRendererTest extends AbstractRendererTst {
|
||||
+ "\"},\"categories\":[\"Style\"],\"location\":{\"path\":\"n/a\",\"lines\":{\"begin\":1,\"end\":1}},\"severity\":\"info\",\"remediation_points\":50000}"
|
||||
+ "\u0000" + PMD.EOL;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXPathRule() throws Exception {
|
||||
DummyNode node = createNode(1);
|
||||
RuleContext ctx = new RuleContext();
|
||||
ctx.setSourceCodeFilename(getSourceCodeFilename());
|
||||
Report report = new Report();
|
||||
XPathRule theRule = new XPathRule();
|
||||
theRule.setProperty(XPathRule.XPATH_DESCRIPTOR, "//dummyNode");
|
||||
|
||||
// Setup as FooRule
|
||||
theRule.setDescription("desc");
|
||||
theRule.setName("Foo");
|
||||
|
||||
report.addRuleViolation(new ParametricRuleViolation<Node>(theRule, ctx, node, "blah"));
|
||||
String rendered = ReportTest.render(getRenderer(), report);
|
||||
|
||||
// Output should be the exact same as for non xpath rules
|
||||
assertEquals(filter(getExpected()), filter(rendered));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user