pmd/pmd

[jsp] NoClassAttribute rule is generating a false positive

Fermée

#2 033 ouverte le 27 sept. 2019

 (8 commentaires) (0 réaction) (0 personne assignée)Java (1 461 forks)batch import
a:false-positivegood first issue

Métriques du dépôt

Stars
 (4 544 étoiles)
Métriques de merge PR
 (Merge moyen 3j 19h) (78 PRs mergées en 30 j)

Description

Affects PMD Version: 6.18.0+ 7.0.0

Rule: NoClassAttribute

Description: The rule generates an error for a jsp:usebean tag whose "class" is specified.

Code Sample demonstrating the issue: In JSP page:

<jsp:usebean id="data" class="jdbc.JdbcBean"/>

Running PMD through: Any.

The rule needs the ability to exclude the above JSP tag.

https://stackoverflow.com/questions/39035297/what-is-the-difference-between-class-and-styleclass-attributes?rq=1

The other option is to suppress this false-positive violation. Suppressing via the message generated by PMD is not possible currently since the message does not list the offending tag. PMD doesn't compile the JSP files into java source. (Does PMD intend to go down that route?) Suppressing via Xpath isn't possible either.

https://pmd.github.io/latest/pmd_userdocs_suppressing_warnings.html#xpath-and-regex-message-suppression

Is it possible that PMD can generate ASTs for JSPs as well in the future?

The rule could be modified to ignore the above tag with a default property value which is extensible to user-specified tags if necessary.

Suppressions won't be needed in that case.

Guide contributeur