Browse Source
* Add clang-format * Auto-format AlphaFilter and RingBuffer * Update to tab=8spaces * Allow for 120 widthmaster
6 changed files with 206 additions and 34 deletions
@ -0,0 +1,117 @@
@@ -0,0 +1,117 @@
|
||||
--- |
||||
Language: Cpp |
||||
# BasedOnStyle: Google |
||||
AccessModifierOffset: -8 # Modified |
||||
AlignAfterOpenBracket: Align |
||||
AlignConsecutiveAssignments: false |
||||
AlignConsecutiveDeclarations: false |
||||
AlignEscapedNewlines: Left |
||||
AlignOperands: true |
||||
AlignTrailingComments: true |
||||
AllowAllParametersOfDeclarationOnNextLine: true |
||||
AllowShortBlocksOnASingleLine: false |
||||
AllowShortCaseLabelsOnASingleLine: false |
||||
AllowShortFunctionsOnASingleLine: All |
||||
AllowShortIfStatementsOnASingleLine: true |
||||
AllowShortLoopsOnASingleLine: true |
||||
AlwaysBreakAfterDefinitionReturnType: None |
||||
AlwaysBreakAfterReturnType: None |
||||
AlwaysBreakBeforeMultilineStrings: true |
||||
AlwaysBreakTemplateDeclarations: true |
||||
BinPackArguments: true |
||||
BinPackParameters: true |
||||
BraceWrapping: |
||||
AfterClass: false |
||||
AfterControlStatement: false |
||||
AfterEnum: false |
||||
AfterFunction: false |
||||
AfterNamespace: false |
||||
AfterObjCDeclaration: false |
||||
AfterStruct: false |
||||
AfterUnion: false |
||||
AfterExternBlock: false |
||||
BeforeCatch: false |
||||
BeforeElse: false |
||||
IndentBraces: false |
||||
SplitEmptyFunction: true |
||||
SplitEmptyRecord: true |
||||
SplitEmptyNamespace: true |
||||
BreakBeforeBinaryOperators: None |
||||
BreakBeforeBraces: Attach |
||||
BreakBeforeInheritanceComma: false |
||||
BreakBeforeTernaryOperators: true |
||||
BreakConstructorInitializersBeforeComma: false |
||||
BreakConstructorInitializers: BeforeColon |
||||
BreakAfterJavaFieldAnnotations: false |
||||
BreakStringLiterals: true |
||||
ColumnLimit: 120 |
||||
CommentPragmas: '^ IWYU pragma:' |
||||
CompactNamespaces: false |
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true |
||||
ConstructorInitializerIndentWidth: 4 |
||||
ContinuationIndentWidth: 4 |
||||
Cpp11BracedListStyle: true |
||||
DerivePointerAlignment: true |
||||
DisableFormat: false |
||||
ExperimentalAutoDetectBinPacking: false |
||||
FixNamespaceComments: true |
||||
ForEachMacros: |
||||
- foreach |
||||
- Q_FOREACH |
||||
- BOOST_FOREACH |
||||
IncludeBlocks: Preserve |
||||
IncludeCategories: |
||||
- Regex: '^<ext/.*\.h>' |
||||
Priority: 2 |
||||
- Regex: '^<.*\.h>' |
||||
Priority: 1 |
||||
- Regex: '^<.*' |
||||
Priority: 2 |
||||
- Regex: '.*' |
||||
Priority: 3 |
||||
IncludeIsMainRegex: '([-_](test|unittest))?$' |
||||
IndentCaseLabels: true |
||||
IndentPPDirectives: None |
||||
IndentWidth: 8 # Modified |
||||
IndentWrappedFunctionNames: false |
||||
JavaScriptQuotes: Leave |
||||
JavaScriptWrapImports: true |
||||
KeepEmptyLinesAtTheStartOfBlocks: false |
||||
MacroBlockBegin: '' |
||||
MacroBlockEnd: '' |
||||
MaxEmptyLinesToKeep: 1 |
||||
NamespaceIndentation: None |
||||
ObjCBlockIndentWidth: 2 |
||||
ObjCSpaceAfterProperty: false |
||||
ObjCSpaceBeforeProtocolList: false |
||||
PenaltyBreakAssignment: 2 |
||||
PenaltyBreakBeforeFirstCallParameter: 1 |
||||
PenaltyBreakComment: 300 |
||||
PenaltyBreakFirstLessLess: 120 |
||||
PenaltyBreakString: 1000 |
||||
PenaltyExcessCharacter: 1000000 |
||||
PenaltyReturnTypeOnItsOwnLine: 200 |
||||
PointerAlignment: Left |
||||
RawStringFormats: |
||||
- Delimiter: pb |
||||
Language: TextProto |
||||
BasedOnStyle: google |
||||
ReflowComments: true |
||||
SortIncludes: true |
||||
SortUsingDeclarations: true |
||||
SpaceAfterCStyleCast: false |
||||
SpaceAfterTemplateKeyword: true |
||||
SpaceBeforeAssignmentOperators: true |
||||
SpaceBeforeParens: ControlStatements |
||||
SpaceInEmptyParentheses: false |
||||
SpacesBeforeTrailingComments: 2 |
||||
SpacesInAngles: false |
||||
SpacesInContainerLiterals: true |
||||
SpacesInCStyleCastParentheses: false |
||||
SpacesInParentheses: false |
||||
SpacesInSquareBrackets: false |
||||
Standard: Auto |
||||
TabWidth: 8 # Modified |
||||
UseTab: Always # Modified |
||||
... |
||||
|
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
name: Format Checks |
||||
|
||||
on: [push, pull_request] |
||||
|
||||
jobs: |
||||
format_checks: |
||||
runs-on: ubuntu-latest |
||||
container: px4io/px4-dev-clang:2019-10-24 |
||||
steps: |
||||
- uses: actions/checkout@v1 |
||||
- name: install clang-format-6.0 |
||||
run: apt install -y clang-format-6.0 |
||||
- name: check_format |
||||
run: ./tools/format.sh 0 |
||||
|
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash |
||||
do_format=$1 |
||||
files_to_format=""" |
||||
EKF/AlphaFilter.hpp |
||||
EKF/RingBuffer.h |
||||
""" |
||||
RED='\033[0;31m' |
||||
GREEN='\033[0;32m' |
||||
YELLOW='\033[1;33m' |
||||
NC='\033[0m' # No Color |
||||
|
||||
if ! hash clang-format-6.0 |
||||
then |
||||
echo -e ${RED}Error: No clang-format-6.0 installed${NC} |
||||
exit 1 |
||||
fi |
||||
|
||||
if [[ $do_format -eq 1 ]] |
||||
then |
||||
# formatting |
||||
clang-format-6.0 -i -style=file ${files_to_format} |
||||
echo -e ${GREEN}Formatting finished${NC} |
||||
else |
||||
# checking format... |
||||
clang-format-6.0 -style=file -output-replacements-xml ${files_to_format} | grep -c "<replacement " > /dev/null |
||||
if [[ $? -eq 0 ]] |
||||
then |
||||
echo -e ${RED}Error: need to format${NC} |
||||
echo -e ${YELLOW}From cmake build directory run: 'make format'${NC} |
||||
exit 1 |
||||
fi |
||||
echo -e ${GREEN}no formatting needed${NC} |
||||
exit 0 |
||||
fi |
Loading…
Reference in new issue