diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..f0a182f --- /dev/null +++ b/.clang-format @@ -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 diff --git a/.travis.yml b/.travis.yml index c1d7da4..84ab01d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index f50d986..7c22aa4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/Dangerfile b/Dangerfile index 5aa30ba..c643d33 100644 --- a/Dangerfile +++ b/Dangerfile @@ -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 diff --git a/Gemfile b/Gemfile index 39ae4b9..4a2b0d3 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 31ad2eb..172bf96 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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: @@ -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) @@ -58,6 +65,7 @@ PLATFORMS DEPENDENCIES danger + danger-code_style_validation (= 0.1.0)! danger-commit_lint danger-lgtm danger-the_coding_love diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..c21deb6 --- /dev/null +++ b/default.nix @@ -0,0 +1,6 @@ +# default.nix +with import {}; +stdenv.mkDerivation { + name = "dev-environment"; # Probably put a more meaningful name here + buildInputs = [ bundler zlib ]; +} diff --git a/hello_world.cpp b/hello_world.cpp index 743be7c..1aaae3e 100644 --- a/hello_world.cpp +++ b/hello_world.cpp @@ -1,11 +1,16 @@ #include #include +#include + +std::vector 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; } diff --git a/vector.cpp b/vector.cpp new file mode 100644 index 0000000..0805daa --- /dev/null +++ b/vector.cpp @@ -0,0 +1,13 @@ +#include + +std::vector myVector() { +int arr[] = {16, 2, 77, 29}; +// Create a vector containing integers +std::vector v (arr, arr + sizeof(arr) /sizeof(arr[0]) ); + +// Add two more integers to vector +v.push_back(25); +v.push_back(13); + +return v; +}