PMD Code Inspection Trouble with Homebrew

Issue #1809 resolved
Aidan Harding created an issue

I’m not sure if this counts as a bug, so feel free to close if you think that the homebrew maintainers ought to fix it instead.

The issue is that if you install pmd on mac via Homebrew, the command to run it is “pmd” not “run.sh”. If I set the PMD Executable parameter in IC to use this, it executes:

/usr/local/Cellar/pmd/6.25.0/bin/pmd -dir /my/code/ -language apex -R /my/rules.xml -f xml -no-cache

However, this is missing the extra “pmd” command that you would send to run.sh. It needs to execute /usr/local/Cellar/pmd/6.25.0/bin/pmd pmd -dir /my/code/...

I’m not sure if there’s a heuristic in IC that adds the extra “pmd” command when it’s running run.sh?

I’ve worked around it by creating a shell script called pmdpmd:

#!/bin/zsh

/usr/local/bin/pmd pmd "$@"

Then, I point IC to that. But, it’s not ideal.

Comments (7)

  1. Scott Wells repo owner

    Hmmmmm...so I can certainly see what's happening. Basically right now when IC2 runs PMD, if it executes via run.sh it adds a first pmd argument; otherwise it omits that argument. Perhaps it should only omit that argument if executed via pmd.bat, i.e., under Windows? Or perhaps I could/should be more explicit and only include that argument if run via run.sh or pmd (no extension)? Or the most foolproof way to do it would be to allow the user to specify any additional args and default the pmd arg when the selected script is either run.sh or pmd. I'd prefer to avoid that if possible, though, as it just adds complexity. If one of the two rules listed above would take care of it, that would certainly be better.

    Anyway, I'm thinking aloud here. Let me investigate a bit and see what I can figure out.

  2. Scott Wells repo owner

    You know what...instead of what is a potentially risky change here, I'm going to hold off on this. You have a reasonable workaround in your pmdpmd script, and I've actually been investigating running PMD Apex in-process to make it more efficient--and potentially even allow it to be run as a real-time inspection. That would solve this problem in a better way. I'll see what traction I get on that front before doing anything here.

  3. Aidan Harding reporter

    Oooh, I like the idea of an in-process pmd. I’d much rather have that than a bodge for this.

    At the very least, if someone asks you for support with pmd and they’ve installed it via homebrew, you’ll know where to look.

  4. Scott Wells repo owner

    I actually made really solid progress on a real-time/in-process PMD Apex integration today:

    Issue_1809.png

    There are still quite a few things to work out before it'll be ready for prime-time, but hopefully I can get it into good shape for either this week's build or, if not that, next week's.

  5. Log in to comment