Skip to content

Standardize code style & formatting throughout repository #2809

@stephen-crawford

Description

@stephen-crawford

This issue is intended to act as a tracking issue for an effort to standardize code style and formatting across the Security repository.

As things stand, there is a mix of styles being used in different parts of the repository. This can lead to confusion on the reader's behalf and also makes PRs challenging to review. If a reviewer does not check the "hide whitespace" option when reviewing, code changes can show as almost entirely made of indentation adjustments based on the settings of the contributor's IDE.

In order to correct this trend and provide further support to contributors, we should create a standardized stye policy which outlines the expected formatting of changes and provides a basic settings file users can copy to their IDE configurations.

Because standardizing the format of the code is such as large task this issue will be used to track incremental changes made to the PR all implementing the preferred style. Only after merging the first incremental PR will subsequent PRs be created since any changes to the style should be made to all code not just a given subsection.

The proposed guidelines planned to be introduced are:

  1. Use the same spotlessApply policy as JobScheduler and other repositories as requested by @cwperks
  2. Don't use mid-line linebreaks in markdown files as requested by @peternied
  3. Indentations should use 1 tab (of size 4 spaces) in Java files
  4. Indentations should be 2 spaces in YAML files
  5. There should be a preceding space before all 'if', 'for', 'while', 'switch', 'try', 'catch', and 'synchronized'
    parentheses
  6. There should be a preceding space before all non-unary operators
  7. Imports should use single class names (no wildcards)
  8. JavaDocs should use fully qualified class names
  9. Java.* imports should be placed at the top, followed by Javax.*, then all other imports, and finally static imports

Style Categories:

  • Java Style
  • YAML Style
  • Markdown Style

Style PRs:

This is the branch with all the changes: https://github.com/scrawfor99/security/tree/formattingGuidelines

Metadata

Metadata

Labels

enhancementNew feature or requesttriagedIssues labeled as 'Triaged' have been reviewed and are deemed actionable.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions