-
Notifications
You must be signed in to change notification settings - Fork 596
Add a .clang-format file implementing the Icinga 2 style guide #10520
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
Draft
jschmidt-icinga
wants to merge
2
commits into
master
Choose a base branch
from
add-clang-format
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
# As per the style-guide we base our settings on the LLVM style. This is closer | ||
# than any of the other options, but there are more conventions that differ from | ||
# it than the style-guide suggests. | ||
BasedOnStyle: LLVM | ||
|
||
# Default LLVM puts access modifiers (public: etc.) at an offset of -2, meaning | ||
# in the middle between the indentation level of the class and the class members. | ||
# A setting of -4 puts them at the same level as class definitions. | ||
AccessModifierOffset: -4 | ||
|
||
# We don't want to align function parameters or arguments with the open bracket | ||
# but instead always just add a level of indentation. | ||
AlignAfterOpenBracket: BlockIndent | ||
|
||
# Mostly relevant for formatting preprocessor macros so that all backslashes align. | ||
AlignEscapedNewlines: LeftWithLastLine | ||
|
||
# We try to avoid having all parameters of a function declaration on a single line | ||
# Together with 'BinPackParameters' and 'PenaltyReturnTypeOnItsOwnLine' this leads | ||
# to function signatures being either all on one line, or split by argument like a | ||
# list. | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
|
||
# Put simple getters/setters in class bodies on a single line. | ||
AllowShortFunctionsOnASingleLine: InlineOnly | ||
|
||
# If necessary to break function calls, preferably put each argument on its own line. | ||
BinPackArguments: false | ||
|
||
# If necessary to break function signatures, preferably put each parameter on its own line. | ||
BinPackParameters: false | ||
|
||
# This Breaking style fits our convention and style-guide very closely, therefore | ||
# it is chosen here instead of individual 'BraceWrapping' settings. | ||
BreakBeforeBraces: Mozilla | ||
|
||
# Template declarations are always on their own line | ||
BreakTemplateDeclarations: Yes | ||
|
||
# Convention | ||
ColumnLimit: 120 | ||
|
||
# Includes are sorted according to the style guide, with the additional requirement | ||
# from Boost.Test that the header including the test framework must go first. | ||
IncludeCategories: | ||
- Regex: ^(<|=)BoostTestTargetConfig.h | ||
Priority: 1 | ||
CaseSensitive: false | ||
- Regex: ^"(base|icinga|remote|test)/ | ||
Priority: 2 | ||
CaseSensitive: false | ||
- Regex: ^<boost/ | ||
Priority: 3 | ||
CaseSensitive: false | ||
- Regex: ^< | ||
Priority: 4 | ||
CaseSensitive: false | ||
|
||
# Convention | ||
IndentCaseLabels: true | ||
IndentWidth: 4 | ||
|
||
# Adds braces to if/else/while blocks if they don't have one yet. | ||
# This is required by the current version of the style-guide. | ||
InsertBraces: true | ||
|
||
# We really want to avoid breaking assignments if we can avoid it. | ||
# This, together with 'BinPackArguments' leads to clang-format rather breaking at | ||
# constructor calls with each argument on its own line, like we want. | ||
PenaltyBreakAssignment: 200 | ||
|
||
# We allow log message shift operators to start on the next line. | ||
PenaltyBreakFirstLessLess: 0 | ||
|
||
# This is needed together with 'PenaltyBreakFirstLessLess' for our preferred formatting | ||
# of log messages. | ||
PenaltyIndentedWhitespace: 1 | ||
|
||
# We absolutely never want the return type on its own line. | ||
# Together with 'AllowAllParametersOfDeclarationOnNextLine' and 'BinPackParameters' | ||
# This makes it so that function signatures are always either on one line or split | ||
# line by line per argument. | ||
PenaltyReturnTypeOnItsOwnLine: 1200 | ||
|
||
# Convention | ||
PointerAlignment: Left | ||
ReferenceAlignment: Left | ||
SpaceAfterTemplateKeyword: false | ||
TabWidth: 4 | ||
UseTab: Always | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ on: | |
push: | ||
branches: | ||
- master | ||
pull_request: {} | ||
release: | ||
types: | ||
- published | ||
|
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.