diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index 5fa512f199..82eabc145a 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -56,13 +56,7 @@ TODO - Release blockers - Must implement before this release can be finished for the new XML language. o Rework RuleReference to be done via Rule.isReference() instead of instanceof RuleReference? o Do something with ExternalRuleID, this should be inner class of RuleSetFactory? - o Rule properties need to be cleaned up. We have the descriptor approach, and - the simple named (but not type safe) approach. The descriptor approach - should be the required approach. If we need runtime definition of properties - (e.g. XML only), perhaps we need to make it explicit in the XML markup via - a elements (wrapper around PropertyDescriptor interface), - versus element which should _only_ assign a non-default value to - a property? Further, Rule documentation should be automatically generated + o Rule documentation should be automatically generated from the descriptors, be they defined in code or XML, I think the code based descriptors are not getting seen. o Enhance Rule Designer to allow testing of the violation suppress Regex and XPath. @@ -405,7 +399,7 @@ Fixed ClassCastException on generic method in BeanMembersShouldSerialize Fixed ClassCastException in symbol table code retroweaver updated to version 2.0.6. -New rules: +New Java rules: Coupling ruleset: LoosePackageCoupling Controversial ruleset: AvoidPrefixingMethodParameters @@ -414,6 +408,9 @@ New rules: Basic ruleset: EmptyInitializer,EmptyStatementBlock,ExtendsObject,UselessParentheses,CheckSkipResult Design ruleset: LogicInversion,UseVarargs +New XML rules: + Basic ruleset: MistypedCDATASection + March 25, 2008 - 4.2: Fixed bug 1920155 - CheckResultSet: Does not pass for loop conditionals diff --git a/pmd/regress/test/net/sourceforge/pmd/lang/xml/rule/basic/BasicRulesTest.java b/pmd/regress/test/net/sourceforge/pmd/lang/xml/rule/basic/BasicRulesTest.java new file mode 100644 index 0000000000..152e8e0482 --- /dev/null +++ b/pmd/regress/test/net/sourceforge/pmd/lang/xml/rule/basic/BasicRulesTest.java @@ -0,0 +1,20 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ +package test.net.sourceforge.pmd.lang.xml.rule.basic; + +import org.junit.Before; + +import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst; + +public class BasicRulesTest extends SimpleAggregatorTst { + + @Before + public void setUp() { + addRule("xml-basic", "MistypedCDATASection"); + } + + public static junit.framework.Test suite() { + return new junit.framework.JUnit4TestAdapter(BasicRulesTest.class); + } +} diff --git a/pmd/regress/test/net/sourceforge/pmd/lang/xml/rule/basic/xml/MistypedCDATASection.xml b/pmd/regress/test/net/sourceforge/pmd/lang/xml/rule/basic/xml/MistypedCDATASection.xml new file mode 100644 index 0000000000..2b97f445f3 --- /dev/null +++ b/pmd/regress/test/net/sourceforge/pmd/lang/xml/rule/basic/xml/MistypedCDATASection.xml @@ -0,0 +1,70 @@ + + + + No CDATASection + 0 + + + + + ]]> + xml + + + Valid CDATASection + 0 + + + ]]> + + ]]> + xml + + + CDATASection with [ and ] in it, but not at the ends + 0 + + + ]]> + + ]]> + xml + + + CDATASection with [ at the beginning + 1 + + + ]]> + + ]]> + xml + + + CDATASection with ] at the end + 1 + + + ]]> + + ]]> + xml + + diff --git a/pmd/rulesets/xml/basic.xml b/pmd/rulesets/xml/basic.xml new file mode 100644 index 0000000000..4728e691ed --- /dev/null +++ b/pmd/rulesets/xml/basic.xml @@ -0,0 +1,38 @@ + + + + +The Basic XML Ruleset contains a collection of good practices which everyone should follow. + + + + +An XML CDATA section begins with a <!CDATA[ marker, which has only one [, and ends with a ]]> marker, which has only two ]. + + 3 + + + + + + + + + + + + + \ No newline at end of file diff --git a/pmd/src/net/sourceforge/pmd/SimpleRuleSetNameMapper.java b/pmd/src/net/sourceforge/pmd/SimpleRuleSetNameMapper.java index 40ff196937..9dd9ee6ec6 100644 --- a/pmd/src/net/sourceforge/pmd/SimpleRuleSetNameMapper.java +++ b/pmd/src/net/sourceforge/pmd/SimpleRuleSetNameMapper.java @@ -42,6 +42,7 @@ public class SimpleRuleSetNameMapper { } private void populateNameMap() { + // TODO Can these non-Language suffixed short names still continue? Would "java-basic" be more appropriate? nameMap.put("basic", "rulesets/basic.xml"); nameMap.put("jsp", "rulesets/basic-jsp.xml"); nameMap.put("jsf", "rulesets/basic-jsf.xml"); @@ -70,6 +71,7 @@ public class SimpleRuleSetNameMapper { nameMap.put("typeresolution", "rulesets/typeresolution.xml"); nameMap.put("unusedcode", "rulesets/unusedcode.xml"); nameMap.put("useless", "rulesets/useless.xml"); + nameMap.put("xml-basic", "rulesets/xml/basic.xml"); nameMap.put("33", "rulesets/releases/33.xml"); nameMap.put("34", "rulesets/releases/34.xml"); nameMap.put("35", "rulesets/releases/35.xml");