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
Need PMD Apex language support. Would contribute to it... #23
Comments
Hi @up2go-rsoesemann We are currently finishing the support for multi-language tools (should be ready next week). Still not sure if it would be better to have a separate docker for each language. Let me know what you think regarding this. Would you prefer a separate docker? In the meanwhile you can check the details about our dockers specs here If you have a way to generate the docs for out |
@rtfpessoa I fully agree that a unified PMD docker is better. For CodeClimate we simply decided to go with a separate engine for two reasons. Another person was working on a general PMD engine (never finished it ;-) and agility. With our own engine, we could easily bundle PMD snapshots to get out our rules.) So you plan sound perfect. Please keep me in the loop so I can test it and tweet about ;-) Sorry for the question, but why should I check the specs? Which kind of help do you want from me? |
Are those two JSOn files to configure the PMD internal settings (like the ruleset.xml)? How are you doing it for PMD Java in your current engine? My language module works exactely the same. There is a rulset for it. I also added some CodeClimate specific params to PMD so I'm quite sure we can do the same for Codacy. Maybe we should have a Skype chat about that. |
Currently we try to keep some docs for each pattern. If Apex patterns have some docs it would be great if we could get an easy way to generate them automatically. For example, in Java PMD have this https://pmd.github.io/pmd-5.5.2/pmd-java/rules/index.html that we map here https://github.com/codacy/codacy-pmdjava/blob/master/src/main/resources/docs Usually the pattern specs go in https://github.com/codacy/codacy-pmdjava/blob/master/src/main/resources/docs/patterns.json the descriptions go in https://github.com/codacy/codacy-pmdjava/blob/master/src/main/resources/docs/description/description.json and the extended descriptions go in their own markdowns in https://github.com/codacy/codacy-pmdjava/blob/master/src/main/resources/docs/description. Do you have anything similar for Apex? |
@up2go-rsoesemann just noticed we wrote a message at the same time. Just sent you an email so we can talk about the skype. |
We have the same for the Apex rules here: https://pmd.github.io/latest/pmd-apex/rules/index.html |
Yes. Monday works for me. I sent you an email to confirm the details. |
@up2go-rsoesemann did you get my email? |
Sure. Sorry for not replying yet. But now. ;-) |
Nice to talk with you. Thanks for the resources:
We are finishing tool multi-language support. As soon as we finish it, we will start updating this docker to support Apex. Also, we will start to evaluate the support for release channels for tool, (e.g. latest, stable, etc) and maybe speed up the release process. |
Dito. I can't wait until Apex is recognized by your PMD engine. Please let me be you beta tester. |
Hi @up2go-rsoesemann, After an initial delay we finally started working on PMD support for the remaining languages, and I have a couple more questions. I am using PMD from Scala code, and I am having one issue when I depend on Apex (seems related to the special parser). Also do you know if I can get the description XML contents from the PMD programatic api? |
@rtfpessoa great that you started. Another great tool using PMD. I need to pass your question to the two main PMD experts @jsotuyod and @adangel. |
@up2go-rsoesemann sbt is like maven but for Scala. Since it is fully compatible with Maven dependencies it should not be a problem. |
@rtfpessoa @up2go-rsoesemann I guess the dependencies you are missing are apex jorje dependencies. They can be found here. They haven't been published to Maven Central yet by the Salesforce team behind it. They probably will once they open source it. If you have any further issues, please let me know. |
Now I got what you are talking about @rtfpessoa. Yes, we are using a custom closed source parser from the Salesforce Eclipse IDE. Salesforce will eventually open source their parser and then its available via Maven repos. Before that they need to be bundled with PMD. |
@jsotuyod thank you. About the PMD description XMLs. Is there any way to read them programmatically from Java/Scala? |
@rtfpessoa All rules descriptions are available in the ruleset file that defines them (the PMD web is actually generated from these by Maven). For instance, java-unusedcode You could load the xml as a resource from the proper PMD jar (pmd-java, pmd-apex, ...), and parse them just like you are currently parsing the results xml. |
@rtfpessoa About the needed dependency for the Apex parser: We do not directly use the linked jar files, but we needed to shade them - there are conflicting versions of asm in the classpath, which would either break apex or other languages. When we package PMD, we use therefore not these dependencies, but the shaded one. You can get the shaded apex-jorje parser jar from here: |
@adangel @jsotuyod I think I still did not got this. Can you be more precise about exactly what jars do I need to have Apex working? I tried multiple combinations but I always end up with problems. One of my deps has Jackson as a dependency. Does PMD or Apex have Jackson as a dependency? I could not find it. |
@rtfpessoa maybe you overlooked this link: https://github.com/pmd/pmd/tree/master/pmd-apex/repo This is a as I understand it local/fake Maven repo to get the 2 needed jars. This page also contains links to the original files in the Salesforce repo. |
@rtfpessoa It depends on the context: If you are building a tool, that only supports apex and not more, then you would be probably fine to use the two apex jars directly. However, since these two jars are "über-jars", which contain all sorts of outdated libraries, you very soon get class loading problems at runtime (NoSuchMethodError, IncompatibleClassChangeError, etc.). That's why I created the shaded jar, which is used, when we package PMD. So, in short: you'll need to use the shaded jar instead of the two original apex jars. About the Jackson problem: I don't see, that PMD has a dependency on it. The apex "über-jar" seems to contain some version of apache-commons-httpclient, javax-SOAP api, SOAP implementation from IBM, javax WSDL api, ... many others.... and com.fasterxml.jackson ... It seems, it is version 2.2.3 (com.fasterxml.jackson.core:jackson-core:2.2.3). If you want use a different version of jackson, you'll probably need to shade this package, too. See here for how I relocated asm. Since the apex jorje jars are self-contained (they bring every dependency, they need), this should work without problems. Once you've verified, that this is the issue, feel free to open a PR/Issue at PMD, so that we can relocate more packages and provide an improved apex shaded jar. For reference, these seem to be the dependencies of the apex jars:
|
Thanks for the help, I think I am closer to the solution. How to I generate the shaded version? Do I need to run the whole PMD build? |
I think I got the shaded jar but now seems like since the version jackson had in apex might have changed the APIs. EDIT: I only shaded the jackson packages. Do I need to shade apache-commons-httpclient, javax-SOAP api, SOAP too?
Any ideas to fix this? |
Make sure, you have excluded the original apex libraries, when you put everything together. Something like this:
|
Since I am creating a jar with Jackson shaded I am just doping the jorje jar in the classpath and I already have this error. |
Actually I might have an idea. I think it might me the databind package not being shaded. Need to check it later. BTW thanks with the classifier syntax I was not finding It |
Thanks a lot for all your help, I already have it running locally. |
Build and tests are passing in https://circleci.com/gh/codacy/codacy-pmdjava/139 |
@rtfpessoa awesome. Let us know if you need anything else! |
@rtfpessoa Btw - I've released yesterday the version 5.5.4. You should now be able to use the shaded jorje jar as a dependency with the classifier from here. |
@rtfpessoa Looks like you are nearly done. Feel free to test the Apex language module using our public Apex repos at https://github.com/up2go. |
@up2go-rsoesemann I will ping you as soon as we put this online. Should not take much more now that the tool side is complete and the backend should also be ready. |
@up2go-rsoesemann we just deployed PMD with Apex. When you add the projects make sure you are either using a configuration file |
@rtfpessoa Why is codacy not getting the rule descriptions right? For all PMD rules it is just linking the PMD pages. On the right side there is CodeClimate. For their engine I output the full description for every single issue. How are you doing it? |
I think I might have forgotten to generate the long descriptions. I will take a look into that when I start working on Visualforce, should not be hard. |
Should be fixed in #31 |
I contributed a PMD language module for the Salesforce.com Apex language and created a PMD wrapper for CodeClimate https://github.com/Up2Go/codeclimate-apexmetrics.
I would love to have Apex support in Codacy and this this could be easily done as you already have a PMD version.
I'd be more than happy to help.
The text was updated successfully, but these errors were encountered: