Closed emnvn closed 2 years ago
Hi,
It's not clear to me whether the platform still supports PMD extensions. Some Googling turned up this (although it looks like it might not have been resolved):
https://sourceforge.net/p/pmd/discussion/188193/thread/f52eec4e/
Have you tried this?
Thanks @timwebster9, I have tried it but It can't resolve my problem. I don't know whether it is supported or not. If Sonar don't support custom rules why it still support PMD plugin ?
I have had the same problem with SonarQube 4.5.6 and sonar-pmd-plugin 2.4.1/2.6. Didn't see that in the first place as we have only a small amount of custom rules and they still show up in the quality profile (as we used to embed them in a sonar-qube-plugin), but none of them is actually working.
I've tried to go back to sonar-pmd-plugin 2.3 as back then the
So the next try was to play a bit with the plugin configuration. A Rather old example on how to do this can be found here: https://github.com/SonarQubeCommunity/sonar-pmd/tree/master/its/plugin/plugins/pmd-extension-plugin
Now the key moment where that the plugin must use the repository key pmd
(as it can be seen here https://github.com/SonarQubeCommunity/sonar-pmd/blob/master/its/plugin/plugins/pmd-extension-plugin/src/main/java/org/sonar/examples/pmd/PmdExtensionRepository.java) but that is only sufficient if you use sonar-pmd-plugin 2.3.
From 2.4 onwards the server will not start anymore if you recreate a repository like this:
public void define(Context context) {
context.createRepository("pmd","java").setName("MyRepository")
you need to extend it:
NewExtendedRepository repository = context.extendRepository(REPOSITORY_KEY, "java");
To be able to reuse the RulesDefinitionXmlLoader
i wrote a thin wrapper around the NewExtendedRepository
implementing RulesDefinition.NewExtendedRepository
and delegating all rule related methods (excluding setName) to the ExtendedRepository.
That is so much tougher than it needs to be an i don't understand why pmd is not executing the rules if they are provided under a different repository name (like it used to be with findbugs-contrib). Any suggestions how to improve it?
Is this still relevant?
Old versions. Assuming not relevant anymore.
Hello,
I m using Sonar 3.4 with PMD. I have written some pmd rule in java, then I add these rules to sonar 3.4, the result that it work well.
I have plan to use sonar 5.4, when I try to add my pmd rule to sonar 5.4, It can not load these rule, I can't see any error report too.
How can I use my custom pmd rule in sonar 5.4 ?
Thanks for helping!