Skip to content

Commit

Permalink
Adding check script and clang-format file
Browse files Browse the repository at this point in the history
  • Loading branch information
Tancrède Lepoint committed Oct 16, 2016
1 parent f6d1f06 commit 6f570e2
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
65 changes: 65 additions & 0 deletions .clang-format
@@ -0,0 +1,65 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: true
AlignConsecutiveAssignments: true
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakTemplateDeclarations: false
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BinPackParameters: true
BinPackArguments: true
ColumnLimit: 100
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
DerivePointerAlignment: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: false
IndentWrappedFunctionNames: false
IndentFunctionDeclarationAfterType: false
MaxEmptyLinesToKeep: 1
KeepEmptyLinesAtTheStartOfBlocks: true
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakString: 1000
PenaltyBreakFirstLessLess: 120
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
SpacesBeforeTrailingComments: 2
Standard: Cpp11
IndentWidth: 2
TabWidth: 8
UseTab: Never
BreakBeforeBraces: Allman
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
CommentPragmas: '^ IWYU pragma:'
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
SpaceBeforeParens: ControlStatements
DisableFormat: false
...

21 changes: 21 additions & 0 deletions .travis-check-style.sh
@@ -0,0 +1,21 @@
#!/bin/bash

# Add LLVM toolchain
sudo add-apt-repository 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main'
wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -

# Install clang-format
sudo apt-get update -qq
sudo apt-get install -qq -y clang-format-3.9

# If clang-format modifies files, the code does not adhere to the project standards
if [[ $(clang-format-3.9 -i --style=file fplll/*.{cpp,h} fplll/*/*.{cpp,h} tests/*.cpp && git status -s) ]];
then
tput setaf 1;
echo "Code does not adhere to the project standards. Run \"make clang-format -i --style=file fplll/*.{cpp,h} fplll/*/*.{cpp,h} tests/*.cpp\".";
exit 1;
else
tput setaf 2;
echo "Code adheres to the project standards.";
exit 0;
fi;
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -144,7 +144,7 @@ AllowShortFunctionsOnASingleLine: All
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakTemplateDeclarations: false
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BinPackParameters: true
Expand Down

0 comments on commit 6f570e2

Please sign in to comment.