Menu

#500 NOPMD Doesn't work in JSFs

open
nobody
rules (229)
5
2012-10-07
2008-04-07
Adrian Gray
No

If you place a //NOPMD comment on a java file line the PMD rules ignore the line.

However, for a JSF file the equivalent NOPMD does not cause the rule to be ignored.

On viewing the source code the token "NOPMD" should have the desired effect for all files, but it does not for JSFs.

Discussion

  • Ryan Gustafson

    Ryan Gustafson - 2008-04-10

    Logged In: YES
    user_id=342470
    Originator: NO

    Yes, this behavior is current Language specific within PMD (ie. Java only). We are currently refactoring the treatment of Languages within PMD to support additional Languages. We'll see about expanding this feature across all supported languages, at least from a design perspective within the PMD core. I expect there will likely still need to be Language AST specific implementation aspects.

     
  • Adrian Gray

    Adrian Gray - 2009-04-24

    Hi,

    We have decided to implement our own work-around for JSF (and JSP) files based on the standard Java equivalents and using XML comments () instead of // comments and @ Annotations.

    For PMD rules we want to be ignored on an individual level - by placing a comment of prior to a tag you want to be ignored all of the tags at the same level within a "CONTENT" leaf are excluded - the following addition to a standard XPath rule will achieve this:-
    [not(../CommentTag [@Image="NOPMD"])]

    For globally ignoring all PMD rules within a file we can now place a comment of towards the top of a JSP/JSF file (although anywhere will do) we want to be ignored - the following addition to a standard XPath rule will achieve this:-

    [not(ancestor::Content//CommentTag [@Image='@SuppressWarnings("PMD")'])]

    If you could incorporate this idea (or very similar) into the main PMD code base I think it will be most beneficial.

    Thanks,

    Adrian Gray

     

Log in to post a comment.