Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 13 04:28
    Belle-PL edited #3694
  • Aug 12 19:17
    aaronhurst-google edited #4092
  • Aug 12 19:17
    aaronhurst-google edited #4092
  • Aug 12 19:17
    aaronhurst-google opened #4092
  • Aug 12 08:25
    Belle-PL commented #4062
  • Aug 12 05:48
    Zustin labeled #4091
  • Aug 12 05:48
    Zustin opened #4091
  • Aug 11 17:10
    oowekyala converted_to_draft #4066
  • Aug 11 14:26
    oowekyala commented #2435
  • Aug 11 13:42
    oowekyala assigned #4081
  • Aug 11 12:54
    pmd-test commented #4081
  • Aug 11 12:38
    Zustin commented #3402
  • Aug 11 11:06
    eklimo synchronize #4081
  • Aug 11 10:49
    eklimo synchronize #4081
  • Aug 10 22:34
    jsotuyod edited #4059
  • Aug 10 22:33
    jsotuyod synchronize #4059
  • Aug 10 21:31
    oowekyala edited #4081
  • Aug 10 18:26
    hgschmie labeled #4090
  • Aug 10 18:26
    hgschmie opened #4090
  • Aug 10 15:44

    github-actions[bot] on gh-pages

    Update documentation https://g… (compare)

Andreas Dangel
@adangel
Hi @MartGit - we use rhino and whatever this supports should be supported by PMD as well. The error message "no Node adapter class registered" indicates, that this is already supported by rhino, but PMD is not able to use it. Could you please create a new issue with a proper code sample on https://github.com/pmd/pmd/issues ? Thanks!
MartGit
@MartGit
@adangel thanks for the response. Will create the issue asap!
MartGit
@MartGit
Hi @adangel I created the issues pmd/pmd#3703 for this. Any ideas on how to track the version of the fix?
wakingrufus
@wakingrufus:matrix.org
[m]
i know this is a long shot, but is anyone aware of an issue present in pmd 6.19.0 where subsequent runs on the same source would duplicate violations in the xml output?
Alfusainey Jallow
@Alfusainey
Hi, is there a way to tell CPD to find cross clones? E.g I have a directory call snippets and another directory call repos. I want CPD to find clones of the snippets directory inside of the repos directory and not report clones found within the snippets directory or the repos directory. Is this possible?
the command i use is: run.sh cpd --minimum-tokens 100 --files snippets --files repos --language py --format xml > cpd_results.xml
this is reporting clones found within the snippets directory and the reposdirectory. Instead, I want CPD to report only those clones found between snippets and repos
Andreas Dangel
@adangel
not sure. Maybe you can filter the report afterwards?
Alfusainey Jallow
@Alfusainey
ok, thanks. yeah, that's my plan if CPD doesn't have support for this
Alfusainey Jallow
@Alfusainey
i have another question: For Python and Javascript, does CPD detect only exact clones i.e cases where the code fragments are 100% similar?
from my testing so far, it looks like it reports only exact clones
Jim Krueger
@jakrueger
Wondering if someone can help me with what I think is a potential bug. I am using PMD to analyze our Ecmascript. One problem I notice is in our report we get the following error message:
Error while processing myfile.js
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCodeWithoutCache(SourceCodeProcessor.java:127)
...
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:831)
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Invalid operator: 164
at net.sourceforge.pmd.lang.ecmascript.ast.EcmascriptTreeBuilder.createNodeAdapter(EcmascriptTreeBuilder.java:172)
First, the line number 164 is not correct, this file only has 127 lines (but I think I've heard in the past that this can be due to the compiler for some reason, not sure but not my main concern).
My concern is that the javascript looks like this:
$('body').on('shipping', function (e, basket) {
toggleForm(basket.shipping.selectedShippingMethod.formEnabled);
Jim Krueger
@jakrueger
This javascript is valid (i.e. in our software is works fine and I think according to ECMA standards it should be fine) However, for some reason the function part of this is getting caught as an "invalid operator". Wondering if anyone has seen something like this before? If this is a bug where is the best place for me to file it?
nimaje
@nimaje
where does it say anything about a line number of the processed file? I only see 'Invalid operator: 164', reads to me like pmd sees 164 somewhere where it expects an operator or pmd tries to use 164 as an operator for some other reason, can you try to create a small reproducer? maybe via something like binary search
Jim Krueger
@jakrueger
I don't have the number "164" anywhere in the code, I guess I was assuming it was a line number. So what I posted above is actually the reduced reproducer, if I remove the function you see there it works fine, there is something about that function that is not getting properly processed.
nimaje
@nimaje
those two lines? there is a closing ) and a cloasing } missing, is that ok in ecmascript?
Jim Krueger
@jakrueger
Sorry, I missed the ending " });"
nimaje
@nimaje
yeah, that could be a bug, the bugs link on the website leads to https://github.com/pmd/pmd/issues
Jim Krueger
@jakrueger
@nimaje Thank you!
jzochowskiSEI
@jzochowskiSEI
Hello everyone. Is there any plans for PMD to move to apache commons-io 2.7 or above? I would like to leverage this tool for my Azure DevOps pipeline but there are known vulnerabilities on the current static version 2.6
Devam Parikh
@Devamparikh
Hey there, I want to contribute here. I have read some issues and discussions, you guys are planning to migrate Junit4 to Junit5. I want to help in migrating Junit4 to Junit5. Can someone please create some good-first-issue so that I can work on it? Thanks :)
nimaje
@nimaje
why not opening an issue about migrating to junit5 yourself and saying that you want to work on it?
Devam Parikh
@Devamparikh
I have commented on simmiler type of issue for that.
I am kind of beginner so I want to work on some good first issues which would be better for me if I start small and if you guys can guide along.
Andreas Dangel
@adangel
@jzochowskiSEI Thanks for asking. commons-io 2.7 requires at least java8, so we can only upgrade it for pmd7. Are you referring to https://github.com/advisories/GHSA-gwrp-pvrq-jmwv ?
Andreas Dangel
@adangel
@Devamparikh Thanks for the offer. Since you mention, you want a good first issue, I'd suggest to start with a bug fix. This allows you to configure your dev environment and see a bit of code of PMD. Good first issues are always fixing false positives or negatives, such as pmd/pmd#3874 , so I'd start with that
Devam Parikh
@Devamparikh
Of course I would like to do that too, can I have a little help from you @adangel? I want to be part of GSoC2202 and work on the Eclipse JKube project "Migrate to JUnit5 Testing Framework from JUnit4", so it would be helpful to give me a chance to get ahead in Migrate To JUnit5. Can we do that?
Devam Parikh
@Devamparikh
A small portion of Migrate to JUnit5 will do if you like.
Andreas Dangel
@adangel
You can give it a try, but I won't have much time to support you...
Devam Parikh
@Devamparikh
Can you assign me any testcase class remains to be convected in any file? I have debugging skills, I'm able to debug.
Devam Parikh
@Devamparikh
Hey @adangel would you assign me any good first issue related to this?
Maikel Steneker
@maikelsteneker
Hi all, apologies in advance if I could have found this out on my own. I'm upgrading my project of Java rules to use the latest PMD version, and I'm getting lots of deprecation warnings, primarily on the addViolation method from AbstractRule. currently, I'm extending the AbstractJavaRule base class and overriding the visit method. this gets an Object data parameter that I pass into addViolation. perhaps I need to override another method to accomplish the same thing? any pointers would be appreciated
Maikel Steneker
@maikelsteneker
ah, I think I figured it out. I simply had to replace addViolation(data, ...) by asCtx(data).addViolation(...). not sure how I missed this initially :)
Andreas Dangel
@adangel
yes, in PMD 7, the violations will be collected via the RuleContext - in PMD6 you still need to cast the data parameter to RuleContext (which asCtx does).
Ayush
@Ayush-D
Hey Team, I wanted to match all the method names having similar parameters in my java code, how can I write the Xpath rule for this?
Ayush
@Ayush-D
Like how to check for parameters if that are also similar I got till here.. But this is also giving the MyClass not the method name
//ClassBody[count(//VariableDeclarator[../Type/Name[@Image='MyClass']])>1]
VasanthiMalagondla
@VasanthiMalagondla
Hi Team, getting the below error while running PMD 6.18.0 jar Unknown Language 'xml' for ruleObjectNamingConventionsUpperCamelCase, supported Languages are apex, ecmascript, java
Andreas Dangel
@adangel
@VasanthiMalagondla which distribution/plugin of PMD are you using? In the standard distribution, all languages (including xml) are contained. You seem to use some special version...
Are you using https://github.com/ChuckJonas/vscode-apex-pmd ? Then try to update the extension - 6.18.0 is pretty old...
Andreas Dangel
@adangel

