[jsp] Move rules and tests to new packages

This commit is contained in:
Andreas Dangel
2017-11-03 15:31:00 +01:00
parent f05c865a24
commit 15526591d4
26 changed files with 101 additions and 53 deletions

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.jsp.rule.basic;
package net.sourceforge.pmd.lang.jsp.rule.codestyle;
import java.util.HashSet;
import java.util.List;

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.jsp.rule.basic;
package net.sourceforge.pmd.lang.jsp.rule.design;
import java.util.Set;

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.jsp.rule.basic;
package net.sourceforge.pmd.lang.jsp.rule.security;
import net.sourceforge.pmd.lang.jsp.ast.ASTElExpression;
import net.sourceforge.pmd.lang.jsp.ast.ASTElement;

View File

@ -76,7 +76,7 @@ Do not use an attribute called 'class'. Use "styleclass" for CSS styles.
since="3.6"
message="Use JSP comments instead of HTML comments"
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_basic.html#nohtmlcomments">
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_bestpractices.html#nohtmlcomments">
<description>
In a production system, HTML comments increase the payload
between the application server to the client, and serve
@ -110,7 +110,7 @@ little other purpose. Consider switching to JSP comments.
since="3.6"
message="Do not do a forward from within a JSP file."
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_basic.html#nojspforward">
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_bestpractices.html#nojspforward">
<description>
Do not do a forward from within a JSP file.
</description>

View File

@ -12,7 +12,7 @@ Rules which enforce a specific coding style.
<rule name="DuplicateJspImports"
since="3.7"
message="Avoid duplicate imports such as ''{0}''"
class="net.sourceforge.pmd.lang.jsp.rule.basic.DuplicateJspImportsRule"
class="net.sourceforge.pmd.lang.jsp.rule.codestyle.DuplicateJspImportsRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_codestyle.html#duplicatejspimports">
<description>
Avoid duplicate import statements inside JSP's.

View File

@ -34,7 +34,7 @@ Externalized script could be reused between pages. Browsers can also cache the
<rule name="NoInlineStyleInformation"
since="3.6"
message="Avoid having style information in JSP files."
class="net.sourceforge.pmd.lang.jsp.rule.basic.NoInlineStyleInformationRule"
class="net.sourceforge.pmd.lang.jsp.rule.design.NoInlineStyleInformationRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_design.html#noinlinestyleinformation">
<description>
Style information should be put in CSS files, not in JSPs. Therefore, don't use &lt;B> or &lt;FONT>

View File

@ -44,9 +44,9 @@ through SSL. See http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q261188
<rule name="NoUnsanitizedJSPExpression"
since="5.1.4"
class="net.sourceforge.pmd.lang.jsp.rule.basic.NoUnsanitizedJSPExpressionRule"
class="net.sourceforge.pmd.lang.jsp.rule.security.NoUnsanitizedJSPExpressionRule"
message="Using unsanitized JSP expression can lead to Cross Site Scripting (XSS) attacks"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_basic.html#nounsanitizedjspexpression">
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_security.html#nounsanitizedjspexpression">
<description>
Avoid using expressions without escaping / sanitizing. This could lead to cross site scripting - as the expression
would be interpreted by the browser directly (e.g. "&lt;script&gt;alert('hello');&lt;/script&gt;").

View File

@ -1,27 +0,0 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.jsp.rule.basic;
import net.sourceforge.pmd.testframework.SimpleAggregatorTst;
public class BasicRulesTest extends SimpleAggregatorTst {
private static final String RULESET = "jsp-basic";
@Override
public void setUp() {
addRule(RULESET, "DuplicateJspImports");
addRule(RULESET, "IframeMissingSrcAttribute");
addRule(RULESET, "JspEncoding");
addRule(RULESET, "NoClassAttribute");
addRule(RULESET, "NoHtmlComments");
addRule(RULESET, "NoInlineScript");
addRule(RULESET, "NoInlineStyleInformation");
addRule(RULESET, "NoJspForward");
addRule(RULESET, "NoLongScripts");
addRule(RULESET, "NoScriptlets");
addRule(RULESET, "NoUnsanitizedJSPExpression");
}
}

View File

@ -1,17 +0,0 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.jsp.rule.basicjsf;
import net.sourceforge.pmd.testframework.SimpleAggregatorTst;
public class BasicJsfRulesTest extends SimpleAggregatorTst {
private static final String RULESET = "jsp-basic-jsf";
@Override
public void setUp() {
addRule(RULESET, "DontNestJsfInJstlIteration");
}
}

View File

@ -0,0 +1,20 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.jsp.rule.bestpractices;
import net.sourceforge.pmd.testframework.SimpleAggregatorTst;
public class BestPracticesRulesTest extends SimpleAggregatorTst {
private static final String RULESET = "category/jsp/bestpractices.xml";
@Override
public void setUp() {
addRule(RULESET, "DontNestJsfInJstlIteration");
addRule(RULESET, "NoClassAttribute");
addRule(RULESET, "NoHtmlComments");
addRule(RULESET, "NoJspForward");
}
}

View File

@ -0,0 +1,17 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.jsp.rule.codestyle;
import net.sourceforge.pmd.testframework.SimpleAggregatorTst;
public class CodeStyleRulesTest extends SimpleAggregatorTst {
private static final String RULESET = "category/jsp/codestyle.xml";
@Override
public void setUp() {
addRule(RULESET, "DuplicateJspImports");
}
}

View File

@ -0,0 +1,20 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.jsp.rule.design;
import net.sourceforge.pmd.testframework.SimpleAggregatorTst;
public class DesignRulesTest extends SimpleAggregatorTst {
private static final String RULESET = "category/jsp/design.xml";
@Override
public void setUp() {
addRule(RULESET, "NoInlineScript");
addRule(RULESET, "NoInlineStyleInformation");
addRule(RULESET, "NoLongScripts");
addRule(RULESET, "NoScriptlets");
}
}

View File

@ -0,0 +1,17 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.jsp.rule.errorprone;
import net.sourceforge.pmd.testframework.SimpleAggregatorTst;
public class ErrorProneRulesTest extends SimpleAggregatorTst {
private static final String RULESET = "category/jsp/errorprone.xml";
@Override
public void setUp() {
addRule(RULESET, "JspEncoding");
}
}

View File

@ -0,0 +1,18 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.jsp.rule.security;
import net.sourceforge.pmd.testframework.SimpleAggregatorTst;
public class SecurityRulesTest extends SimpleAggregatorTst {
private static final String RULESET = "category/jsp/security.xml";
@Override
public void setUp() {
addRule(RULESET, "IframeMissingSrcAttribute");
addRule(RULESET, "NoUnsanitizedJSPExpression");
}
}