-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow multiple ruleset files #51
Allow multiple ruleset files #51
Conversation
Add the ability to chain ruleset files together from the project preferences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I need to think about this a bit further and I would like to know more about your use case:
- Do you use PMD also outside of eclipse? (e.g. maven, gradle, ant, ...)
- Do you use the same ruleset? And where do you store the ruleset?
- Do you know, that a ruleset can reference other rules and even rulesets? E.g. https://pmd.github.io/pmd-6.6.0/pmd_userdocs_making_rulesets.html#bulk-adding-rules
This might be an alternative solution for you. However, I don't know, whether this works well with what the pmd-eclipse-plugin does...
Thanks for your time!
@@ -106,7 +107,7 @@ | |||
* @return Returns the resolved RuleSet File suitable for loading a rule | |||
* set. | |||
*/ | |||
File getResolvedRuleSetFile() throws PropertiesException; | |||
List<File> getResolvedRuleSetFile() throws PropertiesException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this returns now a List, I would expect a plural in the naming of the method, such as getResolvedRuleSetFiles()
.
// Fall back to below | ||
} | ||
List<File> files = new ArrayList<File>(); | ||
for (String ruleSetFile : getRuleSetFile().split(",")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be backwards compatible, which is good and important - so we don't change the format of the project properties file.
@adangel Thanks for taking a look at this. Please find my answers below.
My company would like to start spinning up custom PMD rules around security, but we would also like to have the default ones from the PMD app. It doesn't seem that we can spin up another project and include that new ruleset in the tools folder's ruleset.xml. |
I was looking for this feature!
Will this PR be merged soon? |
Thanks for following up. I'll have a closer look next week (want to do some tests first). |
If you need and example, use this: projectA.zip Here you have a Gradle project
pmd.xml adds a specific rule My target here is to disable running from projectA folder versionsGradle 4.10.2 you need buildship to import this into eclipse. |
Hi @regrog , |
Yeah I can test it out soon.
Phillip Krall
…On Fri, Sep 28, 2018 at 1:20 PM Andreas Dangel ***@***.***> wrote:
Hi @regrog <https://github.com/regrog> ,
I've merged this PR, so it is possible now to select multiple rulesets.
Would you mind testing it?
You can get the zipped update-site from here:
https://dl.bintray.com/pmd/pmd-eclipse-plugin/snapshots/zipped/net.sourceforge.pmd.eclipse.p2updatesite-4.0.18.v20180928-1702.zip
(using the normal snapshot update site
https://dl.bintray.com/pmd/pmd-eclipse-plugin/snapshots/updates/ is very
slow unfortunately due to too many snapshot versions...)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#51 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AIIXQampF7kq-IKfOxNRcsb5T7l1ukIFks5uflpegaJpZM4VKWqK>
.
|
Damn, I think this doesn't solve my case. My rules:
useUtilityClass.xml
|
@regrog I assume, merging both rulesets won't help either? You could maybe use Suppressions, to ignore certain rules for some classes, e.g.
But that's more a workaround. Have you thought about moving third and second into a separate project? Since you use anyway different configurations, it sounds like, these two packages are really something different and should live in projects of their own. |
projectA is just an example to explain my situation.
Merge is not the right solution IMHO. Here is the task configured by Gradle with multiple rulesets: PmdInvoker.groovy |
@adangel @regrog Sorry I am coming into this a little late. It sounds like the solution you are looking for is to process each reset separately; however, you want to keep them all connected at the same project. Effectively saying PMD run rulesetA on codeA then PMD run rulesetB on codeA and give give me the results for both. Is this correct? If this is the case, can we just add a checkbox to the properties field ata project level and tell it to process both ruleset as explained above. Just running the PMD Review code N number of times? I think there would be crazy issues if you repeated or changed ruleset values from A to B. We would probably want to tell the user not to do that with some type of pre-process. |
Yes correct. |
As a work around, you could tell gradle to run rulesetA on codeA and pipe that to a pmd-results.xml file then do the same for rulesetB and just combine the XML files. This doesn't really help in terms of the eclipse plugin, but it sounds like you are just running gradle and seeing the results. |
Gradle works great with multiple rulesets. |
ok. I understand then. I think I stand by my proposal to add the feature to enable what you are talking about. I think we will need to come up with naming and such around it, but I think it is possible. I think you suffer performance because we would need to run pmd from each ruleset since the plugin just calls into the PMD library and as stated if one rule allowed something and other did not allow it, we might hit some odd issues. @adangel What are your thoughts on this? Does this seem like the direction you are going with the plugin? Would something like this be better added to the PMD library itself? I am happy to build this if you like. |
@regrog I had a look into your sample project and gradle - and there is nothing special about it: Executing multiple rulesets with plain PMD already works, e.g. you can execute PMD on your sample project with that commandline:
And you get the correct result - so each ruleset is applied correctly. @pkrall520 Currently the plugin deals with a single RuleSet ( If you are up to it, I'd be happy about a PR :) |
Sorry for the late reply. Yes I would be happy to help out. |
Add the ability to chain ruleset files together from the project preferences.