Skip to content

Commit d31022e

Browse files
committed
Add clang-format checks in Danger
1 parent 5003530 commit d31022e

File tree

8 files changed

+95
-3
lines changed

8 files changed

+95
-3
lines changed

.clang-format

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
AccessModifierOffset: -2
2+
AlignAfterOpenBracket: true
3+
AlignEscapedNewlinesLeft: false
4+
AlignOperands: true
5+
AlignTrailingComments: true
6+
AllowAllParametersOfDeclarationOnNextLine: false
7+
AllowShortBlocksOnASingleLine: false
8+
AllowShortCaseLabelsOnASingleLine: false
9+
AllowShortFunctionsOnASingleLine: All
10+
AllowShortIfStatementsOnASingleLine: false
11+
AllowShortLoopsOnASingleLine: false
12+
AlwaysBreakAfterDefinitionReturnType: false
13+
AlwaysBreakBeforeMultilineStrings: false
14+
AlwaysBreakTemplateDeclarations: false
15+
BinPackArguments: false
16+
BinPackParameters: false
17+
BreakBeforeBinaryOperators: None
18+
BreakBeforeBraces: Attach
19+
BreakBeforeTernaryOperators: true
20+
BreakConstructorInitializersBeforeComma: false
21+
ColumnLimit: 85
22+
CommentPragmas: '^ IWYU pragma:'
23+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
24+
ConstructorInitializerIndentWidth: 4
25+
ContinuationIndentWidth: 4
26+
Cpp11BracedListStyle: true
27+
DerivePointerAlignment: false
28+
DisableFormat: false
29+
ExperimentalAutoDetectBinPacking: false
30+
IndentCaseLabels: true
31+
IndentWidth: 2
32+
IndentWrappedFunctionNames: false
33+
KeepEmptyLinesAtTheStartOfBlocks: true
34+
Language: Cpp
35+
MaxEmptyLinesToKeep: 1
36+
NamespaceIndentation: None
37+
ObjCBlockIndentWidth: 2
38+
ObjCSpaceAfterProperty: true
39+
ObjCSpaceBeforeProtocolList: false
40+
PenaltyBreakBeforeFirstCallParameter: 19
41+
PenaltyBreakComment: 300
42+
PenaltyBreakFirstLessLess: 120
43+
PenaltyBreakString: 1000
44+
PenaltyExcessCharacter: 1000000
45+
PenaltyReturnTypeOnItsOwnLine: 200
46+
PointerAlignment: Middle
47+
SpaceAfterCStyleCast: false
48+
SpaceBeforeAssignmentOperators: true
49+
SpaceBeforeParens: ControlStatements
50+
SpaceInEmptyParentheses: false
51+
SpacesBeforeTrailingComments: 1
52+
SpacesInAngles: false
53+
SpacesInCStyleCastParentheses: false
54+
SpacesInContainerLiterals: true
55+
SpacesInParentheses: false
56+
SpacesInSquareBrackets: false
57+
Standard: Cpp11
58+
TabWidth: 8
59+
UseTab: Never

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ dist: trusty
44
compiler: clang
55
os: linux
66
ruby: 2.2.0
7+
addons:
8+
apt:
9+
packages:
10+
- clang-format-3.5
711
before_script:
812
- cmake --version
913
- bundle install

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
22

33
project(hello_world CXX)
44

5-
add_executable(hello_world hello_world.cpp)
5+
add_executable(hello_world hello_world.cpp vector.cpp)
66

77
enable_testing()
88

Dangerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ if git.commits.any? { |c| c.message =~ /^Merge branch '#{github.branch_for_base}
1818
fail('Please rebase to get rid of the merge commits in this PR')
1919
end
2020

21+
code_style_validation.check
22+
2123
commit_lint.check
2224

2325
lgtm.check_lgtm

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ gem "danger"
55
gem "danger-commit_lint"
66
gem "danger-lgtm"
77
gem "danger-the_coding_love"
8+
gem 'danger-code_style_validation', :git => 'https://github.com/robertodr/danger-code_style_validation.git'

Gemfile.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
GIT
2+
remote: https://github.com/robertodr/danger-code_style_validation.git
3+
revision: 30f4c419369c53b2975f4b768e459a12e41811db
4+
specs:
5+
danger-code_style_validation (0.0.1)
6+
danger-plugin-api (~> 1.0)
7+
18
GEM
29
remote: https://rubygems.org/
310
specs:
@@ -58,6 +65,7 @@ PLATFORMS
5865

5966
DEPENDENCIES
6067
danger
68+
danger-code_style_validation!
6169
danger-commit_lint
6270
danger-lgtm
6371
danger-the_coding_love

hello_world.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#include <cstdlib>
22
#include <iostream>
3+
#include <vector>
4+
5+
std::vector<int> myVector();
36

47
std::string message() {
5-
return "Hello, Danger world!";
8+
return "Hello, Danger world!";
69
}
710

811
int main() {
912
std::cout << message() << std::endl;
10-
return EXIT_SUCCESS;
13+
14+
std::vector< int > v = myVector();
15+
return EXIT_SUCCESS;
1116
}

vector.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <vector>
2+
3+
std::vector<int> myVector() {
4+
int arr[] = {16, 2, 77, 29};
5+
// Create a vector containing integers
6+
std::vector<int> v (arr, arr + sizeof(arr) /sizeof(arr[0]) );
7+
8+
// Add two more integers to vector
9+
v.push_back(25);
10+
v.push_back(13);
11+
12+
return v;
13+
}

0 commit comments

Comments
 (0)