Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Linus Fernandes
@Fernal73
Yes, that's the conclusion I've arrived at as well. There's a parameter includeXMLInSite which processes the generated XML. The real showstopper is the language support missing. I'm guessing the Maven plugin developers focused on supporting the most used languages within pmd.
Using ${basedir}/pom. xml in includes might work as well.
I've had to do something similar for a Checkstyle feature utilising the scripting plugin using groovy. Have you used CodeNarc to statically analyse groovy scripts? I can't seem to find a Maven configuration that works for Java 11.
Linus Fernandes
@Fernal73
The most interesting part of CodeNarc is the format of the ruleset file.
About the maven ordering , a rule for pluginManagement might work.
Linus Fernandes
@Fernal73
I seem to be having a couple of errors with running pmd for XML from the command line. It doesn't like a comma separated list of XML file paths as input. Secondly, if the report file specified is in a directory that doesn't exist yet, pmd falls over. Shouldn't it be creating the directory for me?
Linus Fernandes
@Fernal73
Just the second part is a problem . It's confusing about the file list. It expects a file containing comma separated paths , not a comma separated list of paths on the command line. Why won't the latter work? How long can a command line be? The classpath can get pretty long when you're using that instead of specifying an uber jar.
Linus Fernandes
@Fernal73
@adangel Executing pmd from a groovy script pulls in pmd-core when I specify pmd-xml as the only dependency. However, the pmd maven plugin requires that I explicitly specify pmd-core with pmd-java as dependencies for it to work.
@adangel If I have an uber rules file with all the different language rules I intend to use, I have to specify all the language dependencies even when I specify only one language (say java) in the language parameter. Shouldn't pmd ignore other language rules instead of trying to load the mapped classes?
Andreas Dangel
@adangel

the pmd maven plugin requires that I explicitly specify pmd-core with pmd-java as dependencies for it to work.

That's because m-pmd-p by default supports java, so has in any case the dependency for pmd-java. If you now override the plugin-dependencies, you can only add additional dependencies (like pmd-xml), but never remove (or exclude). Therefore you need to make sure, to use the same pmd version or you need to override all pmd dependencies (that the m-pmd-p already has) with the same version. A mix between different versions of different pmd modules is not supported.

Andreas Dangel
@adangel

If I have an uber rules file with all the different language ... Shouldn't pmd ignore other language rules instead of trying to load the mapped classes?

That's an interesting question, which creates a lot of follow up question. E.g. we didn't really specify yet, how PMD should behave, if multiple languages are enabled at the same time. It might work, but not in all cases (especially if the rule names are the same in different languages...).
If you specify a ruleset, and we can't load all rules, should we then just ignore the problem or should we fail? At the moment, it seems, we fail (although probably not with helpful message). I would argue, if you specify a ruleset, you want to execute all rules in that ruleset, and not just a few... otherwise, why would you specify rules, you don't want to execute anyway?
Not sure, what the right decision here is in terms of "least surprise". There is of course a middle way: Warn the user, that not all rules are available, and run with the rules, that are available...

Linus Fernandes
@Fernal73
@adangel The middle way makes sense. Obviously, if you have rules in a ruleset, you'd want all to be executed. But breaking the build if some aren't available doesn't seem right or proper.
Linus Fernandes
@Fernal73
@adangel on the other hand, if users are just provided a warning, there's no incentive to add the needed dependencies or remove the unused rules altogether. I'm not certain what's the best practice here. I wouldn't consider it a bug if it's expected behaviour.
kenji21
@kenji21

Can't get a ANTLR4 for swift 5.0 string literals with '#" "#' syntax:

let rawString = #"Press "Continue" to close this dialog."#
extension URL {
    func html(withTitle title: String) -> String {
        return #"<a href="\#(absoluteString)">\#(title)</a>"#
    }
}

The Swift.g4 code for basic string literals is:

