If you have custom rules for the intellij ktlint p...
# ktlint
If you have custom rules for the intellij ktlint plugin, and they don't seem to run after you put the jar files in the ktlint ide plugin config form, is there any way to debug why? There are no errors in the AS IDE log either 🤔 Side note: would be nice if the jar list field were larger because the jar paths can be fairly long if you have multiple jars.
blob thinking fast I can definitely look into improving the jar UI 😄 though I’m not aware of any current issues with custom ruleset jars
One issue might be that we need multiple JAR files loaded...found this class conflict:
Copy code
Caused by: java.lang.LinkageError: loader constraint violation: when resolving method 'boolean org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt.isAbstract(org.jetbrains.kotlin.psi.KtClass)' the class loader java.net.URLClassLoader @375c179b of the current class, com/twitter/ktlint/rules/SerializableContentViewArgsCheck, and the class loader com.intellij.ide.plugins.cl.PluginClassLoader @7da6c7b3 for the method's defining class, org/jetbrains/kotlin/psi/psiUtil/KtPsiUtilKt, have different Class objects for the type org/jetbrains/kotlin/psi/KtClass used in the signature (com.twitter.ktlint.rules.SerializableContentViewArgsCheck is in unnamed module of loader java.net.URLClassLoader @375c179b, parent loader com.intellij.ide.plugins.cl.PluginClassLoader @138301aa; org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @7da6c7b3, parent loader 'bootstrap')
	at com.twitter.ktlint.rules.SerializableContentViewArgsCheck.visitClassNode(SerializableContentViewArgsCheck.kt:23)
	at com.twitter.ktlint.rules.TwitterKtRule.visit(TwitterKtRule.kt:25)
Probably time for me to take a step back and look for simple example ruleset jar that definitely works w/ the IntelliJ plugin and try adding our rules into it bit by bit...
The ktlint project contains a template for a custom ruleset.
Have you tried to run your custom ruleset with the ktlint CLI? This might give a better understanding whether the problem is in the ruleset or the plugin.
ktlint CLI works fine...we use the ruleset with it (we're just trying to get the custom rules working w/ the ktlint intellij plugin) It looks like it's conflicting w/ some class that the IDE is also supplying from that stack trace snippet. thx for the template pointer 🙂
ah yeah, the IDE loves to conflict 😞 I ran into that with the plugin itself too
😞 1
I'm guessing we're going to have to shade some classes/jars we use in our custom rules....
yeah give that a shot, that’s what I had to do to get the plugin working as well 😬
👍 1