jdneo / vscode-checkstyle

Checkstyle extension for VS Code
https://marketplace.visualstudio.com/items?itemName=shengchen.vscode-checkstyle
GNU Lesser General Public License v3.0
68 stars 16 forks source link

CheckStyle doesnt work with Mypy extension or on lower versions #331

Open pitris90 opened 2 years ago

pitris90 commented 2 years ago

Checkstyle messages me this: {"message":"LineLength is not allowed as a child in Checker"}.... It worked with this xml on my main computer and i think even on this one...

the important part of XML file looks like this: image

Language support extension for Java by RedHat writes this: [Error - 1:08:15] 9. 3. 2022 1:08:15 Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ls.core". null java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at com.shengchen.checkstyle.runner.DelegateCommandHandler.executeCommand(DelegateCommandHandler.java:58) at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:215) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:205) at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:507) at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75) at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source) at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source) at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: LineLength is not allowed as a child in Checker at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:493) at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:198) at com.shengchen.checkstyle.checker.CheckerService.setConfiguration(CheckerService.java:67) at com.shengchen.checkstyle.runner.DelegateCommandHandler.setConfiguration(DelegateCommandHandler.java:79) ... 17 more

[Error - 1:08:15] 9. 3. 2022 1:08:15 Error in calling delegate command handler null java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at com.shengchen.checkstyle.runner.DelegateCommandHandler.executeCommand(DelegateCommandHandler.java:58) at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:215) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:205) at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:507) at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75) at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source) at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source) at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: LineLength is not allowed as a child in Checker at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:493) at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:198) at com.shengchen.checkstyle.checker.CheckerService.setConfiguration(CheckerService.java:67) at com.shengchen.checkstyle.runner.DelegateCommandHandler.setConfiguration(DelegateCommandHandler.java:79) ... 17 more

And when I switch Checkstyle version on 10 (where it was originally), it writes this: {"message":"com/puppycrawl/tools/checkstyle/api/AuditListener","cause":{"message":"com.puppycrawl.tools.checkstyle.api.AuditListener"}}

And this in Java Support extension:

Caused by: java.lang.NoClassDefFoundError: com/puppycrawl/tools/checkstyle/api/AuditListener at java.base/java.lang.Class.getDeclaredConstructors0(Native Method) at java.base/java.lang.Class.privateGetDeclaredConstructors(Unknown Source) at java.base/java.lang.Class.getConstructor0(Unknown Source) at java.base/java.lang.Class.getConstructor(Unknown Source) at com.shengchen.checkstyle.runner.CheckstyleLoader.loadCheckerService(CheckstyleLoader.java:49) at com.shengchen.checkstyle.runner.DelegateCommandHandler.setConfiguration(DelegateCommandHandler.java:75) ... 17 more Caused by: java.lang.ClassNotFoundException: com.puppycrawl.tools.checkstyle.api.AuditListener at java.base/java.net.URLClassLoader.findClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) ... 23 more

[Error - 1:21:00] 9. 3. 2022 1:21:00 Error in calling delegate command handler null java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at com.shengchen.checkstyle.runner.DelegateCommandHandler.executeCommand(DelegateCommandHandler.java:58) at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:215) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:205) at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:507) at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75) at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source) at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source) at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) Caused by: java.lang.NoClassDefFoundError: com/puppycrawl/tools/checkstyle/api/AuditListener at java.base/java.lang.Class.getDeclaredConstructors0(Native Method) at java.base/java.lang.Class.privateGetDeclaredConstructors(Unknown Source) at java.base/java.lang.Class.getConstructor0(Unknown Source) at java.base/java.lang.Class.getConstructor(Unknown Source) at com.shengchen.checkstyle.runner.CheckstyleLoader.loadCheckerService(CheckstyleLoader.java:49) at com.shengchen.checkstyle.runner.DelegateCommandHandler.setConfiguration(DelegateCommandHandler.java:75) ... 17 more Caused by: java.lang.ClassNotFoundException: com.puppycrawl.tools.checkstyle.api.AuditListener at java.base/java.net.URLClassLoader.findClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) ... 23 more

pitris90 commented 2 years ago

EDIT: I found a problem... I remembered that I recently installed also Mypy extension for handling Mypy for Python. And as you can see there is some weird conflict. I solved it by turning off Mypy extension for my Java workspace

jdneo commented 2 years ago

sounds wired, I'm trying to understand why a Python extension could affect Java ones. 🤔

jdneo commented 2 years ago

And one more thing: checkstyle rules differs from different checkstyle version. You need to make sure the version and your rules are compatibale

pitris90 commented 2 years ago

There is an option called: Mypy: Run Using Active Interpreter Use the active Python interpreter (selected in the Python extension) to run dmypy itself, instead of the mypy.dmypyExecutable setting. Note: your code is always checked against the active interpreter – this setting only controls the interpreter used to run dmypy itself.

I had it set to True, because on False it didnt work on my Python files and this option when it is set to True seems to be a problem

pitris90 commented 2 years ago

And one more thing: checkstyle rules differs from different checkstyle version. You need to make sure the version and your rules are compatibale

I simply have to use latest version - 10 - otherwise plugin has some problems too

jdneo commented 2 years ago

I had it set to True, because on False it didnt work on my Python files and this option when it is set to True seems to be a problem

But you are using Checkstyle to check your Java code right? I cannot understand my the Python's setting would affect that.

pitris90 commented 2 years ago

I had it set to True, because on False it didnt work on my Python files and this option when it is set to True seems to be a problem

But you are using Checkstyle to check your Java code right? I cannot understand my the Python's setting would affect that.

Of course :D But that Python extension was enabled too and with that setting it caused this weird conflict. I don't understand it either... You can take a look on it, its Mypy extension -> image

And try to turn that mentioned setting to on

pitris90 commented 2 years ago

But there is still this message when i set checkstyle version on 8.43 for example (In IntelliJ it works with this version too): {"message":"com/puppycrawl/tools/checkstyle/api/AuditListener","cause":{"message":"com.puppycrawl.tools.checkstyle.api.AuditListener"}}

jdneo commented 2 years ago

Would you mind to share a sample project?

pitris90 commented 2 years ago

Would you mind to share a sample project?

For fixing that message i mentioned above? Because this speccifically is my school project which, I am afraid, I can't share 😄

pitris90 commented 2 years ago

Would you mind to share a sample project?

^ |