style: Introduce clang-format configurations for automated enforcement#948
Open
wmthornton-dev wants to merge 1 commit into
Open
style: Introduce clang-format configurations for automated enforcement#948wmthornton-dev wants to merge 1 commit into
wmthornton-dev wants to merge 1 commit into
Conversation
924fb26 to
648895e
Compare
This commit introduces a formatting pipeline to enforce consistent
coding standards across the rsync codebase using clang-format.
The root `_clang-format` file is configured to enforce the Linux Kernel
(K&R) coding style, specifically adapted for rsync's historical baseline
and to account for developer habits:
- 8-character hardware tabs for all indentation
- 80-column line length limit
- K&R brace placement (same line for control statements, new line
for function definitions)
- Function names and return types sharing the same line
Additionally, local `_clang-format` overrides have been added to the
`popt/` and `zlib/` vendored library directories. These files inherit
the root Linux structural rules but override the indentation to 4 spaces
to respect their specific upstream formatting requirements.
Usage:
To automatically apply the formatting rules and modify the files in-place,
run the following command from the root directory:
find . -name "*.c" -o -name "*.h" | xargs clang-format -i
To automatically apply the formatting rules and modify a single file
in-place, run the following command from the root directory:
clang-format -i <path/to/file>
To validate code compliance without modifying the files (for use
in pre-commit hooks or CI pipelines), run the dry-run command:
find . -name "*.c" -o -name "*.h" | xargs clang-format --dry-run --Werror
To validate code compliance for a single file, without modification, run
the dry-run command:
clang-format --dry-run --Werror <path/to/file>
This commit is designed to work in conjunction with .editorconfig files
but can be used standalone.
Additionally, a proposed STYLEGUIDE.md file is included in the root
directory for publishing where appropriate.
Signed-off by: Wayne Michael Thornton <wmthornton-dev@outlook.com>
648895e to
60cae20
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit introduces a formatting pipeline to enforce consistent coding standards across the rsync codebase using clang-format.
The root
_clang-formatfile is configured to enforce the Linux Kernel (K&R) coding style, specifically adapted for rsync's historical baseline and to account for developer habits:Additionally, local
_clang-formatoverrides have been added to thepopt/andzlib/vendored library directories. These files inherit the root Linux structural rules but override the indentation to 4 spaces to respect their specific upstream formatting requirements.Usage:
To automatically apply the formatting rules and modify the files in-place, run the following command from the root directory:
To automatically apply the formatting rules and modify a single file in-place, run the following command from the root directory:
To validate code compliance without modifying the files (for use in pre-commit hooks or CI pipelines), run the dry-run command:
To validate code compliance for a single file, without modification, run the dry-run command:
clang-format --dry-run --Werror <path/to/file>This commit is designed to work in conjunction with .editorconfig files but can be used standalone.
Signed-off by: Wayne Michael Thornton wmthornton-dev@outlook.com