Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport: merge bitcoin#24794, #23524, #24902, #24915, #24916, #24929, #23506, #24840, #24982, partial bitcoin#25288 (lint backports: part 2) #6429

Merged
merged 11 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/dash/build_src.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if [ "$CHECK_DOC" = 1 ]; then
# TODO: Check docs (re-enable after all Bitcoin PRs have been merged and docs fully fixed)
#test/lint/check-doc.py
# Run all linters
test/lint/lint-all.sh
test/lint/all-lint.py
fi

ccache --zero-stats --max-size=$CCACHE_SIZE
Expand Down
2 changes: 1 addition & 1 deletion ci/lint/06_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test/lint/git-subtree-check.sh src/minisketch
test/lint/git-subtree-check.sh src/univalue
test/lint/git-subtree-check.sh src/leveldb
test/lint/check-doc.py
test/lint/lint-all.sh
test/lint/all-lint.py

if [ "$CIRRUS_REPO_FULL_NAME" = "dashpay/dash" ] && [ -n "$CIRRUS_CRON" ]; then
git log --merges --before="2 days ago" -1 --format='%H' > ./contrib/verify-commits/trusted-sha512-root-commit
Expand Down
4 changes: 2 additions & 2 deletions contrib/guix/libexec/prelude.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
export LC_ALL=C
set -e -o pipefail

# shellcheck source=../../shell/realpath.bash
# shellcheck source=contrib/shell/realpath.bash
source contrib/shell/realpath.bash

# shellcheck source=../../shell/git-utils.bash
# shellcheck source=contrib/shell/git-utils.bash
source contrib/shell/git-utils.bash

################
Expand Down
2 changes: 1 addition & 1 deletion src/banman.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ class BanMan
CRollingBloomFilter m_discouraged GUARDED_BY(m_cs_banned) {50000, 0.000001};
};

#endif
#endif // BITCOIN_BANMAN_H
2 changes: 1 addition & 1 deletion src/batchedlogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ class CBatchedLogger
void Flush();
};

#endif//BITCOIN_BATCHEDLOGGER_H
#endif // BITCOIN_BATCHEDLOGGER_H
2 changes: 1 addition & 1 deletion src/coinjoin/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ constexpr int CalculateAmountPriority(CAmount nInputAmount)

} // namespace CoinJoin

#endif
#endif // BITCOIN_COINJOIN_COMMON_H
2 changes: 1 addition & 1 deletion src/consensus/amount.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ static constexpr CAmount COIN = 100000000;
static constexpr CAmount MAX_MONEY = 21000000 * COIN;
inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }

#endif // BITCOIN_CONSENSUS_AMOUNT_H
#endif // BITCOIN_CONSENSUS_AMOUNT_H
2 changes: 1 addition & 1 deletion src/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ T* GetContext(const CoreContext& context) noexcept
: nullptr;
}

#endif // BITCOIN_CONTEXT_VARIANT_H
#endif // BITCOIN_CONTEXT_H
2 changes: 1 addition & 1 deletion src/evo/creditpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ std::optional<CCreditPoolDiff> GetCreditPoolDiffForBlock(CCreditPoolManager& cpo
const CBlock& block, const CBlockIndex* pindexPrev, const Consensus::Params& consensusParams,
const CAmount blockSubsidy, BlockValidationState& state);

#endif
#endif // BITCOIN_EVO_CREDITPOOL_H
2 changes: 1 addition & 1 deletion src/evo/dmnstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,4 @@ class CDeterministicMNStateDiff
};


#endif //BITCOIN_EVO_DMNSTATE_H
#endif // BITCOIN_EVO_DMNSTATE_H
4 changes: 2 additions & 2 deletions src/governance/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ class Object
}
}
};

} // namespace Governance
#endif

#endif // BITCOIN_GOVERNANCE_COMMON_H
2 changes: 1 addition & 1 deletion src/httprpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ void InterruptREST();
*/
void StopREST();

#endif
#endif // BITCOIN_HTTPRPC_H
2 changes: 1 addition & 1 deletion src/i2p.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,4 @@ class Session
} // namespace sam
} // namespace i2p

#endif /* BITCOIN_I2P_H */
#endif // BITCOIN_I2P_H
2 changes: 1 addition & 1 deletion src/llmq/snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,4 @@ extern std::unique_ptr<CQuorumSnapshotManager> quorumSnapshotManager;

} // namespace llmq

