Caution: VS Code guides section is a work-in-progress, containing content contributed by students.
Given below are the steps to set up a Checkstyle plugin in VS Code so that VS Code can alert you about code style problems as you write code.
checkstyle.xml
and suppressions.xml
) should be in the ./config/checkstyle
directory, as mentioned here.Extensions
-> Search Checkstyle for Java
-> Install (the first entry).File -> Open Folder...
../.vscode/settings.json
file exists. If not, create a folder .vscode
in the project root directory and add a file settings.json
within the .vscode
folder. This file contains configuration settings for projects in VS Code.settings.json
file. These settings ensure that the Checkstyle extension uses the correct configuration files in the ./config/checkstyle
directory: {
"java.checkstyle.configuration": "${workspaceFolder}/config/checkstyle/checkstyle.xml",
"java.checkstyle.properties": {
"config_loc": "${workspaceFolder}/config/checkstyle"
}
}
.vscode
to your .gitignore
if you haven't done so by adding these few lines to the end of .gitignore
:# VS Code
/.vscode/
Problems
tab in VS Code. For example, after changing the code to add a wildcard import, you can see that the wildcard import on line 11 has been detected by the Checkstyle extension:Contributors: Brendon Koh (@brein62)