forked from phoedos/pmd
Merge branch 'master' into pmd/7.0.x
This commit is contained in:
@ -1501,7 +1501,7 @@ public class Foo {
|
||||
</test-code>
|
||||
|
||||
|
||||
<test-code regressionTest="false">
|
||||
<test-code disabled="true">
|
||||
<!--
|
||||
Demonstrate that authorization for sub-relation queries doesn't work properly; see checkForAccessibility()
|
||||
See https://github.com/pmd/pmd/issues/2775
|
||||
|
@ -146,7 +146,7 @@ public class StatementAndBraceFinder {
|
||||
<code-ref id="full-example"/>
|
||||
</test-code>
|
||||
|
||||
<test-code regressionTest="false">
|
||||
<test-code disabled="true">
|
||||
<description>TODO: known limitation, should report 1</description>
|
||||
<!-- <rule-property name="reportClasses">false</rule-property> -->
|
||||
<expected-problems>1</expected-problems>
|
||||
|
@ -285,7 +285,7 @@ public class Foo {
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code regressionTest="false">
|
||||
<test-code disabled="true">
|
||||
<description>#46 False +: Unused private field: call to instance of self, received from another class</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
|
@ -885,7 +885,7 @@ class InvalidLogMessageFormatTest {
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code regressionTest="false">
|
||||
<test-code disabled="true">
|
||||
<description>[java] InvalidLogMessageFormat false-negative for a lambda argument #2255</description>
|
||||
<expected-problems>3</expected-problems>
|
||||
<expected-linenumbers>11,13,16</expected-linenumbers>
|
||||
|
@ -68,7 +68,7 @@ end Test;
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code regressionTest="false">
|
||||
<test-code disabled="true">
|
||||
<description>Invalid example: suspicious reference to X</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.w3c.dom.Attr;
|
||||
@ -240,7 +240,8 @@ class BaseTestParserImpl {
|
||||
}
|
||||
String propertyName = nameAttr.getNodeValue();
|
||||
if (knownProps.getPropertyDescriptor(propertyName) == null) {
|
||||
Stream<String> knownNames = knownProps.getPropertyDescriptors().stream().map(PropertyDescriptor::name);
|
||||
String knownNames = knownProps.getPropertyDescriptors().stream().map(PropertyDescriptor::name)
|
||||
.collect(Collectors.joining(", "));
|
||||
err.at(nameAttr).error("Unknown property, known property names are {0}", knownNames);
|
||||
continue;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import net.sourceforge.pmd.annotation.Experimental;
|
||||
import com.github.oowekyala.ooxml.messages.NiceXmlMessageSpec;
|
||||
import com.github.oowekyala.ooxml.messages.OoxmlFacade;
|
||||
import com.github.oowekyala.ooxml.messages.PositionedXmlDoc;
|
||||
import com.github.oowekyala.ooxml.messages.PrintStreamMessageHandler;
|
||||
import com.github.oowekyala.ooxml.messages.XmlException;
|
||||
import com.github.oowekyala.ooxml.messages.XmlMessageReporter;
|
||||
import com.github.oowekyala.ooxml.messages.XmlMessageReporterBase;
|
||||
@ -57,7 +58,9 @@ public class TestSchemaParser {
|
||||
* @throws XmlException If parsing throws this
|
||||
*/
|
||||
public RuleTestCollection parse(Rule rule, InputSource inputSource) throws IOException, XmlException {
|
||||
OoxmlFacade ooxml = new OoxmlFacade();
|
||||
// note: need to explicitly specify the writer here, so that in unit tests
|
||||
// System.err can be swapped out and in
|
||||
OoxmlFacade ooxml = new OoxmlFacade().withPrinter(new PrintStreamMessageHandler(System.err));
|
||||
PositionedXmlDoc doc = ooxml.parse(newDocumentBuilder(), inputSource);
|
||||
|
||||
try (PmdXmlReporterImpl err = new PmdXmlReporterImpl(ooxml, doc.getPositioner())) {
|
||||
|
@ -6,6 +6,7 @@ package net.sourceforge.pmd.test.schema;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
@ -86,6 +87,31 @@ public class TestSchemaParserTest {
|
||||
+ " ^^^^^^^^^^^^^^ Attribute 'regressionTest' is deprecated, use 'ignored' with inverted value\n"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknownProperty() throws IOException {
|
||||
String file = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
+ "<test-data\n"
|
||||
+ " xmlns=\"http://pmd.sourceforge.net/rule-tests\"\n"
|
||||
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
|
||||
+ " xsi:schemaLocation=\"http://pmd.sourceforge.net/rule-tests net/sourceforge/pmd/test/schema/rule-tests_1_0_0.xsd\">\n"
|
||||
+ " <test-code>\n"
|
||||
+ " <description>equality operators with Double.NaN</description>\n"
|
||||
+ " <rule-property name='invalid_property'>foo</rule-property>\n"
|
||||
+ " <expected-problems>0</expected-problems>\n"
|
||||
+ " <code><![CDATA[\n"
|
||||
+ " public class Foo {\n"
|
||||
+ " }\n"
|
||||
+ " ]]></code>\n"
|
||||
+ " </test-code>\n"
|
||||
+ "</test-data>\n";
|
||||
|
||||
errStreamCaptor.enableLog();
|
||||
assertThrows(IllegalStateException.class, () -> parseFile(file));
|
||||
|
||||
MatcherAssert.assertThat(errStreamCaptor.getLog(), containsString(" 8| <rule-property name='invalid_property'>foo</rule-property>\n"
|
||||
+ " ^^^^ Unknown property, known property names are violationSuppressRegex, violationSuppressXPath, testIntProperty\n"));
|
||||
}
|
||||
|
||||
private RuleTestCollection parseFile(String file) throws IOException {
|
||||
MockRule mockRule = new MockRule();
|
||||
mockRule.setLanguage(PlainTextLanguage.getInstance());
|
||||
|
Reference in New Issue
Block a user