acanda / eclipse-pmd

eclipse-pmd has been moved to
https://github.com/eclipse-pmd/eclipse-pmd
Other
21 stars 10 forks source link

Add context menu to reanalyze after rule set file changes #14

Open ianbrandt opened 10 years ago

ianbrandt commented 10 years ago

It would be nice to have a context menu such as "PMD > Check Code with PMD" that picks up changes to active rule set files and reanalyzes. For prior art see "Checkstyle > Check Code with Checkstyle" and "Find Bugs > Find Bugs".

It would be great if this supported multiple selections to analyze several projects at once. A nice-to-have would be for it to work at the package/folder and file levels, again supporting multiple selections.

Looking ahead a "PMD > Configure" that shortcuts to the PMD properties page would be another use for a PMD context menu.

acanda commented 10 years ago

I'm trying to make eclipse-pmd stay out of your way as much as possible. Once enabled it should just do its thing so you can focus on writing clean code. This goal includes not introducing manual steps which could be automated and only adding context menu items when really needed (the eclipse context menus are already way to cluttered).

I'm already working on a feature that watches the rule set files and, when one of those files changes, reanalyses the respective projects automatically. This would eliminate the need for a "PMD > Check Code" context menu.

I'm also trying to make eclipse-pmd as user friendly as possible.

What were you trying to achieve when you missed a "PMD > Configure" context menu item? And in which context menu were you looking for it?

ianbrandt commented 10 years ago

I agree with automating reanalysis in theory, but I fear it might not scale well in practice. My concern would be that for larger, multi-module projects the performance of analysis could be an issue. I base this on my attempts so far to set this up for my project.

Currently I'm trying to migrate from PMD 4 to 5 at the same time as trying to switch to this plugin instead of the upstream one (for workspace configuration sharing specifically). I started by enabling the PMD nature on one of my smaller modules. It resulted in around 1500 warnings due to some new rules in 5 that I needed to exclude. Initially I decided to try enabling the PMD nature on the rest of the modules, figuring I would tune the rule file for all of them at once. I cheated and did this by propagating .eclipse-pmd and the requisite .project file changes to the other modules manually, outside of Eclipse. I started Eclipse up, refreshed the workspace, and the PMDBuilder got going as expected. Then it pegged the CPU for several minutes and eventually Eclipse reported an out-of-memory error (-Xmx1536m, -XX:MaxPermSize=512m). I'm currently retrying by enabling the nature on one module at a time, tuning the rules as I go.

Going forward, if I make a rule change when all modules are enabled, and it results in thousands of warnings being created across them, automated reanalysis on save would not be very desirable. I'd rather edit the rule file, reanalyze just one module in isolation manually, and if it appears sane reanalyze some or all of the rest of the modules as appropriate.

ianbrandt commented 10 years ago

I was thinking "MyProject > PMD > Configure", i.e. it would be a project context menu. I realize it would only be one click less than "MyProject > Properties > PMD", but when trying to tune a rule file that extra click adds up.

Staying out of the way and limiting context menus are defititely good things, and for sure there isn't a very strong convention for how plugins present their UI. That said most of the similar plugins I use present features like these in context menus, so I actually find it a bit unintuitive that eclipse-pmd doesn't have one at all. For example when I didn't find "MyProject > Configure > Enable PMD Nature", and didn't see a "MyProject > PMD" group, my third guess was to check "MyProject > Properties > PMD".

jeffjensen commented 9 years ago

@acanda "I'm already working on a feature...": would be great if you created enhancement issues so we can follow along with your plans, and know which ones are in progress! :-)