-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add clang-format; travis CI; LICENCE
- Loading branch information
Showing
3 changed files
with
779 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,51 @@ | ||
BasedOnStyle: Google | ||
AccessModifierOffset: -1 | ||
AlignEscapedNewlinesLeft: true | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortFunctionsOnASingleLine: true | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
#AlwaysBreakBeforeMultilineStrings: true | ||
AlwaysBreakTemplateDeclarations: true | ||
BinPackParameters: true | ||
BreakBeforeBinaryOperators: false | ||
BreakBeforeBraces: Linux | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: false | ||
ColumnLimit: 0 | ||
CommentPragmas: '^ IWYU pragma:' | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
ConstructorInitializerIndentWidth: 2 | ||
ContinuationIndentWidth: 2 | ||
Cpp11BracedListStyle: false | ||
DerivePointerBinding: false | ||
ExperimentalAutoDetectBinPacking: false | ||
IndentCaseLabels: true | ||
IndentFunctionDeclarationAfterType: true | ||
IndentWidth: 2 | ||
# It is broken on windows. Breaks all #include "header.h" | ||
Language: Cpp | ||
MaxEmptyLinesToKeep: 1 | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
NamespaceIndentation: None | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: false | ||
PenaltyBreakBeforeFirstCallParameter: 1 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 200 | ||
SortIncludes: false | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: false | ||
SpacesInContainerLiterals: true | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
Standard: Cpp11 | ||
TabWidth: 2 | ||
UseTab: Never |
This file contains 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,54 @@ | ||
sudo: false | ||
matrix: | ||
fast_finish: true | ||
# Note: Workaround travis-ci/travis-ci#4681 | ||
# Exclude default job which lacks our included environment variables. | ||
exclude: | ||
- os: linux | ||
- env: | ||
include: | ||
- os: linux | ||
env: TOOL=clang-format | ||
addons: | ||
apt: | ||
sources: *sources | ||
packages: ['clang-format-3.9'] | ||
compiler: clang | ||
script: | | ||
if [[ $TOOL == "clang-format" ]]; then | ||
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then | ||
BASE_COMMIT=$(git rev-parse $TRAVIS_BRANCH) | ||
echo "Running clang-format-3.9 against branch $TRAVIS_BRANCH, with hash $BASE_COMMIT" | ||
COMMIT_FILES=$(git diff --name-only $BASE_COMMIT | grep -ivE 'LinkDef|Utilities/PCG/') | ||
RESULT_OUTPUT="$(git-clang-format-3.9 --commit $BASE_COMMIT --diff --binary `which clang-format-3.9` $COMMIT_FILES)" | ||
for x in $COMMIT_FILES; do | ||
case $x in | ||
*.h|*.cxx) | ||
# We remove the header from the diff as it contains +++ then | ||
# we only select the added lines to check for the long ones. | ||
# We do not need to check for the lines which have been removed | ||
# and we do not want to check for the lines which were not changed | ||
# to avoid extra work. | ||
# 120 characters are allowed, meaning the error should start with 122, | ||
# to allow for the starting + at the end of the line. | ||
git diff $x | tail -n +5 | grep -e '^+' | grep '.\{122,\}' && { echo "Line longer than 120 chars in $x." && exit 1; } || true ;; | ||
*.hxx|*.cc|*.hpp) echo "$x uses non-allowed extension." && exit 1 ;; | ||
*) ;; | ||
esac | ||
done | ||
if [ "$RESULT_OUTPUT" == "no modified files to format" ] \ | ||
|| [ "$RESULT_OUTPUT" == "clang-format did not modify any files" ] ; then | ||
echo "clang-format passed." | ||
exit 0 | ||
else | ||
echo "clang-format failed." | ||
echo "To reproduce it locally please run" | ||
echo -e "\tgit checkout $TRAVIS_BRANCH" | ||
echo -e "\tgit-clang-format --commit $BASE_COMMIT --diff --binary $(which clang-format)" | ||
echo "$RESULT_OUTPUT" | ||
exit 1 | ||
fi | ||
fi | ||
fi |
Oops, something went wrong.