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

Apply clang-format for unified coding-style #1427

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a6fe516
Initial framework for formatting & indentation check.
hjtappe May 3, 2023
3f52a1d
a few steps to configure indent
hjtappe May 4, 2023
8c172ad
Add current version of indent.pro
hjtappe May 12, 2023
f4f87d2
Mograte from indent to clang-format for more options and better fit.
hjtappe May 12, 2023
53dbb89
Apply unified formatting rules.
hjtappe May 12, 2023
30721ab
Final version of CPP check.
hjtappe May 12, 2023
4ed9234
Update JS files to a common coding style
hjtappe May 12, 2023
23bcb9c
Update JS files to a common coding style
hjtappe May 12, 2023
fda038a
Remove in-place format update
hjtappe May 12, 2023
e6057ed
Fix some sice cases.
hjtappe May 13, 2023
96c89ec
Merge branch 'master' of https://github.com/mcallegari/qlcplus into i…
hjtappe May 13, 2023
96fbc88
Fix clang-format configuration handling for build system
hjtappe May 13, 2023
a3d5de2
Use fixed clang-format-14
hjtappe May 14, 2023
39782b6
Use available action to add apt repository
hjtappe May 14, 2023
bdcbb7b
Fix yaml syntax
hjtappe May 14, 2023
7f8689a
Trigger another build
hjtappe May 14, 2023
9cbb42d
Use the specific version 14 repo
hjtappe May 14, 2023
100c307
also exclude moc_*.h
hjtappe May 14, 2023
1553c81
Exclude qlcconfig.h
hjtappe May 14, 2023
3a184a3
Merge branch 'master' of https://github.com/mcallegari/qlcplus into i…
hjtappe May 14, 2023
13a7ce1
Omit qrc_* files in check
hjtappe May 14, 2023
def584d
Fix another merge conflict
hjtappe May 14, 2023
556a0ed
Omit generated ui_*.h files.
hjtappe May 14, 2023
20940c9
Move pointer alignment from left to right.
hjtappe Jun 2, 2023
4b93230
Merge branch 'master' of https://github.com/mcallegari/qlcplus into i…
hjtappe Jun 2, 2023
b165ce6
Indent the merged files from master.
hjtappe Jun 2, 2023
d530da2
Update switch-case indentation as per review comment.
hjtappe Jul 3, 2023
2bff5c1
Align consecutive declarations etc. as per review comment
hjtappe Jul 3, 2023
9d5bf35
Keep comment lines as formatted.
hjtappe Jul 3, 2023
2f8abff
Merge branch 'master' of https://github.com/mcallegari/qlcplus into i…
hjtappe Jul 3, 2023
019be65
Apply style to merged files.
hjtappe Jul 3, 2023
63e8112
Merge branch 'master' of https://github.com/mcallegari/qlcplus into i…
hjtappe Jul 4, 2023
411d829
Reduce the column limit to 100.
hjtappe Jul 4, 2023
0255a05
Fix a multiline comment in #if
hjtappe Jul 4, 2023
5844f6b
Merge branch 'master' of https://github.com/mcallegari/qlcplus into i…
hjtappe Jan 28, 2024
244250d
Merge branch 'indent' of https://github.com/hjtappe/qlcplus into indent
hjtappe Jan 28, 2024
94666d3
Add indentation script and prepare integration.
hjtappe Feb 1, 2024
1a5c9a8
Update help message by a bit.
hjtappe Feb 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
251 changes: 251 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
# This is the clang-format configuration style to be used by QLCplus,
# based on the rules from https://wiki.qt.io/Qt_Coding_Style and
# https://wiki.qt.io/Coding_Conventions

---
Language: Cpp
AccessModifierOffset: -4

# Horizontally align arguments after an open bracket.
# The coding style does not specify the following, but this is what gives
# results closest to the existing code.
AlignAfterOpenBracket: Align
AlignArrayOfStructures: Right
AlignConsecutiveMacros: AcrossComments
AlignConsecutiveAssignments: AcrossComments
AlignConsecutiveBitFields: AcrossComments
AlignConsecutiveDeclarations: AcrossComments

# When escaping newlines in a macro attach the '\' as far left as possible, e.g.
##define a \
# something; \
# other; \
# thelastlineislong;
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false

AlwaysBreakTemplateDeclarations: MultiLine

AttributeMacros:
- __capability
- __attribute
BinPackArguments: true
BinPackParameters: true

# Braces are usually on a new line
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Never
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true

# We want to break before the operators, but not before a '='.
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Allman
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true

# Break constructor initializers before the colon and after the commas.
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
# Column width is limited to 120 characters as used in the QLCplus code
# https://wiki.qt.io/Qt_Coding_Style defines a limit of 100.
ColumnLimit: 100

# Disable reflow of some specific comments
# qdoc comments: indentation rules are different.
# Translation comments and SPDX license identifiers are also excluded.
CommentPragmas: "^!|^:|^ SPDX-License-Identifier:|^ IWYU pragma:"
QualifierAlignment: Leave
CompactNamespaces: false

# Indent initializers by 4 spaces
ConstructorInitializerIndentWidth: 4
# Indent width for line continuations.
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
PackConstructorInitializers: BinPack
BasedOnStyle: ''

# Put constructor initializers each on a new line.
ConstructorInitializerAllOnOneLineOrOnePerLine: false
AllowAllConstructorInitializersOnNextLine: true

# Add "// namespace <namespace>" comments on closing brace for a namespace
# Ignored for namespaces that qualify as a short namespace,
# see 'ShortNamespaceLines'
FixNamespaceComments: true

# macros for which the opening brace stays attached.
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
- forever
- Q_FOREVER
- QBENCHMARK
- QBENCHMARK_ONCE
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseLabels: true
IndentCaseBlocks: false
IndentGotoLabels: false
IndentPPDirectives: BeforeHash
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
# No indentation for namespaces.
NamespaceIndentation: None

ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 4
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0

# We want a space between the type and the star for pointer types.
PointerAlignment: Right
PPIndentWidth: 2
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1

# The QT coding style specifies some include order categories, but also tells to
# separate categories with an empty line. It does not specify the order within
# the categories. Since the SortInclude feature of clang-format does not
# re-order includes separated by empty lines, the feature is not used.
SortIncludes: Never
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false

# We use template< without space.
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false

# Avoids the addition of a space between an identifier and the
# initializer list in list-initialization.
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
BeforeNonEmptyParentheses: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both

Standard: Latest

StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...

Loading