dash/test/lint/lint-cppcheck-dash.sh

126 lines
5.9 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
#
# Copyright (c) 2019 The Bitcoin 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
ENABLED_CHECKS=(
"Class '.*' has a constructor with 1 argument that is not explicit."
"Struct '.*' has a constructor with 1 argument that is not explicit."
"Function parameter '.*' should be passed by const reference."
"Comparison of modulo result is predetermined"
"Local variable '.*' shadows outer argument"
"Redundant initialization for '.*'. The initialized value is overwritten before it is read."
"Dereferencing '.*' after it is deallocated / released"
"The scope of the variable '.*' can be reduced."
"Parameter '.*' can be declared with const"
"Variable '.*' can be declared with const"
"Variable '.*' is assigned a value that is never used."
"Unused variable"
"The function '.*' overrides a function in a base class but is not marked with a 'override' specifier."
# Enabale to catch all warnings
".*"
)
IGNORED_WARNINGS=(
"src/bls/bls.h:.* Struct 'CBLSIdImplicit' has a constructor with 1 argument that is not explicit."
"src/llmq/dkgsessionmgr.h:.* warning: struct member 'ContributionsCacheEntry::entryTime' is never used."
"src/llmq/instantsend.h:.* warning: struct member 'NonLockedTxInfo::pindexMined' is never used."
"src/rpc/masternode.cpp:.*:21: warning: Consider using std::copy algorithm instead of a raw loop." # UniValue doesn't support std::copy
"src/spork.h:.* warning: struct member 'CSporkDef::defaultValue' is never used."
"src/test/dip0020opcodes_tests.cpp:.* warning: There is an unknown macro here somewhere. Configuration is required. If BOOST_FIXTURE_TEST_SUITE is a macro then please configure it."
"src/ctpl_stl.h:.*22: warning: Dereferencing '_f' after it is deallocated / released"
feat: implement quorum rotation and updated LLMQ parameters (#4752) * Added GET_SNAPSHOT_INFO message handling * Quorum members by rotation * Quorum utils functions * Handle GET_QUORUM_ROTATION_INFO with baseBlockHash from client * Storing QuorumSnaphots in evoDB when requesting them * Added DIP Enforcement param * quorumIndex cache * Quorum Rotation deployment control * Usage of Bitsets for storing CQuorumSnapshots * Correct handling of early quorum quarters * More asserts * Corrections * Handling of quorumIndex * Refactoring of truncate mechanism * Various fixes * Interface correction * Added template type for indexed cache * Added quorumIndex into commitmenHash * Various changes * Needs to update maqQuorumsCache along with indexedQuorumsCache * Added CFinalCommitment version 2 * Renamed variables * Fixes * Refactoring & correct caching of quorumMembers by rotation * Added assertions * Refactoring * Interface change * Handling of previous DKG session failure * Applied refactoring * Build quarter members improvments * Merge Quorum Rotation and Decreased fee into one deployment (DIP24) * Added new LLMQ Type * Added functional tests + refactoring * Refactoring * Spreaded Quorum creation and Quorum Index adaptation * quorumIndex adaptations * Added quorumIndex in CFinalCommitment * Latest work * Final refactoring * Batch of refactoring * Fixes for tests * Fix for CFinalCommitment * Fix for Quorums * Fix * Small changes * Thread sync fic * Safety changes * Reuse mns when needed * Refactoring * More refactoring * Fixes for rotationinfo handling * Fix for rotation of members * Correct order of MNs lists in Quorum Snapshots * Adding extra logs * Sync rotation quorums + qrinfo changes * Fix + extra logs * Removed redundant field * Fix for null final commitment + refactoring * Added timers in tests * Fix for qrinfo message: quorumdiff and merkleRootQuorums * Small changes for rotation test * Remove reading from scanQuorumCache * Added quorum list output * Crash fix * Experimental commit * apply changes to specialtxman.cpp from specialtx.cpp * all the changes * substancially speed up feature_llmq_rotation.py * reenable asserts, add check for reorgs * Refactoring * Added extra logs * format * trivial * drop extra boost includes * drop ContainsMN * fix ScanQuorums * check quorum hash and index in CFinalCommitment::Verify * fix/tweak tests * IsQuorumRotationEnabled should be aware of the context * Calculating members based on earlier block. * Fix for Quorum Members Cache * Removed duplicate size of baseBlockHashes * Adaptations of qrinfo to -8 mn lists * Introduction of llmqTypeDIP24InstantSend * Adaptation for llmqTypeDIP24InstantSend * Adaptations for IS * bump protocol version * Added feature_llmq_is_migration test * Various cleanups * use unordered_lru_cache for quorumSnapshotCache * trivial refactor ComputeQuorumMembersByQuarterRotation * Reduced CFinalCommitment::quorumIndex from 32 to 16 bits * Keep verified LLMQ relay connections * Experimental Relay connection fix * Fix for EnsureQuorumConnections rotation * Using only valid Mns for checking * Override of nPowTargetSpacing (devnet only) * Show penalty score in masternode rpc * fixups * Rotation refactoring * Update src/chainparams.cpp * Replaced LogPrintf with LogPrint * IS locking fix once DIP24 activation * Various cleanup * Updated MIN_MASTERNODE_PROTO_VERSION * Introduce LLMQ_TEST_INSTANTSEND reg-test only quorum and actually test switching to dip0024 quorums * Renamed field lastQuorumHashPerIndex * Renamed to DIP0024 * chore: update nStartTime and nTimeout for mainnet / testnet for DEPLOYMENT_DIP0024 Co-authored-by: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com> Co-authored-by: pasta <pasta@dashboost.org> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2022-04-16 16:46:04 +02:00
"src/llmq/snapshot.cpp:.*:17: warning: Consider using std::copy algorithm instead of a raw loop."
"src/llmq/snapshot.cpp:.*:18: warning: Consider using std::copy algorithm instead of a raw loop."
# General catchall, for some reason any value named 'hash' is viewed as never used.
"Variable 'hash' is assigned a value that is never used."
# The following can be useful to ignore when the catch all is used
# "Consider performing initialization in initialization list."
"Consider using std::transform algorithm instead of a raw loop."
"Consider using std::accumulate algorithm instead of a raw loop."
# "Consider using std::any_of algorithm instead of a raw loop."
# "Consider using std::count_if algorithm instead of a raw loop."
# "Consider using std::find_if algorithm instead of a raw loop."
# "Member variable '.*' is not initialized in the constructor."
)
# We should attempt to update this with all dash specific code
FILES=$(git ls-files -- "src/batchedlogger.*" \
"src/bench/bls*.cpp" \
"src/bls/*.cpp" \
"src/bls/*.h" \
"src/cachemap.h" \
"src/cachemultimap.h" \
"src/coinjoin/*.cpp" \
"src/coinjoin/*.h" \
"src/ctpl_stl.h" \
"src/cxxtimer.hpp" \
"src/dsnotificationinterface.*" \
"src/evo/*.cpp" \
"src/evo/*.h" \
"src/governance/*.cpp" \
"src/governance/*.h" \
"src/hdchain.*" \
"src/keepass.*" \
"src/llmq/*.cpp" \
"src/llmq/*.h" \
"src/masternode/*.cpp" \
"src/masternode/*.h" \
"src/messagesigner.*" \
"src/netfulfilledman.*" \
"src/qt/governancelist.*" \
"src/qt/masternodelist.*" \
"src/rpc/coinjoin.cpp" \
"src/rpc/governance.cpp" \
"src/rpc/masternode.cpp" \
"src/rpc/rpcevo.cpp" \
"src/rpc/rpcquorums.cpp" \
"src/spork.*" \
"src/saltedhasher.*" \
"src/stacktraces.*" \
"src/statsd_client.*" \
"src/test/block_reward_reallocation_tests.cpp" \
"src/test/bls_tests.cpp" \
"src/test/dip0020opcodes_tests.cpp" \
"src/test/dynamic_activation*.cpp" \
"src/test/evo*.cpp" \
"src/test/governance*.cpp" \
"src/unordered_lru_cache.h")
if ! command -v cppcheck > /dev/null; then
echo "Skipping cppcheck linting since cppcheck is not installed."
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[@]}")
FILES_REGEXP=$(join_array "|" "${FILES[@]}")
WARNINGS=$(echo "${FILES}" | \
xargs cppcheck --enable=all -j "$(getconf _NPROCESSORS_ONLN)" --language=c++ --std=c++17 --template=gcc -D__cplusplus -DENABLE_WALLET -DCLIENT_VERSION_BUILD -DCLIENT_VERSION_IS_RELEASE -DCLIENT_VERSION_MAJOR -DCLIENT_VERSION_MINOR -DCLIENT_VERSION_REVISION -DCOPYRIGHT_YEAR -DDEBUG -DHAVE_WORKING_BOOST_SLEEP_FOR -DCHAR_BIT=8 -I src/ -q 2>&1 | sort -u | \
grep -E "${ENABLED_CHECKS_REGEXP}" | \
grep -vE "${IGNORED_WARNINGS_REGEXP}" | \
grep -E "${FILES_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 linter / comment to run locally
exit 1
fi
exit 0