Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize code style & formatting throughout repository #2809

Closed
11 tasks done
stephen-crawford opened this issue May 30, 2023 · 3 comments
Closed
11 tasks done

Standardize code style & formatting throughout repository #2809

stephen-crawford opened this issue May 30, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable.

Comments

@stephen-crawford
Copy link
Contributor

stephen-crawford commented May 30, 2023

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

@stephen-crawford stephen-crawford added enhancement New feature or request untriaged Require the attention of the repository maintainers and may need to be prioritized labels May 30, 2023
@davidlago davidlago added triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable. and removed untriaged Require the attention of the repository maintainers and may need to be prioritized labels May 31, 2023
@peternied peternied added the untriaged Require the attention of the repository maintainers and may need to be prioritized label Jun 19, 2023
@peternied
Copy link
Member

@scrawfor99 Can we backport all the style changes into the 1.x and 2.x branches. If our backports won't apply cleanly from main onto on those branches.

(Added untriaged so we cover this during the triage meeting)

@stephen-crawford
Copy link
Contributor Author

Yeah, will do.

@stephen-crawford
Copy link
Contributor Author

[Triage] @scrawfor99 to backport the new settings.

@stephen-crawford stephen-crawford removed the untriaged Require the attention of the repository maintainers and may need to be prioritized label Jun 19, 2023
@stephen-crawford stephen-crawford self-assigned this Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable.
Projects
None yet
Development

No branches or pull requests

3 participants