Rules that help you discover design issues.
Table of Contents NoInlineScriptSince: PMD 4.0
Priority: Medium (3)
Avoid inlining HTML script content. Consider externalizing the HTML script using the âsrcâ attribute on the "script" element. Externalized script could be reused between pages. Browsers can also cache the script, reducing overall download bandwidth.
This rule is defined by the following XPath expression:
//HtmlScript[@Content != '']
Use this rule by referencing it:
<rule ref="category/jsp/design.xml/NoInlineScript" />
NoInlineStyleInformation
Since: PMD 3.6
Priority: Medium (3)
Style information should be put in CSS files, not in JSPs. Therefore, donât use <B> or <FONT> tags, or attributes like "align=âcenterâ".
This rule is defined by the following Java class: net.sourceforge.pmd.lang.jsp.rule.design.NoInlineStyleInformationRule
Example(s):
<html><body><p align='center'><b>text</b></p></body></html>
Use this rule by referencing it:
<rule ref="category/jsp/design.xml/NoInlineStyleInformation" />
NoLongScripts
Since: PMD 3.6
Priority: Medium High (2)
Scripts should be part of Tag Libraries, rather than part of JSP pages.
This rule is defined by the following XPath expression:
//HtmlScript[(@EndLine - @BeginLine > 10)]
Example(s):
<HTML>
<BODY>
<!--Java Script-->
<SCRIPT language="JavaScript" type="text/javascript">
<!--
function calcDays(){
var date1 = document.getElementById('d1').lastChild.data;
var date2 = document.getElementById('d2').lastChild.data;
date1 = date1.split("-");
date2 = date2.split("-");
var sDate = new Date(date1[0]+"/"+date1[1]+"/"+date1[2]);
var eDate = new Date(date2[0]+"/"+date2[1]+"/"+date2[2]);
var daysApart = Math.abs(Math.round((sDate-eDate)/86400000));
document.getElementById('diffDays').lastChild.data = daysApart;
}
onload=calcDays;
//-->
</SCRIPT>
</BODY>
</HTML>
Use this rule by referencing it:
<rule ref="category/jsp/design.xml/NoLongScripts" />
NoScriptlets
Since: PMD 3.6
Priority: Medium (3)
Scriptlets should be factored into Tag Libraries or JSP declarations, rather than being part of JSP pages.
This rule is defined by the following XPath expression:
//JspScriptlet
|
//Element[ upper-case(@Name)="JSP:SCRIPTLET" ]
Example(s):
<HTML>
<HEAD>
<%
response.setHeader("Pragma", "No-cache");
%>
</HEAD>
<BODY>
<jsp:scriptlet>String title = "Hello world!";</jsp:scriptlet>
</BODY>
</HTML>
Use this rule by referencing it:
<rule ref="category/jsp/design.xml/NoScriptlets" />
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4