Incorrect named args are source of bugs, like #22979.
To allow them being checked by clang-tidy
, use a format it can understand.
Incorrect named args are source of bugs, like #22979.
To allow them being checked by clang-tidy
, use a format it can understand.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
165+
166+```sh
167+apt install clang-tidy bear clang
168+```
169+
170+Then, pass clang as compiler to configure, and use bear to produce the `compile_commands.json`:
configure
/
141@@ -142,6 +142,51 @@ Coding Style (Python)
142
143 Refer to [/test/functional/README.md#style-guidelines](/test/functional/README.md#style-guidelines).
144
145+Coding Style (named arguments)
146+------------------------------
147+
148+When passing named arguments, use a format that clang-tidy understands. The
149+argument names can otherwise not be verified by clang-tidy.
s/can ... not/cannot/
suggested simplification: “that clang-tidy understands to enable it to verify argument names.”
141@@ -142,6 +142,51 @@ Coding Style (Python)
142
143 Refer to [/test/functional/README.md#style-guidelines](/test/functional/README.md#style-guidelines).
144
145+Coding Style (named arguments)
Coding Style (C++)
section just above or s/Coding Style (named arguments)/Coding Style (C++ named arguments)
test/lint/commit-script-check.sh ea989de..2a4582d
and ran ( cd src/ && run-clang-tidy-14 -j $(nproc) )
on debian 5.15.5-1 (2021-11-26)
214@@ -215,7 +215,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
215
216 case TxVerbosity::SHOW_DETAILS_AND_PREVOUT:
217 UniValue o_script_pub_key(UniValue::VOBJ);
218- ScriptPubKeyToUniv(prev_txout.scriptPubKey, o_script_pub_key, /* includeHex */ true);
219+ ScriptPubKeyToUniv(prev_txout.scriptPubKey, o_script_pub_key, /*includeHex=*/true);
0 ScriptPubKeyToUniv(prev_txout.scriptPubKey, o_script_pub_key, /*include_hex=*/true);
0clang-tidy-12 --use-color -p=/home/ubuntu/bitcoin /home/ubuntu/bitcoin/src/core_write.cpp
1/home/ubuntu/bitcoin/src/core_write.cpp:218:83: error: argument name 'includeHex' in comment does not match parameter name 'include_hex' [bugprone-argument-comment,-warnings-as-errors]
2 ScriptPubKeyToUniv(prev_txout.scriptPubKey, o_script_pub_key, /*includeHex=*/true);
3 ^~~~~~~~~~~~~~~
4 /*include_hex=*/
5./core_io.h:56:74: note: 'include_hex' declared here
6void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool include_hex, bool include_address = true);
7 ^
8/home/ubuntu/bitcoin/src/core_write.cpp:150:6: note: actual callee ('ScriptPubKeyToUniv') is declared here
9void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool include_hex, bool include_address)
10 ^
111 warning generated.
Running against c41736ab82cfb3b7ce8487c038eceb3617b82eb4:
0clang-tidy-12 --use-color -p=/home/ubuntu/bitcoin /home/ubuntu/bitcoin/src/wallet/test/wallet_tests.cpp
1wallet/test/wallet_tests.cpp:333:155: error: argument name 'position_in_block' in comment does not match parameter name 'index' [bugprone-argument-comment,-warnings-as-errors]
2 CWalletTx wtx{m_coinbase_txns.back(), TxStateConfirmed{m_node.chainman->ActiveChain().Tip()->GetBlockHash(), m_node.chainman->ActiveChain().Height(), /*position_in_block=*/0}};
3 ^
4./wallet/transaction.h:28:74: note: 'index' declared here
5 explicit TxStateConfirmed(const uint256& block_hash, int height, int index) : confirmed_block_hash(block_hash), confirmed_block_height(height), position_in_block(index) {}
6 ^
7wallet/test/wallet_tests.cpp:367:56: error: argument name 'position_in_block' in comment does not match parameter name 'index' [bugprone-argument-comment,-warnings-as-errors]
8 state = TxStateConfirmed{hash, block->nHeight, /*position_in_block=*/0};
9 ^
10./wallet/transaction.h:28:74: note: 'index' declared here
11 explicit TxStateConfirmed(const uint256& block_hash, int height, int index) : confirmed_block_hash(block_hash), confirmed_block_height(height), position_in_block(index) {}
12 ^
13wallet/test/wallet_tests.cpp:534:142: error: argument name 'position_in_block' in comment does not match parameter name 'index' [bugprone-argument-comment,-warnings-as-errors]
14 it->second.m_state = TxStateConfirmed{m_node.chainman->ActiveChain().Tip()->GetBlockHash(), m_node.chainman->ActiveChain().Height(), /*position_in_block=*/1};
15 ^
16./wallet/transaction.h:28:74: note: 'index' declared here
17 explicit TxStateConfirmed(const uint256& block_hash, int height, int index) : confirmed_block_hash(block_hash), confirmed_block_height(height), position_in_block(index) {}
18 ^
19/home/ubuntu/bitcoin/src/wallet/test/wallet_tests.cpp:825:109: error: argument name 'update' in comment does not match parameter name 'fUpdate' [bugprone-argument-comment,-warnings-as-errors]
20 wallet->ScanForWalletTransactions(m_node.chain->getBlockHash(0), 0, /* max height= */ {}, reserver, /* update= */ true);
21 ^~~~~~~~~~~~~
22 /* fUpdate= */
23./wallet/wallet.h:534:162: note: 'fUpdate' declared here
24 ScanResult ScanForWalletTransactions(const uint256& start_block, int start_height, std::optional<int> max_height, const WalletRescanReserver& reserver, bool fUpdate);
Running against c41736a:
Pretty sure those are bugs in current master and have nothing to do with this pull? Maybe create a separate issues or pull to fix those?
🐙 This pull request conflicts with the target branch and needs rebase.
Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a “draft”.
-BEGIN VERIFY SCRIPT-
sed -i --regexp-extended -e 's_(\(|\{|, ?)\/\* ?([^=* ]+) ?\*\/ ?_\1/*\2=*/_g' $( git grep -l --extended-regexp ', ?\/\* ?[^=* ]+ ?\*\/' ./src )
# perl -0777 -pi -e 's:((\(|\{|,)(\n| )*)\/\* ?([^=* ]+) ?\*\/ ?:\1/*\4=*/:g' $( git ls-files ./src/ )
-END VERIFY SCRIPT-