#endif //BITCOIN_LLMQ_SNAPSHOT_H
#endif // BITCOIN_LLMQ_SNAPSHOT_H
2 changes: 1 addition & 1 deletion src/node/psbt.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ struct PSBTAnalysis {
*/
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx);

#endif // BITCOIN_PSBT_H
#endif // BITCOIN_NODE_PSBT_H
2 changes: 1 addition & 1 deletion src/policy/feerate.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ class CFeeRate
SERIALIZE_METHODS(CFeeRate, obj) { READWRITE(obj.nSatoshisPerK); }
};

#endif // BITCOIN_POLICY_FEERATE_H
#endif // BITCOIN_POLICY_FEERATE_H
2 changes: 1 addition & 1 deletion src/randomenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ void RandAddDynamicEnv(CSHA512& hasher);
/** Gather non-cryptographic environment data that does not change over time. */
void RandAddStaticEnv(CSHA512& hasher);

#endif
#endif // BITCOIN_RANDOMENV_H
2 changes: 1 addition & 1 deletion src/rpc/blockchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
*/
UniValue CreateUTXOSnapshot(NodeContext& node, CChainState& chainstate, CAutoFile& afile);

#endif
#endif // BITCOIN_RPC_BLOCKCHAIN_H
2 changes: 1 addition & 1 deletion src/rpc/index_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ bool GetTimestampIndex(CBlockTreeDB& block_tree_db, const uint32_t high, const u
std::vector<uint256>& hashes)
EXCLUSIVE_LOCKS_REQUIRED(::cs_main);

#endif // BITCOIN_RPC_CLIENT_H
#endif // BITCOIN_RPC_INDEX_UTIL_H
2 changes: 1 addition & 1 deletion src/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ class SingleThreadedSchedulerClient
size_t CallbacksPending() EXCLUSIVE_LOCKS_REQUIRED(!m_callbacks_mutex);
};

#endif
#endif // BITCOIN_SCHEDULER_H
2 changes: 1 addition & 1 deletion src/shutdown.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ bool RestartRequested();
*/
void WaitForShutdown();

#endif
#endif // BITCOIN_SHUTDOWN_H
2 changes: 1 addition & 1 deletion src/span.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,4 @@ template<typename C>
return span.end();
}

#endif
#endif // BITCOIN_SPAN_H
2 changes: 1 addition & 1 deletion src/stacktraces.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ inline std::string GetExceptionWhat(const T& e)
void RegisterPrettyTerminateHander();
void RegisterPrettySignalHandlers();

#endif//BITCOIN_STACKTRACES_H
#endif // BITCOIN_STACKTRACES_H
2 changes: 1 addition & 1 deletion src/test/scriptnum10.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,4 @@ class CScriptNum10
};


#endif // BITCOIN_TEST_BIGNUM_H
#endif // BITCOIN_TEST_SCRIPTNUM10_H
2 changes: 1 addition & 1 deletion src/test/util/setup_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,4 @@ class HasReason
// define an implicit conversion here so that uint256 may be used directly in BOOST_CHECK_*
std::ostream& operator<<(std::ostream& os, const uint256& num);

#endif
#endif // BITCOIN_TEST_UTIL_SETUP_COMMON_H
2 changes: 1 addition & 1 deletion src/threadinterrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ class CThreadInterrupt
std::atomic<bool> flag;
};

#endif //BITCOIN_THREADINTERRUPT_H
#endif // BITCOIN_THREADINTERRUPT_H
2 changes: 1 addition & 1 deletion src/torcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ class TorController
static void reconnect_cb(evutil_socket_t fd, short what, void *arg);
};

#endif /* BITCOIN_TORCONTROL_H */
#endif // BITCOIN_TORCONTROL_H
2 changes: 1 addition & 1 deletion src/util/edge.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ class EdgeTriggeredEvents
int m_fd{-1};
};

#endif /* BITCOIN_UTIL_EDGE_H */
#endif // BITCOIN_UTIL_EDGE_H
2 changes: 1 addition & 1 deletion src/util/readwritefile.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ std::pair<bool,std::string> ReadBinaryFile(const fs::path &filename, size_t maxs
*/
bool WriteBinaryFile(const fs::path &filename, const std::string &data);

#endif /* BITCOIN_UTIL_READWRITEFILE_H */
#endif // BITCOIN_UTIL_READWRITEFILE_H
2 changes: 1 addition & 1 deletion src/util/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@
#endif


#endif /* BITCOIN_UTIL_TRACE_H */
#endif // BITCOIN_UTIL_TRACE_H
2 changes: 1 addition & 1 deletion src/util/underlying.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ template <typename E>
return static_cast<typename std::underlying_type<E>::type>(e);
}

