Affects PMD Version:
6.6.0-SNAPSHOT
Rule:
Description:
Because JSP doesn’t draw any distinction between plain text and HTML tags, we can use <c:if> tags anywhere, for instance in the middle of an HTML tag.
Consider this use of a <c:if> tag:
<font size="2" <c:if test="${something}"> color="red" </c:if> >
<c:out value="some value" />
</font>
Of course one can rewrite this to
<c:choose>
<c:when test="${something}">
<font size="2" color="red">
</c:when>
<c:otherwise>
<font size="2">
</c:otherwise>
</c:choose>
<c:out value="some value" />
</font>
The former is currently not supported by pmd-jsp and the latter is difficult to maintain.
Handling the former can be quite cumbersome but handling a ternary operator in tag attributes it's not. By now pmd-jsp supports EL in tag attribute values, something like
<font size="2" class="${something ? 'red' : 'blue'}">
<c:out value="some value" />
</font>
But does not support EL in tag attributes
<font size="2" ${something ? 'class=\"red\"' : ''}>
<c:out value="some value" />
</font>
Running PMD through: [Maven]
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