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.
Let's see how many conflicts this has :sweat_smile:
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
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.
Concept ACK.
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`:
s/as compiler to configure/as the compiler to 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)
Maybe place this in the Coding Style (C++) section just above or s/Coding Style (named arguments)/Coding Style (C++ named arguments)
ACK 5ae180c542dbb43354ba944fdcbaa5ef7bc92f51 rebased to master, verified the scripted diff with 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);
ScriptPubKeyToUniv(prev_txout.scriptPubKey, o_script_pub_key, /*include_hex=*/true);
clang-tidy-12 --use-color -p=/home/ubuntu/bitcoin /home/ubuntu/bitcoin/src/core_write.cpp
/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]
ScriptPubKeyToUniv(prev_txout.scriptPubKey, o_script_pub_key, /*includeHex=*/true);
^~~~~~~~~~~~~~~
/*include_hex=*/
./core_io.h:56:74: note: 'include_hex' declared here
void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool include_hex, bool include_address = true);
^
/home/ubuntu/bitcoin/src/core_write.cpp:150:6: note: actual callee ('ScriptPubKeyToUniv') is declared here
void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool include_hex, bool include_address)
^
1 warning generated.
Already fixed in master
Running against c41736ab82cfb3b7ce8487c038eceb3617b82eb4:
clang-tidy-12 --use-color -p=/home/ubuntu/bitcoin /home/ubuntu/bitcoin/src/wallet/test/wallet_tests.cpp
wallet/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]
CWalletTx wtx{m_coinbase_txns.back(), TxStateConfirmed{m_node.chainman->ActiveChain().Tip()->GetBlockHash(), m_node.chainman->ActiveChain().Height(), /*position_in_block=*/0}};
^
./wallet/transaction.h:28:74: note: 'index' declared here
explicit TxStateConfirmed(const uint256& block_hash, int height, int index) : confirmed_block_hash(block_hash), confirmed_block_height(height), position_in_block(index) {}
^
wallet/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]
state = TxStateConfirmed{hash, block->nHeight, /*position_in_block=*/0};
^
./wallet/transaction.h:28:74: note: 'index' declared here
explicit TxStateConfirmed(const uint256& block_hash, int height, int index) : confirmed_block_hash(block_hash), confirmed_block_height(height), position_in_block(index) {}
^
wallet/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]
it->second.m_state = TxStateConfirmed{m_node.chainman->ActiveChain().Tip()->GetBlockHash(), m_node.chainman->ActiveChain().Height(), /*position_in_block=*/1};
^
./wallet/transaction.h:28:74: note: 'index' declared here
explicit TxStateConfirmed(const uint256& block_hash, int height, int index) : confirmed_block_hash(block_hash), confirmed_block_height(height), position_in_block(index) {}
^
/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]
wallet->ScanForWalletTransactions(m_node.chain->getBlockHash(0), 0, /* max height= */ {}, reserver, /* update= */ true);
^~~~~~~~~~~~~
/* fUpdate= */
./wallet/wallet.h:534:162: note: 'fUpdate' declared here
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?
<!--cf906140f33d8803c4a75a2196329ecb-->
🐙 This pull request conflicts with the target branch and needs rebase.
<sub>Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".</sub>
-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-Closing as up for grabs