SingleStringLiteral : '"' QuotedText? '"' ;
fragment SingleDoubleQuote : '"' | ~["] ;
fragment QuotedText : QuotedTextItem+ ;
fragment QuotedTextItem : EscapedCharacter | InterpolatedString
// | '\\(' expression ')'
 | ~["\\\u000A\u000D]
 ;
fragment InterpolatedString: '\\(' (QuotedTextItem | SingleStringLiteral)* ')';

but adding DashedSingleStringLiteral : '#"' QuotedText? '"#' ; doesn't do the job

Clément Fournier
@oowekyala
QuotedText disallows double quotes. You'll need to make another fragment that allows them, and possibly other characters (eg \\\u000A is newline iirc)
kenji21
@kenji21
ok, merci Clément :-), got it: had to specific fragments:
DashedSingleStringLiteral : '#"' DashedMultiQuotedText? '"#' ;
fragment DashedMultiQuotedText : DashedMultiQuotedTextItem+ ;
fragment DashedMultiQuotedTextItem : EscapedCharacter | DashedMultiInterpolatedString
 | ~[\\\u000A\u000D]
 ;
fragment DashedMultiInterpolatedString: '\\#(' (DashedMultiQuotedTextItem | DashedSingleStringLiteral)* ')';
ZilinXiang
@ZilinXiang
Hi there, I wonder how to debug CPD in IDEA ? I followed the introduction and passed some augments in IDEA but it doesn't work...
I specified objectivec but CPD parsed the language is AnyLanguage
ZilinXiang
@ZilinXiang
It seems that ServiceLoader cannot load any Language implementation
ZilinXiang
@ZilinXiang
I resolved the problem. You should add your target language module as module dependency (runtime) for pmd-core.
Fiorella Zampetti
@fzampetti_gitlab
Hi there, we are conducting a survey about why refactoring-related contributions to software projects get rejected.
If you have any related experience, we highly appreciate your input!
Thanks in advance and the survey is available at https://usi.eu.qualtrics.com/jfe/form/SV_cO6Ayah0D6q4eSF
Jerome Marfleet
@jmarfleet_gitlab
Hi Guys. I was wondering if the software could be used to determine if an apex class was implementing another apex class. Say I got all the classes names and bodies via return [SELECT Id, Name, Body FROM ApexClass]. Could I then check the bodies to determine which class implements Schedulable?
Juan Martín Sotuyo Dodero
@jsotuyod
@jmarfleet_gitlab sorry, but I'm a little lost here… you want to analyze classes that are retrieved through Apex code at runtime?
by default PMD analyzes code directly from files… for Apex that is either .cls or .trigger files
programmatically, it would be possible to have PMD analyze code directly from a String
but I'm unsure how that Apex - Java bridge would work (not really familiar with Apex and it's runtime)
Nimit Patel
@nimit-patel
Hi all, first timer here. Trying to open pr but running into this error: git push -u origin issue-2738 fatal: unable to access 'https://github.com/pmd/pmd.git/': The requested URL returned error: 403
Juan Martín Sotuyo Dodero
@jsotuyod
@nimit-patel welcome! you won't be able to push directly into the main PMD repo. You would need to fork it, push your changes to a branch in your fork, and then submit a PR from your fork the main repo
Nimit Patel
@nimit-patel
Thanks, will do that.
Andreas Dangel
@adangel
:+1:
Test User1
@tuser1_gitlab
Just wanted to check if https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-6814 impacts PMD as groovy 2.4.7 is in use.
Juan Martín Sotuyo Dodero
@jsotuyod
@tuser1_gitlab no, PMD makes no use of serialization. Groovy is only in use to parse Groovy files, and may not even be in classpath if unneeded (ie: not analyzing groovy files)
Test User1
@tuser1_gitlab
Thanks @jsotuyod for the confirmation.
Sudharshan
@Suddukaluvai_twitter
Hi I am new to PMD, I want to add lint rules for kotlin
will pmd supports kotlin ? if yes how can i add rules for it?
Juan Martín Sotuyo Dodero
@jsotuyod
PMD already supports Kotlin, but ships no rules at the moment
adding rule support should be very straightforward
and you are off to write rules
PRs are always welcomed
Sudharshan
@Suddukaluvai_twitter
Thanks for the quick response
is there any existing PR's in pipeline for certain rules to avoid duplicate PR's
Juan Martín Sotuyo Dodero
@jsotuyod
AFAIK no one is currently working on rules for Kotlin
Sudharshan
@Suddukaluvai_twitter
ok thanks
Juan Martín Sotuyo Dodero
@jsotuyod
bare in mind, most complete Antlr4 support (Kotlin is an Antlr 4 Gramma) is in PMD 7 branch
I'd suggest you contribute to that branch