-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[kotlin] Kotlin support #3808
[kotlin] Kotlin support #3808
Conversation
…d language" except $. Generate your Parser did not succeed because combining lexer and parser grammars has issues.
…ammar; and move PmdKotlinParser.java to the right place
…lasses.g4 file, added <libDirectory> to maven antlr plugin to make it work
… with unit test cases
…for custom kotlin xpath functions
…sts with pmd/7.0.x branch
…found by pmd-sonar plugin
…T in sonatype snapshots repo
…-SNAPSHOT in sonatype snapshots repo" This reverts commit 051da73.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot Andreas for cleaning this up!
pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/AbstractKotlinRule.java
Outdated
Show resolved
Hide resolved
pmd-kotlin/src/main/antlr4/net/sourceforge/pmd/lang/kotlin/ast/KotlinLexer.g4
Show resolved
Hide resolved
pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/KotlinLanguageModule.java
Outdated
Show resolved
Hide resolved
pmd-kotlin/src/main/resources/rulesets/kotlin/rulesets.properties
Outdated
Show resolved
Hide resolved
- PackageHeader | ||
| - T-PACKAGE | ||
| - Identifier | ||
| | - SimpleIdentifier | ||
| | | - T-Identifier | ||
| | - T-DOT | ||
| | - SimpleIdentifier | ||
| | | - T-Identifier | ||
| | - T-DOT | ||
| | - SimpleIdentifier | ||
| | | - T-Identifier | ||
| | - T-DOT | ||
| | - SimpleIdentifier | ||
| | | - T-Identifier | ||
| | - T-DOT | ||
| | - SimpleIdentifier | ||
| | | - T-Identifier | ||
| | - T-DOT | ||
| | - SimpleIdentifier | ||
| | | - T-Identifier | ||
| | - T-DOT | ||
| | - SimpleIdentifier | ||
| | - T-Identifier | ||
| - Semi | ||
| - T-NL | ||
| - T-NL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how package net.sourceforge.pmd.lang.kotlin.ast.testdata
is currently parsed. That's unfortunately very verbose and that's how the antlr grammar is written. That's why I want to mark this language as experimental, so that we can maybe simplify the AST somehow and don't worry about compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. We use @joinTokenText in rules to address the AST verbosity, however, it is deprecated because of bad performance. Would be nice to have an alternative which keeps working with the improved AST.
pmd-kotlin/src/main/resources/category/kotlin/bestpractices.xml
Outdated
Show resolved
Hide resolved
pmd-kotlin/src/main/resources/category/kotlin/bestpractices.xml
Outdated
Show resolved
Hide resolved
Generated by 🚫 Danger |
@adangel @oowekyala A question, not sure this is the right place. |
I think, you can't avoid updating your custom rules at some point to fully migrate to pmd7. I don't know, how the integration of sonar into the build works. I wonder, whether you really need two separate versions of the sonar-pmd-plugin, maybe two execution instances would work? E.g. the maven-pmd-plugin can also work with pmd7, so the API to call pmd is (at least for now) still compatible between pmd6 and pmd7. That would be "just" a dependency update. But in your case, it's a bit more, because sonar-pmd-plugin knows only java and not kotlin. Ok, I looked at how the sonar-pmd-plugin is installed - it's a single jar file including all the dependencies, so you have no chance to configure the dependencies at runtime as you need (like with maven). So, the easiest way seems to be indeed what you already do: complete separate plugin for pmd7. |
Thanks for your answer. Right, good to know we are on the right track. We should be able to build both versions of the plugin, so not as separate branch. Choice to make is between 1. two separate directory structures and duplication of code and 2. somehow parameterise to manage the differences, with more complexity. |
Hi @adangel @oowekyala, me and @jborgers are working on the sonar-pmd-plugin to get it working with pmd7 with Kotlin added. Currently we need to locally build https://github.com/adangel/pmd/tree/kotlin-poc. Is it possible to merge kotlin-poc in the pmd/7.0.x branch so we can use the pmd 7.0.0-SNAPSHOT release from Sonatype snapshots instead? What needs to be done to get this branch merged and can we help with that? Thanks. |
Hi @adangel and @oowekyala, we run into an issue creating the sonar-pmd plugin with pmd7. When running
The pmd-7.0.0-SNAPSHOT.jar makes use of slf4j 2.0.0-alpha6 as seen by
This is not compatible with Sonar, that provides slf4j to its plugins. We can exclude We could solve this by making a local build of Another way to solve this, it seems, is to configure the sonar-packaging-maven-plugin to use From the sonar plugin instructions: Under: Third-party Libraries We wanted to bring this to your attention: using slf4j 2.0.0 might not work everywhere when pmd is used as jar. Also, what would you recommend in this case? |
@stokpop I've created #4023 for downgrading slf4j. I don't think there is a different way - there can only be one logging framework active. |
Describe the PR
Follow-up on #3505
Related issues
Related work
Ready?
npx all-contributors
)