From af0dd25b861291e1c094df1d59856e3594355186 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Wed, 14 Oct 2015 01:01:25 +0300 Subject: [PATCH] * add clang-format configuration and script * add cppcheck script proto (TODO include directories according ot cmake output) TODO do it while build time and/or commit --- utils/.clang-format | 66 ++++++++++++++++++++++++++++++++++++++++++ utils/cpp-check.sh | 9 ++++++ utils/qt-code-style.sh | 10 +++++++ 3 files changed, 85 insertions(+) create mode 100644 utils/.clang-format create mode 100755 utils/cpp-check.sh create mode 100755 utils/qt-code-style.sh diff --git a/utils/.clang-format b/utils/.clang-format new file mode 100644 index 0000000..9baa1fd --- /dev/null +++ b/utils/.clang-format @@ -0,0 +1,66 @@ +--- +Language: Cpp +AccessModifierOffset: -4 +AlignAfterOpenBracket: true +AlignConsecutiveAssignments: false +AlignEscapedNewlinesLeft: false +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false +BinPackArguments: true +BinPackParameters: true +BreakBeforeBinaryOperators: All +BreakBeforeBraces: Linux +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IndentCaseLabels: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 8 +UseTab: Never +... + diff --git a/utils/cpp-check.sh b/utils/cpp-check.sh new file mode 100755 index 0000000..ae993be --- /dev/null +++ b/utils/cpp-check.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# This code is used to check source files with cppcheck + +cppcheck --enable=all \ + --std=c++11 \ + --verbose \ + --quiet \ + ../sources 2>&1 | grep -v '3rdparty' diff --git a/utils/qt-code-style.sh b/utils/qt-code-style.sh new file mode 100755 index 0000000..357d934 --- /dev/null +++ b/utils/qt-code-style.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# This script will check the source code by using clang-format with required arguments. +# The template comes from https://gist.github.com/Uflex/7086827 +# More details may be found here http://clang.llvm.org/docs/ClangFormatStyleOptions.html + +clang-format -i \ + -style=file \ + $(find ../sources -not -path '*3rdparty*' \ + -and \( -name '*.cpp' -or -name '*.h' \))