Skip to content

Add clang-format checks in Danger #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 85
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '$'
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Middle
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
TabWidth: 8
UseTab: Never
38 changes: 33 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
language: cpp
sudo: false
dist: trusty
compiler: clang
os: linux
ruby: 2.2.0
cache: bundler
addons:
apt:
packages:
- clang-format-3.9
matrix:
include:
- os: linux
addons:
apt:
packages:
- g++
env:
- CXX_COMPILER='g++'
- RUN_DANGER=false
- os: linux
addons:
apt:
packages:
- clang
- clang-format-3.9
env:
- CXX_COMPILER='clang++'
- RUN_DANGER=true
before_script:
- cmake --version
- bundle install
- |
if [[ "${RUN_DANGER}" = true ]]; then
bundle install
fi
script:
- bundle exec danger
- |
if [[ "${RUN_DANGER}" = true ]]; then
bundle exec danger
fi
- cmake -H. -Bbuild
- cd build
- make
- cmake --build .
- ctest
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)

project(hello_world CXX)

add_executable(hello_world hello_world.cpp)
add_executable(hello_world hello_world.cpp vector.cpp)

enable_testing()

Expand Down
4 changes: 2 additions & 2 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ if git.commits.any? { |c| c.message =~ /^Merge branch '#{github.branch_for_base}
fail('Please rebase to get rid of the merge commits in this PR')
end

code_style_validation.check file_extensions: ['.hpp', '.cpp', '.h', '.cc']

commit_lint.check

lgtm.check_lgtm

the_coding_love.random
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ gem "danger"
gem "danger-commit_lint"
gem "danger-lgtm"
gem "danger-the_coding_love"
gem 'danger-code_style_validation', '0.1.0', :git => 'https://github.com/flix-tech/danger-code_style_validation.git'
10 changes: 9 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
GIT
remote: https://github.com/flix-tech/danger-code_style_validation.git
revision: 05925775fa1ba9cd3eda09437c8c7efba31ef59e
specs:
danger-code_style_validation (0.1.0)
danger-plugin-api (~> 1.0)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -31,7 +38,7 @@ GEM
danger-the_coding_love (0.0.4)
danger-plugin-api (~> 1.0)
nokogiri
faraday (0.12.2)
faraday (0.13.0)
multipart-post (>= 1.2, < 3)
faraday-http-cache (1.3.1)
faraday (~> 0.8)
Expand All @@ -58,6 +65,7 @@ PLATFORMS

DEPENDENCIES
danger
danger-code_style_validation (= 0.1.0)!
danger-commit_lint
danger-lgtm
danger-the_coding_love
Expand Down
6 changes: 6 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# default.nix
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "dev-environment"; # Probably put a more meaningful name here
buildInputs = [ bundler zlib ];
}
9 changes: 7 additions & 2 deletions hello_world.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#include <cstdlib>
#include <iostream>
#include <vector>

std::vector<int> myVector();

std::string message() {
return "Hello, Danger world!";
return "Hello, Danger world!";
}

int main() {
std::cout << message() << std::endl;
return EXIT_SUCCESS;

std::vector< int > v = myVector();
return EXIT_SUCCESS;
}
13 changes: 13 additions & 0 deletions vector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <vector>

std::vector<int> myVector() {
int arr[] = {16, 2, 77, 29};
// Create a vector containing integers
std::vector<int> v (arr, arr + sizeof(arr) /sizeof(arr[0]) );

// Add two more integers to vector
v.push_back(25);
v.push_back(13);

return v;
}