PMD and auto generated code in Netbeans
I'm using Netbeans to build a GUI application and PMD "complains" about things in the auto-generated code. Can I configure PMD to ignore auto-generated code (as I did with Checkstyle)?
Thank you.
There are a couple things that you can do:
A. Alter the template for the type of form to include some of the magic strings that are discussed on this page about suppressing PMD warnings.
Use the Templates item of the Tools menu to open the 'Template Manager' dialog.
Find the folder labeled 'Swing GUI Forms' and expand that node.
Select a template and press the 'Open in Editor' button.
Change the
@SuppressWarnings("unchecked")
to@SuppressWarnings({"unchecked", "PMD"})
Note: You can apply this last step to any of the forms that you have already created.
B. Create a ruleset that does not include the warnings that get violated by the generated code and use that ruleset instead. There is a page that discusses creating rulesets and a page that describes how to direct PMD to use an explicit ruleset when executed from the command line.
精彩评论