superhornets / 2023-Robot

Other
0 stars 0 forks source link

Setup Spotless #1

Open JonathanLindsey opened 1 year ago

JonathanLindsey commented 1 year ago

This will help to keep our code formatted consistently.

  1. Follow the 'Spotless' section here (not the 'wpiformat' section which is for C++ teams).
  2. So we don't have to manually run ./gradlew spotlessApply all the time, install the 'Spotless Gradle' extension in VS Code (not the 'spotless' extension which is simply a color scheme) - all programmers on the team will need this extension.
  3. So that GitHub codespaces gets setup with the Spotless Gradle extension, add the extension to the list of extensions in the .devcontainer/devcontainer.json file with it's identifier found on the right side of the extensions page: richardwillis.vscode-spotless-gradle
  4. Add the following to the .vscode/settings.json file.

This is from the Details section of the 'Spotless Gradle' extension under the typical usage section.

{
  "java.format.enabled": false,
  "[java]": {
    "files.trimTrailingWhitespace": false,
    "spotlessGradle.diagnostics.enable": true,
    "spotlessGradle.format.enable": true,
    "editor.defaultFormatter": "richardwillis.vscode-spotless-gradle",
    "editor.codeActionsOnSave": {
      "source.fixAll.spotlessGradle": true
    }
  },
  "[gradle]": {
    "files.trimTrailingWhitespace": false,
    "spotlessGradle.diagnostics.enable": true,
    "spotlessGradle.format.enable": true,
    "editor.defaultFormatter": "richardwillis.vscode-spotless-gradle",
    "editor.codeActionsOnSave": {
      "source.fixAll.spotlessGradle": true
    }
  }
}

Note that the first and last curly braces are already in that file as well as other settings. And you need to add a comma (,) immediately after the last pre-existing setting.