This repository was archived by the owner on May 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 191
PARQUET-477: Add clang-format / clang-tidy checks to toolchain #92
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6c2e7cf
Adapt clang-tidy / clang-format tools from Apache Arrow C++ codebase
wesm 514601c
Fix build dir in travis script
wesm 2c512dc
Install newer boost due to C++11 issues on ubuntu precise
wesm 503e793
Boost 1.55
wesm 8b6e8f0
Statically-link zlib
wesm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # Runs clang format in the given directory | ||
| # Arguments: | ||
| # $1 - Path to the source tree | ||
| # $2 - Path to the clang format binary | ||
| # $3 - Apply fixes (will raise an error if false and not there where changes) | ||
| # $ARGN - Files to run clang format on | ||
| # | ||
| SOURCE_DIR=$1 | ||
| shift | ||
| CLANG_FORMAT=$1 | ||
| shift | ||
| APPLY_FIXES=$1 | ||
| shift | ||
|
|
||
| # clang format will only find its configuration if we are in | ||
| # the source tree or in a path relative to the source tree | ||
| pushd $SOURCE_DIR | ||
| if [ "$APPLY_FIXES" == "1" ]; then | ||
| $CLANG_FORMAT -i $@ | ||
| else | ||
|
|
||
| NUM_CORRECTIONS=`$CLANG_FORMAT -output-replacements-xml $@ | grep offset | wc -l` | ||
| if [ "$NUM_CORRECTIONS" -gt "0" ]; then | ||
| echo "clang-format suggested changes, please run 'make format'!!!!" | ||
| exit 1 | ||
| fi | ||
| fi | ||
| popd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # | ||
| # Runs clang format in the given directory | ||
| # Arguments: | ||
| # $1 - Path to the clang tidy binary | ||
| # $2 - Path to the compile_commands.json to use | ||
| # $3 - Apply fixes (will raise an error if false and not there where changes) | ||
| # $ARGN - Files to run clang-tidy on | ||
| # | ||
| CLANG_TIDY=$1 | ||
| shift | ||
| COMPILE_COMMANDS=$1 | ||
| shift | ||
| APPLY_FIXES=$1 | ||
| shift | ||
|
|
||
| # clang format will only find its configuration if we are in | ||
| # the source tree or in a path relative to the source tree | ||
| if [ "$APPLY_FIXES" == "1" ]; then | ||
| $CLANG_TIDY -p $COMPILE_COMMANDS -fix $@ | ||
| else | ||
| NUM_CORRECTIONS=`$CLANG_TIDY -p $COMPILE_COMMANDS $@ 2>&1 | grep -v Skipping | grep "warnings* generated" | wc -l` | ||
| if [ "$NUM_CORRECTIONS" -gt "0" ]; then | ||
| echo "clang-tidy had suggested fixes. Please fix these!!!" | ||
| exit 1 | ||
| fi | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
|
|
||
| : ${CPP_BUILD_DIR=$TRAVIS_BUILD_DIR/parquet-build} | ||
|
|
||
| pushd $CPP_BUILD_DIR | ||
|
|
||
| make lint | ||
| if [ $TRAVIS_OS_NAME == "linux" ]; then | ||
| make check-format | ||
| make check-clang-tidy | ||
| fi | ||
|
|
||
| if [ $TRAVIS_OS_NAME == "linux" ]; then | ||
| make -j4 || exit 1 | ||
| ctest || { cat $TRAVIS_BUILD_DIR/parquet-build/Testing/Temporary/LastTest.log; exit 1; } | ||
| sudo pip install cpp_coveralls | ||
| export PARQUET_ROOT=$TRAVIS_BUILD_DIR | ||
| $TRAVIS_BUILD_DIR/ci/upload_coverage.sh | ||
| else | ||
| make -j4 || exit 1 | ||
| ctest || { cat $TRAVIS_BUILD_DIR/parquet-build/Testing/Temporary/LastTest.log; exit 1; } | ||
| fi | ||
|
|
||
| popd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # Tries to find the clang-tidy and clang-format modules | ||
| # | ||
| # Usage of this module as follows: | ||
| # | ||
| # find_package(ClangTools) | ||
| # | ||
| # Variables used by this module, they can change the default behaviour and need | ||
| # to be set before calling find_package: | ||
| # | ||
| # ClangToolsBin_HOME - | ||
| # When set, this path is inspected instead of standard library binary locations | ||
| # to find clang-tidy and clang-format | ||
| # | ||
| # This module defines | ||
| # CLANG_TIDY_BIN, The path to the clang tidy binary | ||
| # CLANG_TIDY_FOUND, Whether clang tidy was found | ||
| # CLANG_FORMAT_BIN, The path to the clang format binary | ||
| # CLANG_TIDY_FOUND, Whether clang format was found | ||
|
|
||
| find_program(CLANG_TIDY_BIN | ||
| NAMES clang-tidy-3.8 clang-tidy-3.7 clang-tidy-3.6 clang-tidy | ||
| PATHS ${ClangTools_PATH} $ENV{CLANG_TOOLS_PATH} /usr/local/bin /usr/bin | ||
| NO_DEFAULT_PATH | ||
| ) | ||
|
|
||
| if ( "${CLANG_TIDY_BIN}" STREQUAL "CLANG_TIDY_BIN-NOTFOUND" ) | ||
| set(CLANG_TIDY_FOUND 0) | ||
| message("clang-tidy not found") | ||
| else() | ||
| set(CLANG_TIDY_FOUND 1) | ||
| message("clang-tidy found at ${CLANG_TIDY_BIN}") | ||
| endif() | ||
|
|
||
| find_program(CLANG_FORMAT_BIN | ||
| NAMES clang-format-3.8 clang-format-3.7 clang-format-3.6 clang-format | ||
| PATHS ${ClangTools_PATH} $ENV{CLANG_TOOLS_PATH} /usr/local/bin /usr/bin | ||
| NO_DEFAULT_PATH | ||
| ) | ||
|
|
||
| if ( "${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND" ) | ||
| set(CLANG_FORMAT_FOUND 0) | ||
| message("clang-format not found") | ||
| else() | ||
| set(CLANG_FORMAT_FOUND 1) | ||
| message("clang-format found at ${CLANG_FORMAT_BIN}") | ||
| endif() | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| --- | ||
| Language: Cpp | ||
| # BasedOnStyle: Google | ||
| AccessModifierOffset: -1 | ||
| AlignAfterOpenBracket: false | ||
| AlignConsecutiveAssignments: false | ||
| AlignEscapedNewlinesLeft: true | ||
| AlignOperands: true | ||
| AlignTrailingComments: true | ||
| AllowAllParametersOfDeclarationOnNextLine: true | ||
| AllowShortBlocksOnASingleLine: true | ||
| AllowShortCaseLabelsOnASingleLine: false | ||
| AllowShortFunctionsOnASingleLine: Inline | ||
| AllowShortIfStatementsOnASingleLine: true | ||
| AllowShortLoopsOnASingleLine: false | ||
| AlwaysBreakAfterDefinitionReturnType: None | ||
| AlwaysBreakBeforeMultilineStrings: true | ||
| AlwaysBreakTemplateDeclarations: true | ||
| BinPackArguments: true | ||
| BinPackParameters: true | ||
| BreakBeforeBinaryOperators: None | ||
| BreakBeforeBraces: Attach | ||
| BreakBeforeTernaryOperators: true | ||
| BreakConstructorInitializersBeforeComma: false | ||
| ColumnLimit: 90 | ||
| CommentPragmas: '^ IWYU pragma:' | ||
| ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
| ConstructorInitializerIndentWidth: 4 | ||
| ContinuationIndentWidth: 4 | ||
| Cpp11BracedListStyle: true | ||
| DerivePointerAlignment: false | ||
| DisableFormat: false | ||
| ExperimentalAutoDetectBinPacking: false | ||
| ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] | ||
| IndentCaseLabels: true | ||
| IndentWidth: 2 | ||
| IndentWrappedFunctionNames: false | ||
| KeepEmptyLinesAtTheStartOfBlocks: false | ||
| MacroBlockBegin: '' | ||
| MacroBlockEnd: '' | ||
| MaxEmptyLinesToKeep: 1 | ||
| NamespaceIndentation: None | ||
| ObjCBlockIndentWidth: 2 | ||
| ObjCSpaceAfterProperty: false | ||
| ObjCSpaceBeforeProtocolList: false | ||
| PenaltyBreakBeforeFirstCallParameter: 1000 | ||
| PenaltyBreakComment: 300 | ||
| PenaltyBreakFirstLessLess: 120 | ||
| PenaltyBreakString: 1000 | ||
| PenaltyExcessCharacter: 1000000 | ||
| PenaltyReturnTypeOnItsOwnLine: 200 | ||
| PointerAlignment: Left | ||
| SpaceAfterCStyleCast: false | ||
| SpaceBeforeAssignmentOperators: true | ||
| SpaceBeforeParens: ControlStatements | ||
| SpaceInEmptyParentheses: false | ||
| SpacesBeforeTrailingComments: 2 | ||
| SpacesInAngles: false | ||
| SpacesInContainerLiterals: true | ||
| SpacesInCStyleCastParentheses: false | ||
| SpacesInParentheses: false | ||
| SpacesInSquareBrackets: false | ||
| Standard: Cpp11 | ||
| TabWidth: 8 | ||
| UseTab: Never |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| Checks: 'clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-.*,modernize-.*,readablity-.*' | ||
| HeaderFilterRegex: 'parquet/.*' | ||
| AnalyzeTemporaryDtors: true | ||
| CheckOptions: | ||
| - key: google-readability-braces-around-statements.ShortStatementLines | ||
| value: '1' | ||
| - key: google-readability-function-size.StatementThreshold | ||
| value: '800' | ||
| - key: google-readability-namespace-comments.ShortNamespaceLines | ||
| value: '10' | ||
| - key: google-readability-namespace-comments.SpacesBeforeComments | ||
| value: '2' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,4 +29,4 @@ | |
| // IO | ||
| #include "parquet/api/io.h" | ||
|
|
||
| #endif // PARQUET_API_READER_H | ||
| #endif // PARQUET_API_READER_H | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zlib was being dynamically linked (and there is a valgrind warning on Ubuntu 12.04) so this fixes that