user1119859
user1119859

Reputation: 719

How to run static code analysis in netbeans on save

I'm working with Netbeans and would like run static code analysis when I save a java file.

I know I can use the "Inspect" function, but this has to be called manually each time which seems quite tortuous.

Upvotes: 1

Views: 657

Answers (1)

skomisa
skomisa

Reputation: 17391

This is straightforward if you are only using FindBugs for static analysis:

  • Select Tools > Options > Editor, then select the Hints tab.
  • Select FindBugs from the Language drop list, then check the box labeled Run FindBugs in Editor. Note that the tooltip states "Will automatically run FindBugs on the currently edited file after save".

    findBugsOnSave

Notes:

  • I am not aware of any other static analysis tools being integrated into NetBeans in this manner. This solution is only good for FindBugs.
  • This will only run static analysis for the saved file, and not for the entire project. That may be viewed as good or bad, depending on your requirements.

Upvotes: 1

Related Questions