Commit 6412d981 authored by Jens Petit's avatar Jens Petit
Browse files

Adding clang-format (#9):

  * clang-format file
  * CI integration of clang-format
parent b29a17c5
---
BasedOnStyle: LLVM
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: 'false'
AlignConsecutiveDeclarations: 'false'
AlignEscapedNewlines: Left
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'true'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'false'
AlwaysBreakTemplateDeclarations: 'Yes'
BinPackArguments: 'true'
BinPackParameters: 'true'
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Linux
BreakBeforeTernaryOperators: 'true'
BreakConstructorInitializers: BeforeColon
ColumnLimit: '100'
CompactNamespaces: 'true'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
Cpp11BracedListStyle: 'true'
DerivePointerAlignment: 'false'
DisableFormat: 'false'
ExperimentalAutoDetectBinPacking: 'false'
FixNamespaceComments: 'true'
IncludeBlocks: Preserve
IndentCaseLabels: 'true'
IndentWidth: '4'
IndentWrappedFunctionNames: 'true'
JavaScriptQuotes: Leave
KeepEmptyLinesAtTheStartOfBlocks: 'true'
Language: Cpp
NamespaceIndentation: All
PointerAlignment: Left
ReflowComments: 'true'
SortIncludes: 'false'
SortUsingDeclarations: 'false'
SpaceAfterCStyleCast: 'true'
SpaceAfterTemplateKeyword: 'true'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCpp11BracedList: 'false'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'true'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: Cpp11
TabWidth: '4'
UseTab: Never
AccessModifierOffset: '-4'
...
stages:
- static-test
- compile
- test
- coverage
......@@ -41,6 +42,17 @@ stages:
reports:
junit: "build/test_reports/test_*.xml"
### static test ###
clang-format:
stage: static-test
image: elsa/clang:8
script:
./tools/ci_scripts/clang-format-test.sh
tags:
- linux
- elsa
- clang
### compile jobs ###
......@@ -55,8 +67,7 @@ build-ubuntu:
tags:
- linux
- elsa
build-gcc9:
<<: *build_job_artifact
image: elsa/gcc:9
......@@ -109,7 +120,7 @@ test-ubuntu:
tags:
- linux
- elsa
test-gcc9:
<<: *test_job_artifact
stage: test
......
#!/bin/bash
# Applies clang-format
# check that we are in a clean state in order to prevent accidential changes
if [ ! -z "$(git status --untracked-files=no --porcelain)" ]; then
echo "Script must be applied on a clean git state"
exit 1
fi
echo
echo "Checking formatting using the following clang-format version:"
clang-format --version
echo
# perform clang-format on all cpp-files
find elsa/ -name '*.h' -or -name '*.hpp' -or -name '*.cpp' | xargs clang-format -i -style=file $1
# check if something was modified
notcorrectlist=`git status --porcelain | grep '^ M' | cut -c4-`
# if nothing changed ok
if [[ -z $notcorrectlist ]]; then
# send a negative message to gitlab
echo "Excellent. Very good formatting!"
exit 0;
else
echo "The following files have clang-format problems:"
git diff --stat $notcorrectlist
echo "Please run"
echo
echo "find elsa/ -name '*.h' -or -name '*.hpp' -or -name '*.cpp' | xargs clang-format -i -style=file $1"
echo
echo "to solve the issue."
# cleanup changes in git
git reset HEAD --hard
fi
exit 1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment