Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 11:39
    rsoesemann commented #3184
  • 07:58
    ajeans edited #3350
  • 07:57
    ajeans opened #3350
  • 07:57
    ajeans labeled #3350
  • Jun 21 20:54
    gurmsc5 labeled #3349
  • Jun 21 20:54
    gurmsc5 opened #3349
  • Jun 21 18:21
    kanwarpreet25 commented #3300
  • Jun 21 12:54
    pmd-test commented #3348
  • Jun 21 12:39
    oowekyala opened #3348
  • Jun 21 12:39
    oowekyala milestoned #3348
  • Jun 21 12:28
    oowekyala milestoned #3305
  • Jun 21 12:28
    oowekyala assigned #3305
  • Jun 21 11:39
    pmd-test commented #3311
  • Jun 21 10:15
    pbilstein commented #3305
  • Jun 21 08:58
    breizh31 commented #3340
  • Jun 21 08:58
    breizh31 commented #3340
  • Jun 21 08:58
    breizh31 commented #3340
  • Jun 21 08:58
    breizh31 commented #3340
  • Jun 21 08:57
    breizh31 commented #3340
  • Jun 21 08:55
    breizh31 commented #3340
Alexandre Locci Martins
@aloccim_twitter
Hi. I am PhD. student and I am interesting to use PMD code for some experiments. So, I would like to know who is the person responsable by the PMD tests.
Juan Martín Sotuyo Dodero
@jsotuyod
@aloccim_twitter welcomed! I'm not sure what you mean by "responsible", but all code in the project is managed by the PMD maintainers team… what would you need from us?
Alexandre Locci Martins
@aloccim_twitter
@jsotuyod Hi Juan. Thank you for your attention. I intend to perform some experiments involved rigorous code coverage criteria like MCDC. So I want to use the PMD code for that, but I need to know how you, the developers, implement the tests, more specifically, the regression test. Therefore, I would like to know what kind of tools and switch test are used as well as the kind of bug you have found.
Juan Martín Sotuyo Dodero
@jsotuyod
sure! There are 2 kinds of tests. Unit tests (found under src/test/* for each Maven module), and an integration regression test. The unit tests may cover the internals (classic unit tests checking behavior of components) or the rule's performance, by feeding it code snippets to analyze and enforce we avoid false positives / negatives.
the integration regression uses a custom tool (found at https://github.com/pmd/pmd-regression-tester ) which runs the snapshot PMD build against a set of real-life projects (currently a given version of Checkstyle and Spring Framework), and compares the analysis output vs a baseline from the latest stable build. When differences arise, we manually check those (the diff report is pretty consice), and are therefore able to find issues our tests may have missed, and try to add unit tests for those
Juan Martín Sotuyo Dodero
@jsotuyod
ie: here we fixed a FP, and the integration report sees 3 violations removed, and the detailed report shows which violations were so we can assess all these were actually false positives
Alexandre Locci Martins
@aloccim_twitter
@jsotuyod OK perfect. I will download the tool to perform the regression test, I intend to replicate the same conditions that you perform the test. I assume that unit tests are performed according to the maven standard, right? By the way, what is the IDE adopted by project? Thank you, I believe I have enough information to start my work.
Juan Martín Sotuyo Dodero
@jsotuyod
we do not favor one IDE in particular, part of our team uses Eclipse, others use IntelliJ, the wiki shows how to setup either: https://github.com/pmd/pmd/wiki/Setup-IDE
Artem
@KroArtem
Hello there! I know there is a PMD in the press page on PMD site. Just wanted to say that PMD was slightly presented in this very small and superficial talk: https://youtu.be/L42zH5ne074 (approx. since 5:24)
Andreas Dangel
@adangel
@KroArtem Thanks for sharing! I've added it to our page: pmd/pmd@41076fa
Artem
@KroArtem

Hello there! As usual, I'm updating pmd from old version (6.28) to a new one (6.33) and fixing new deprecations. I've already created pmd/pmd#3196 since ThreadSafeReportListener seem to be obsolete now. Also there is one more question about PMDParameters and PMDCommandLineInterface. Previously they were used like this:

PMDParameters params = PMDCommandLineInterface.extractParameters(new PMDParameters(), new String[]{
                "-language", "java",
                .....
                "-debug",
        }, "pmd");
final PMDConfiguration configuration = params.toConfiguration();

but now both these classes are deprecated. Should we just use PMDConfiguration now and set all the required settings? It seems to be working but two issues seem to be unclear:
1) How to set language versions without using LanguageVersion ctor that would require internal JavaLanguageHandler?
2) PMDParameters had getSourceDir method but I don't see any non-internal alternative

Artem
@KroArtem

ok, seems like

Language javaLanguage = LanguageRegistry.getLanguage("Java");
LanguageVersion lv = new LanguageVersion(javaLanguage, "11", javaLanguage.getDefaultVersion().getLanguageVersionHandler());

could do the trick

Clément Fournier
@oowekyala
Hi, the intended usage is that you do javaLanguage.getVersion("11")
Maybe we should also deprecate the language version constructor to make this clearer. It's only meant to be used when initializing the language instance.
For your other question about the parameters, I think we deprecated those to promote using PMDConfiguration. We could probably add a new method that takes an array of string arguments and produces a PMDConfiguration, while hiding those internal classes
Artem
@KroArtem
@oowekyala , I'm ok with current approach if it works (and it seems to be working :D)
javaLanguage.getVersion("11") works like a charm
Rabart kurrey
@kurrey007_twitter
why unusedcode.xml is depracted? I need to find unused or dead code from my code base using PMD kindly help.
Andreas Dangel
@adangel
Hi @kurrey007_twitter , with PMD 6, we reorganized the rules into categories and deprecated the old rulesets. The rules though are not deprecated.
You can still use the rules like UnusedFormalParameter by referencing it in your own custom ruleset. See Making rulesets for more information.
Rabart kurrey
@kurrey007_twitter
@adangel Hi Andreas, I am trying to use it for Apex classes, and I also tried to include the rules mentioned into my ruleset but it did not return my any response, my output file is emtpy.
Screenshot 2021-05-04 at 11.42.48 AM.png
do you see anything wrong with this ruleset?
Juan Martín Sotuyo Dodero
@jsotuyod
@kurrey007_twitter if this is an apex ruleset, you should reference the apex rules rather than the java ones… category/apex/bestpractices.xml/UnusedLocalVariable. If I recall correctly, that one is the only unused code rule for Apex at the moment…
Rabart kurrey
@kurrey007_twitter
@jsotuyod yes you are right, its for apex and currently there is only "unused variable" rule present in PMD, I have tried its working. Is there a way I can use java library inside custom apex rule to find deadcode?
Juan Martín Sotuyo Dodero
@jsotuyod
@kurrey007_twitter I fear not. For the time being, all rules are specific to a given language, as it operates on the particular language's Abstract Syntax Tree… in the future we may have some support for UAST and some generic rules, but not in the foreseeable future.
Rabart kurrey
@kurrey007_twitter
@jsotuyod i would be working to create rules for PMD to find the unused method very soon. I might need your help.
Juan Martín Sotuyo Dodero
@jsotuyod
@kurrey007_twitter awesome!
Alberto Puritano
@AlbertoPuritano
Hi, is PMD more effective with Gradle or Maven compared to the command line?
Clément Fournier
@oowekyala
I think it's easier to configure, because for instance the maven and gradle plugins make dependencies of your project available to PMD automatically. But in principle, you could with some effort achieve the same thing with the CLI, so it's not more effective. Another thing is that integrating PMD in your build tool makes it easier to make sure your sources always comply to your rules. For instance you can make your CI build fail if there are violations.
Alberto Puritano
@AlbertoPuritano
thanks
pan64
@pan64
Hi all! I have an ancient pmd 5.3.3 (from 2015) with pmd-ttcn plugin. Do you know how can I upgrade it? Thanks
nimaje
@nimaje
what problems did you face when trying to upgrade?
pan64
@pan64
I can't find that plugin
Andreas Dangel
@adangel
Is this an extension, that can analyze https://en.wikipedia.org/wiki/TTCN ?
If you don't have the source code of this extension, that you can't upgrade. You could try to use the latest pmd 5.x, but I guess, pmd 6 won't work anymore
pan64
@pan64
yes, that is for ttcn3. Thanks, probably I will try that.
vertao
@vertaodagalera_twitter
image.png
Hello everyone!!
I have a problem with pmd when i try to build my app in Xcode, i get the error whose says i'm not have pmd installed in my machine.
i already install with brew and manually, but still not work
anyone have a idea to resolve this?
Juan Martín Sotuyo Dodero
@jsotuyod
we don't have any official integration with XCode… are you using a third party plugin of any sort?
vertao
@vertaodagalera_twitter
not that I know
it's weird because in my machine i have this error, but in a Mac Mini with old version of iOS, the build passed with no problems
Juan Martín Sotuyo Dodero
@jsotuyod
well, the first step would be figuring out how you integrated PMD into XCode… my best guess is through a custom build script, but that's just a guess
given your error, I would guess you or someone in your team did somthing equivalent to this but for PMD https://jeehut.medium.com/how-to-configure-build-scripts-in-xcode-b41301579c80
in which case this may be an issue with the $PATH used by XCode not including wherever brew installed PMD
vertao
@vertaodagalera_twitter
it's a good sugestion, thanks Juan
the integration is with a custom build script as you said, with this I can search the error more precisely
probably is the issue with the $PATH as you said too
thanks again
Juan Martín Sotuyo Dodero
@jsotuyod
no problem!
vertao
@vertaodagalera_twitter
In case someone also has the problem that Xcode cannot find pmd, there are two solutions:
1- BEST SOLUTION: run the command sudo ln -s /opt/homebrew/bin/pmd /usr/local/bin, which makes a symbolic link between the pmd installation folder to the bin location of the machine.
2- Add PATH=${PATH}:/opt/homebrew/bin at the beginning of the custom script that uses pmd, but anyone who does not have pmd installed through homebrew will not be able to build.