#endif //BITCOIN_UTIL_UNDERLYING_H
#endif // BITCOIN_UTIL_UNDERLYING_H
2 changes: 1 addition & 1 deletion src/util/wpipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ class WakeupPipe
EdgeTriggeredEvents* m_edge_trig_events{nullptr};
};

#endif /* BITCOIN_UTIL_WPIPE_H */
#endif // BITCOIN_UTIL_WPIPE_H
2 changes: 1 addition & 1 deletion src/wallet/rpcwallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ RPCHelpMan getaddressinfo();
RPCHelpMan getrawchangeaddress();
RPCHelpMan addmultisigaddress();
RPCHelpMan signrawtransactionwithwallet();
#endif //BITCOIN_WALLET_RPCWALLET_H
#endif // BITCOIN_WALLET_RPCWALLET_H
2 changes: 1 addition & 1 deletion src/warnings.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ void SetfLargeWorkInvalidChainFound(bool flag);
*/
bilingual_str GetWarnings(bool verbose);

#endif // BITCOIN_WARNINGS_H
#endif // BITCOIN_WARNINGS_H
2 changes: 1 addition & 1 deletion src/zmq/zmqrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ class CRPCTable;

void RegisterZMQRPCCommands(CRPCTable& t);

#endif // BITCOIN_ZMQ_ZMRRPC_H
#endif // BITCOIN_ZMQ_ZMQRPC_H
10 changes: 5 additions & 5 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,11 @@ Use the `-v` option for verbose output.

| Lint test | Dependency |
|-----------|:----------:|
| [`lint-python.sh`](lint/lint-python.sh) | [flake8](https://gitlab.com/pycqa/flake8)
| [`lint-python.sh`](lint/lint-python.sh) | [mypy](https://github.com/python/mypy)
| [`lint-python.sh`](lint/lint-python.sh) | [pyzmq](https://github.com/zeromq/pyzmq)
| [`lint-python.py`](lint/lint-python.py) | [flake8](https://gitlab.com/pycqa/flake8)
| [`lint-python.py`](lint/lint-python.py) | [mypy](https://github.com/python/mypy)
| [`lint-python.py`](lint/lint-python.py) | [pyzmq](https://github.com/zeromq/pyzmq)
| [`lint-python-dead-code.py`](lint/lint-python-dead-code.py) | [vulture](https://github.com/jendrikseipp/vulture)
| [`lint-shell.sh`](lint/lint-shell.sh) | [ShellCheck](https://github.com/koalaman/shellcheck)
| [`lint-shell.py`](lint/lint-shell.py) | [ShellCheck](https://github.com/koalaman/shellcheck)
| [`lint-spelling.py`](lint/lint-spelling.py) | [codespell](https://github.com/codespell-project/codespell)

In use versions and install instructions are available in the [CI setup](../ci/lint/04_install.sh).
Expand All @@ -332,7 +332,7 @@ test/lint/lint-files.py
You can run all the shell-based lint tests by running:

```
test/lint/lint-all.sh
test/lint/all-lint.py
```

# Writing functional tests
Expand Down
2 changes: 1 addition & 1 deletion test/lint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ To do so, add the upstream repository as remote:
git remote add --fetch secp256k1 https://github.com/bitcoin-core/secp256k1.git
```

lint-all.sh
all-lint.py
===========
Calls other scripts with the `lint-` prefix.
36 changes: 36 additions & 0 deletions test/lint/all-lint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
#
# Copyright (c) 2017-2022 The Bitcoin 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/lint-* files, and fails if any exit
# with a non-zero status code.

from glob import glob
from os import path as os_path, remove
from pathlib import Path
from shutil import which
from subprocess import run

exit_code = 0
mod_path = Path(__file__).parent
lints = glob(f"{mod_path}/lint-*")
if which("parallel") and which("column"):
logfile = "parallel_out.log"
command = ["parallel", "--jobs", "100%", "--will-cite", "--joblog", logfile, ":::"] + lints
result = run(command)
if result.returncode != 0:
print(f"^---- failure generated")
exit_code = result.returncode
result = run(["column", "-t", logfile])
if os_path.isfile(logfile):
remove(logfile)
else:
for lint in lints:
result = run([lint])
if result.returncode != 0:
print(f"^---- failure generated from {lint.split('/')[-1]}")
exit_code |= result.returncode

exit(exit_code)
46 changes: 0 additions & 46 deletions test/lint/lint-all.sh

This file was deleted.

Loading
Loading