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 not working with visual studio 1.43.0 on Mac #274

Open getaceres opened 4 years ago

getaceres commented 4 years ago

I'm using the following environment:

Visual Studio Code 1.43.0 on MacOS Catalina Java Support 0.58.0 Checkstyle Plugin 1.3.0

When I execute the command "Set the checkstyle configuration file" I get a notification saying "Successfully set the Checkstyle configuration." but nothing changes in the editor and in the output of the plug in I see the following message:

"Checkstyle configuration file not set yet, skip the check."

No matter what file I select. I tried with the built in /google_checks.xml and /sun_checks.xml and also with https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml but the result is the same. This message and the checkstyle rules are not applied. I don't see any checkstyle error in any file editor and if I select the command "Check code with checkstyle" nothing happens.

rafaelrenanpacheco commented 4 years ago

Same here. I'm using:

Visual Studio Code 1.43.2 on Arch Linux Java Support 0.58.0 Checkstyle Plugin 1.3.2

After I set the checkstyle configuration file, it created a new .vscode folder with a settings.json file. Shouldn't it use the user settings file, located on the ~./.config/Code/User folder?

rafaelrenanpacheco commented 4 years ago

Found the problem, the extension was using the wrong checkstyle version. After I set it to 8.30 it started working:

image

I also removed the .vscode folder and set the ${workspaceFolder}/checkstyle.xml on the user's setting file.

getaceres commented 4 years ago

I just tested in Arch Linux as well and setting it to 8.30 with the embedded google_checks.xml file doesn't do anything. ¿What local checkstyle.xml file are you using?

rafaelrenanpacheco commented 4 years ago

I'm using a custom checkstyle. Make sure that mvn checkstyle:check is working as well. Also make sure that you are using the same checkstyle version as defined in your pom.xml file.

jdneo commented 4 years ago

@getaceres Could you share a sample project to us?

getaceres commented 4 years ago

Sure, for example this simple project:

https://github.com/getaceres/webflux-simple-demo

executing mvn clean install will find several checkstyle violations while VSCode finds none.

rslarson commented 3 years ago

On Mac, I observed you have to use the full path to point to the XML as ${workspaceFolder} does not seem to actually resolve to anything.

lambainsaan commented 3 years ago

Found the problem, the extension was using the wrong checkstyle version. After I set it to 8.30 it started working:

image

I also removed the .vscode folder and set the ${workspaceFolder}/checkstyle.xml on the user's setting file.

+1, This worked for me!

Keetz commented 3 years ago

Ubuntu 20.04.2 LTS VSCode 1.57.0 Checkstyle 1.4.0

I am having this exact problem. No matter which checkstyle file I try to set, it just gives the: Checkstyle configuration file not set yet, skip the check.

Although, if I try to set it in the user or workspace settings I get the following error:

Error: Running the contributed command: 'java.execute.workspaceCommand' failed. at _executeContributedCommand (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:84:108254) at async Object.sendPendingDiagnostics (/home/<MY_USER>/.vscode/extensions/shengchen.vscode-checkstyle-1.4.0/dist/extension.js:1:87630)

UPDATE I spent some more time trying different settings and I found one that worked. I am not sure what works and what doesn't, but the following worked for me:

  1. Remove all checkstyle settings from user settings, workspace settings and project settings (.vscode folder in project)
  2. Only add the settings to the workspace settings. I am using "java.checkstyle.version": "8.41", and "java.checkstyle.configuration": "/home/<MY_USER>/.vscode/checkstyle.xml",

If I try to use a version beyong 8.41 I get the following error:

Error: Running the contributed command: 'java.execute.workspaceCommand' failed.
    at _executeContributedCommand (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:84:108251)
    at async Object.sendPendingDiagnostics (/home/<MY_USER>/.vscode/extensions/shengchen.vscode-checkstyle-1.4.0/dist/extension.js:1:87630)

I don't know if this is because of some changes to the actual checkstyle format in 8.42 and beyond or if it is this plugin.