Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 1.88 KB

CODE-FORMATTING.md

File metadata and controls

26 lines (19 loc) · 1.88 KB

Code Formatting

Spotless

Spotless is a tool that automatically formats code to follow a certain convention. It allows multiple developers to write code but still maintain some uniformity in bracketing, indentation, whitespace, etc of the code.

This implementation of spotless mainly enforces the Google Java Style, replaced tab indentation with spaces, and trims any trailing whitespace in files.

Summary of changes:

  1. build.gradle
    1. Install the spotless plug-in
    2. Configure the spotless settings for the various file types (java, gradle, xml, etc)
    3. Disable automatics spotless execution during a build
      • By default, spotless is configured to run during a build. This is generally undesirable because we don't want formatting errors to cause build failures and hinder developent, debugging, and testing. We generally want to run and apply the spotless changes prior to committing and/or pushing the code to a source code repository (e.g. git)

Apply Spotless Code Formatting

Once spotless is configured, you can run and apply the spotless changes by running spotlessApply via Gradle.

From vscode, you can run spotless as follows:

  1. Open the vscode command palette: Ctrl-Shift-P
  2. Type/Select: WPILib: Run a command in Gradle
  3. Type: spotlessApply

Summary of changes:

  1. Code reformatted by spotless

To keep the code base as uniform as possible, all subsequent changes should be processed by spotless prior to pushing it to the shared repository.