forked from PIVX-Project/PIVX
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: Add extended lint job for cppcheck
- Loading branch information
Showing
3 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,27 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright (c) 2019 The Bitcoin Core developers | ||
# Copyright (c) 2024 The PIVX Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
# | ||
# This script runs all test/lint/extended-lint-*.sh files, and fails if | ||
# any exit with a non-zero status code. | ||
|
||
# This script is intentionally locale dependent by not setting "export LC_ALL=C" | ||
# in order to allow for the executed lint scripts to opt in or opt out of locale | ||
# dependence themselves. | ||
|
||
set -u | ||
|
||
SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}") | ||
LINTALL=$(basename "${BASH_SOURCE[0]}") | ||
|
||
for f in "${SCRIPTDIR}"/extended-lint-*.sh; do | ||
if [ "$(basename "$f")" != "$LINTALL" ]; then | ||
if ! "$f"; then | ||
echo "^---- failure generated from $f" | ||
exit 1 | ||
fi | ||
fi | ||
done |
This file contains 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,93 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright (c) 2019 The Bitcoin Core developers | ||
# Copyright (c) 2024 The PIVX Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
# | ||
|
||
export LC_ALL=C | ||
|
||
CPPCHECK_BUILD_DIR=".ci-cppcheck" | ||
|
||
ENABLED_CHECKS=( | ||
"Class '.*' has a constructor with 1 argument that is not explicit." | ||
"Struct '.*' has a constructor with 1 argument that is not explicit." | ||
) | ||
|
||
IGNORED_WARNINGS=( | ||
"src/immer/.*" | ||
"src/chiabls/.*" | ||
"src/arith_uint256.h:.* Class 'arith_uint160' has a constructor with 1 argument that is not explicit." | ||
"src/arith_uint256.h:.* Class 'arith_uint256' has a constructor with 1 argument that is not explicit." | ||
"src/arith_uint256.h:.* Class 'arith_uint512' has a constructor with 1 argument that is not explicit." | ||
"src/arith_uint256.h:.* Class 'base_uint < 160 >' has a constructor with 1 argument that is not explicit." | ||
"src/arith_uint256.h:.* Class 'base_uint < 256 >' has a constructor with 1 argument that is not explicit." | ||
"src/arith_uint256.h:.* Class 'base_uint < 512 >' has a constructor with 1 argument that is not explicit." | ||
"src/arith_uint256.h:.* Class 'base_uint' has a constructor with 1 argument that is not explicit." | ||
"src/coins.h:.* Class 'CCoinsViewBacked' has a constructor with 1 argument that is not explicit." | ||
"src/coins.h:.* Class 'CCoinsViewCache' has a constructor with 1 argument that is not explicit." | ||
"src/bls/bls_wrapper.h:.* Struct 'CBLSIdImplicit' has a constructor with 1 argument that is not explicit." | ||
"src/bls/bls_wrapper.h:.* Class 'CBLSId' has a constructor with 1 argument that is not explicit." | ||
"src/bls/bls_wrapper.h:.* Class 'CBLSWrapper < CBLSIdImplicit , 32 , CBLSId >' has a constructor with 1 argument that is not explicit." | ||
"src/bls/bls_wrapper.h:.* Class 'CBLSWrapper < bls :: G1Element , 48 , CBLSPublicKey >' has a constructor with 1 argument that is not explicit." | ||
"src/bls/bls_wrapper.h:.* Class 'CBLSWrapper < bls :: G2Element , 96 , CBLSSignature >' has a constructor with 1 argument that is not explicit." | ||
"src/bls/bls_wrapper.h:.* Class 'CBLSWrapper < bls :: PrivateKey , 32 , CBLSSecretKey >' has a constructor with 1 argument that is not explicit." | ||
"src/operationresult.h:.* Class 'OperationResult' has a constructor with 1 argument that is not explicit." | ||
"src/prevector.h:.* Class 'const_iterator' has a constructor with 1 argument that is not explicit." | ||
"src/prevector.h:.* Class 'const_reverse_iterator' has a constructor with 1 argument that is not explicit." | ||
"src/prevector.h:.* Class 'iterator' has a constructor with 1 argument that is not explicit." | ||
"src/prevector.h:.* Class 'reverse_iterator' has a constructor with 1 argument that is not explicit." | ||
"src/primitives/block.h:.* Class 'CBlock' has a constructor with 1 argument that is not explicit." | ||
"src/primitives/transaction.h:.* Class 'CTransaction' has a constructor with 1 argument that is not explicit." | ||
"src/primitives/transaction.h:.* Struct 'CMutableTransaction' has a constructor with 1 argument that is not explicit." | ||
"src/libzerocoin/bignum.h:.* Class 'CBigNum' has a constructor with 1 argument that is not explicit." | ||
"src/qt/walletmodel.h:.* Struct 'SendCoinsReturn' has a constructor with 1 argument that is not explicit." | ||
"src/rpc/server.h:.* Struct 'UniValueType' has a constructor with 1 argument that is not explicit." | ||
"src/sapling/incrementalmerkletree.h:.* Class 'PedersenHash' has a constructor with 1 argument that is not explicit." | ||
"src/sapling/incrementalmerkletree.h:.* Class 'SHA256Compress' has a constructor with 1 argument that is not explicit." | ||
"src/script/standard.h:.* Class 'CScriptID' has a constructor with 1 argument that is not explicit." | ||
"src/span.h:.* Class 'Span' has a constructor with 1 argument that is not explicit." | ||
"src/span.h:.* Class 'Span < const char >' has a constructor with 1 argument that is not explicit." | ||
"src/span.h:.* Class 'Span < const uint8_t >' has a constructor with 1 argument that is not explicit." | ||
"src/span.h:.* Class 'Span < const unsigned char >' has a constructor with 1 argument that is not explicit." | ||
"src/span.h:.* Class 'Span < uint8_t >' has a constructor with 1 argument that is not explicit." | ||
"src/span.h:.* Class 'Span < unsigned char >' has a constructor with 1 argument that is not explicit." | ||
"src/support/allocators/secure.h:.* Struct 'secure_allocator < char >' has a constructor with 1 argument that is not explicit." | ||
"src/support/allocators/secure.h:.* Struct 'secure_allocator < RNGState >' has a constructor with 1 argument that is not explicit." | ||
"src/support/allocators/secure.h:.* Struct 'secure_allocator < unsigned char >' has a constructor with 1 argument that is not explicit." | ||
"src/support/allocators/zeroafterfree.h:.* Struct 'zero_after_free_allocator < char >' has a constructor with 1 argument that is not explicit." | ||
"src/wallet/wallet.h:.* Struct 'Confirmation' has a constructor with 1 argument that is not explicit." | ||
) | ||
|
||
if ! command -v cppcheck > /dev/null; then | ||
echo "Skipping cppcheck linting since cppcheck is not installed. Install by running \"apt install cppcheck\"" | ||
exit 0 | ||
fi | ||
|
||
function join_array { | ||
local IFS="$1" | ||
shift | ||
echo "$*" | ||
} | ||
|
||
ENABLED_CHECKS_REGEXP=$(join_array "|" "${ENABLED_CHECKS[@]}") | ||
IGNORED_WARNINGS_REGEXP=$(join_array "|" "${IGNORED_WARNINGS[@]}") | ||
|
||
cppcheck --cppcheck-build-dir="${CPPCHECK_BUILD_DIR}" --enable=all -j "$(getconf _NPROCESSORS_ONLN)" \ | ||
--language=c++ --std=c++14 --template=gcc --check-level=exhaustive --file-filter=*.cpp --file-filter=*.h -isrc/chiabls \ | ||
-isrc/crc32c -isrc/immer -isrc/leveldb -isrc/secp256k1 -isrc/univalue -D__cplusplus -DCLIENT_VERSION_BUILD \ | ||
-DCLIENT_VERSION_IS_RELEASE -DCLIENT_VERSION_MAJOR -DCLIENT_VERSION_MINOR -DCLIENT_VERSION_REVISION -DCOPYRIGHT_YEAR \ | ||
-DDEBUG -DWITH_LOCK -DPACKAGE_NAME -DENABLE_MINING_RPC --library=boost --library=qt -I src/ -I src/qt/ src/ 2> >(sort -u > cppcheck.txt) | ||
|
||
WARNINGS=$(< cppcheck.txt grep -E "${ENABLED_CHECKS_REGEXP}" | grep -vE "${IGNORED_WARNINGS_REGEXP}") | ||
|
||
if [[ ${WARNINGS} != "" ]]; then | ||
echo "${WARNINGS}" | ||
echo | ||
echo "Advice not applicable in this specific case? Add an exception by updating" | ||
echo "IGNORED_WARNINGS in $0" | ||
# Uncomment to enforce the developer note policy "By default, declare single-argument constructors `explicit`" | ||
# exit 1 | ||
fi | ||
exit 0 |