Menu

#1290 RuleSetReferenceId does not process HTTP(S) correctly.

PMD-5.2.3
closed
None
PMD
3-Major
Bug
5.21
2014-12-21
2014-12-03
No

This issue was found as result of using the Sonar with maven-pmd-plugin. The maven-pmd-plugin issue, MPMD-174 - Using a permalink from sonar as a ruleset does not work, can be found here:

http://jira.codehaus.org/browse/MPMD-174

Basically, the logic (in public RuleSetReferenceId(final String id, final RuleSetReferenceId externalRuleSetReferenceId)) that determines whether the ID is a full ruleset name or not is flawed. If the given ID it is a HTTP(S) URL the stripping logic does not work correctly.

I don't know much about PMD so I don't know what is allowed and what is not, but two potential solutions could be:

  1. More naive fix is to just assume that if the ID is a HTTP(S) URL then the ID is a full ruleset. This is the case for Sonar as you get the whole file, but I don't know if that is always the case.
  2. More complicated fix, assuming that URL ruleset can specify the file and rules, would have to be to modify the parsing logic to somehow determine that this is the URL to file and it also defines the rules. This is very tricky as you can't just assume that the last "/" means that on the right side is the rule.

I was okay with fixing this in maven-pmd-plugin, but the stakeholders there rather have it fixed in the PMD's code.

Discussion

  • Maciek Siemczyk

    Maciek Siemczyk - 2014-12-03

    I've made the changes in my local fork as per solution #1. I can add a patch here or commit it on my fork. I just need to add a unit test for it.

     
  • Andreas Dangel

    Andreas Dangel - 2014-12-04

    Hi,
    It would be great if you could create a pull request on github: https://github.com/pmd/pmd

    Unfortunately I just released pmd 5.2.2 - so this bug needs to wait for 5.2.3.

     
  • Maciek Siemczyk

    Maciek Siemczyk - 2014-12-09

    Hi Andreas,

    Did I create the pull request correctly?

    Regards,
    Maciek

     
  • Andreas Dangel

    Andreas Dangel - 2014-12-09

    Yes, the pull request is fine. I'm working on it... Thanks!

     
  • Andreas Dangel

    Andreas Dangel - 2014-12-10

    Thanks again!

     
  • Andreas Dangel

    Andreas Dangel - 2014-12-10
    • status: open --> closed
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-Next
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.