PMD rule messages

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

PMD rule messages

Caleb Knox
Hey all,

For PMD rule messages, can we somehow pass a parameter from a rule's Java class into the XML file?

For example:

"You had " + count + " repeated increment statements. This is above the threshold. Try instead: var += " + count + "."

or something.

Thanks much.

--
Caleb Knox

Endeveran

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Pmd-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/pmd-devel
Reply | Threaded
Open this post in threaded view
|

Re: PMD rule messages

Juan Martín Sotuyo Dodero
Yes you can. You have a couple overrides to `addViolation` that allow passing arguments for message interpolation. https://github.com/pmd/pmd/blob/master/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java#L421-L435

On Fri, Jul 14, 2017 at 2:18 PM, Caleb Knox <[hidden email]> wrote:
Hey all,

For PMD rule messages, can we somehow pass a parameter from a rule's Java class into the XML file?

For example:

"You had " + count + " repeated increment statements. This is above the threshold. Try instead: var += " + count + "."

or something.

Thanks much.

--
Caleb Knox

Endeveran

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Pmd-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/pmd-devel



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Pmd-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/pmd-devel