@Ayush-D That's a bit tricky, not sure if this is possible with XPath. It's certainly easier to write a Java-based rule.

So, this is, how you can find all methods, for which at least one other method exists with the same parameter count:

for $x in //MethodDeclaration
  return if (count(//MethodDeclaration[@Arity = $x/@Arity]) > 1)
   then $x
   else ()
Md Mahir Asef Kabir
@mahirkabir

Hello. I am trying to build the pmd project in Windows computer by following https://github.com/pmd/pmd/blob/master/BUILDING.md.
But I am getting the following error: "[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project pmd-core: There are test failures."

Can anybody help me on what to do?

mihaidogaru2537
@mihaidogaru2537
Hello! Does anyone know if the report output can be configured to display the metric value somehow distinctly? I am trying to use the PMD API to create some statistics using the metrics measured by PMD. When outputting in JSON format, for example I get this: "The class Factory has a total cyclomatic complexity of 13 (highest 12)." I am interested in getting that 13 number in a separate json key. Also, there are some rules which do not output their metric's value: "Avoid really long classes.". I would like to know how long is that class. Thank you!
Andreas Dangel
@adangel
Hi @mihaidogaru2537 , that's not possible out of the box. Regarding metrics - we created for unit testing those metrics simple rules, that that report the metric value in the violation message and then we verify the message (which contains the number). See https://github.com/pmd/pmd/blob/master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/metrics/impl/AllMetricsTest.java for an example.
Regarding some rules you mentioned - you'd need to change the rule, so that they output whatever value they measured.
While calculating and reporting metrics is an interesting feature, it is not currently part of PMD.
Ulli Hafner
@uhafner:matrix.org
[m]

One of my students implemented a small tool around those metric classes and integrated it into a Jenkins plugin: https://github.com/jenkinsci/metrics-aggregation-plugin

Maybe you can use this code as a starting point.

Sandip
@sandip1805
Hello all, I am new in this space, and want to contribute in code. I am a Java developer. Can anyone suggest what I can pick up and provide contribution?
Andreas Dangel
@adangel
Hello and welcome @sandip1805 ! I guess the easiest way would be to follow this guide here: https://github.com/pmd/pmd/wiki/Newcomers%27-Guide