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
@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
Sudharshan
@Suddukaluvai_twitter
Sure
Juan Martín Sotuyo Dodero
@jsotuyod
for reference, you can check the pmd-swift module, that also uses an Antlr4 Grammar… it was one of the modules used as Proof of Concept for the Antlr4 support
Sudharshan
@Suddukaluvai_twitter
ok
Prakash Tarun Kumar
@prakashkumar264
Hi, I am using CPD tool to find duplicate code in C# projects. I want to exclude all the .Designer.cs files in entire project. is there a way to do that? like --exclude "*.Designer.cs"?
Prakash Tarun Kumar
@prakashkumar264
I have lots of subdirectories and want to ignore Designer files in every one of them. One way is to create a text file with all subdirectories and pass it to --exclude, but i am looking to do this in cmd
Andreas Dangel
@adangel
according to the doc at https://pmd.github.io/latest/pmd_userdocs_cpd.html#cli-options-reference there is no direct way to do this. wildcards are not supported at the command line.
Prakash Tarun Kumar
@prakashkumar264
so is there a way to ignore some pieces of code in cpd?
Andreas Dangel
@adangel
Hi @prakashkumar264 , I've written up the different solutions here: https://github.com/adangel/scratchpad/tree/master/cpd-file-exclusions
CPD itself doesn't support exclusion patterns, but you can create a filelist file with some shell scripting or use ant or use maven to achieve what you want.