Skip to content

Commit 3133be1

Browse files
authored
test: multiple linter warnings to suppress or fix (dashpay#5880)
## Issue being fixed or feature implemented On my local kubuntu linters have way too much spam ## What was done? See each commit ## How Has This Been Tested? Run locally. Amount of warnings decreased from thousands to fewer amount. Excluding typos, they are: ``` src/coinjoin/client.cpp:1420:5: warning: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm] src/coinjoin/client.cpp:1426:5: warning: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm] src/coinjoin/client.cpp:655:26: warning: Consider using std::copy_if algorithm instead of a raw loop. [useStlAlgorithm] src/coinjoin/server.cpp:593:33: warning: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm] src/coinjoin/server.cpp:630:106: warning: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm] src/governance/governance.cpp:1057:9: warning: C-style pointer casting [cstyleCast] src/governance/governance.cpp:1068:9: warning: C-style pointer casting [cstyleCast] src/governance/governance.cpp:1079:13: warning: C-style pointer casting [cstyleCast] src/governance/governance.cpp:1086:9: warning: C-style pointer casting [cstyleCast] src/governance/governance.cpp:1094:9: warning: C-style pointer casting [cstyleCast] src/governance/governance.cpp:1099:5: warning: C-style pointer casting [cstyleCast] src/governance/governance.cpp:1486:34: warning: Consider using std::copy_if algorithm instead of a raw loop. [useStlAlgorithm] src/llmq/commitment.cpp:102:5: warning: Consider using std::all_of or std::none_of algorithm instead of a raw loop. [useStlAlgorithm] src/llmq/instantsend.cpp:820:38: warning: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm] src/llmq/quorums.cpp:831:102: warning: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm] src/llmq/quorums.h:300:17: warning: C-style pointer casting [cstyleCast] src/llmq/quorums.h:301:17: warning: C-style pointer casting [cstyleCast] src/llmq/quorums.h:302:17: warning: C-style pointer casting [cstyleCast] src/llmq/quorums.h:303:17: warning: C-style pointer casting [cstyleCast] src/spork.cpp:119:58: warning: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm] src/statsd_client.cpp:234:63: warning: C-style pointer casting [cstyleCast] Advice not applicable in this specific case? Add an exception by updating IGNORED_WARNINGS in test/lint/lint-cppcheck-dash.sh ^---- failure generated from test/lint/lint-cppcheck-dash.sh Consider install flake8-cached for cached flake8 results. test/functional/data/invalid_txs.py: error: Source file found twice under different module names: "invalid_txs" and "data.invalid_txs" test/functional/data/invalid_txs.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info test/functional/data/invalid_txs.py: note: Common resolutions include: a) adding `__init__.py` somewhere, b) using `--explicit-package-bases` or adjusting MYPYPATH Found 1 error in 1 file (errors prevented further checking) ^---- failure generated from test/lint/lint-python.s ``` ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone
1 parent 95b15fd commit 3133be1

15 files changed

+22
-26
lines changed

doc/release-notes-5742.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
RPC changes
22
-----------
33

4-
RPC `gettxchainlocks` will also return the status `mempool` indicating wether the transaction is in the mempool or not.
4+
RPC `gettxchainlocks` will also return the status `mempool` indicating whether the transaction is in the mempool or not.

src/evo/cbtx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ using QcIndexedHashMap = std::map<Consensus::LLMQType, std::map<int16_t, uint256
175175

176176
/**
177177
* Handles the calculation or caching of qcHashes and qcIndexedHashes
178-
* @param pindexPrev The const CBlockIndex* (ie a block) of a block. Both the Quorum list and quorum rotation actiavtion status will be retrieved based on this block.
178+
* @param pindexPrev The const CBlockIndex* (ie a block) of a block. Both the Quorum list and quorum rotation activation status will be retrieved based on this block.
179179
* @return nullopt if quorumCommitment was unable to be found, otherwise returns the qcHashes and qcIndexedHashes that were calculated or cached
180180
*/
181181
auto CachedGetQcHashesQcIndexedHashes(const CBlockIndex* pindexPrev, const llmq::CQuorumBlockProcessor& quorum_block_processor) ->

src/evo/mnhftx.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class CMNHFManager : public AbstractEHFManager
101101
// versionBit <-> height
102102
unordered_lru_cache<uint256, Signals, StaticSaltedHasher> mnhfCache GUARDED_BY(cs_cache) {MNHFCacheSize};
103103

104-
// This cache is used only for v20 activation to avoid double lock throught VersionBitsConditionChecker::SignalHeight
104+
// This cache is used only for v20 activation to avoid double lock through VersionBitsConditionChecker::SignalHeight
105105
VersionBitsCache v20_activation GUARDED_BY(cs_cache);
106106
public:
107107
explicit CMNHFManager(CEvoDB& evoDb);
@@ -116,8 +116,8 @@ class CMNHFManager : public AbstractEHFManager
116116

117117
/**
118118
* Every undo block should be processed when Tip() is updated by calling of CMNHFManager::UndoBlock
119-
* This function actually does nothing at the moment, because status of ancester block is already know.
120-
* Altough it should be still called to do some sanity checks
119+
* This function actually does nothing at the moment, because status of ancestor block is already know.
120+
* Although it should be still called to do some sanity checks
121121
*/
122122
bool UndoBlock(const CBlock& block, const CBlockIndex* const pindex);
123123

src/evo/simplifiedmns.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ bool CSimplifiedMNListDiff::BuildQuorumsDiff(const CBlockIndex* baseBlockIndex,
183183
return true;
184184
}
185185

186-
bool CSimplifiedMNListDiff::BuildQuorumChainlockInfo(const CBlockIndex* blockIndex)
186+
void CSimplifiedMNListDiff::BuildQuorumChainlockInfo(const CBlockIndex* blockIndex)
187187
{
188188
// Group quorums (indexes corresponding to entries of newQuorums) per CBlockIndex containing the expected CL signature in CbTx.
189189
// We want to avoid to load CbTx now, as more than one quorum will target the same block: hence we want to load CbTxs once per block (heavy operation).
@@ -220,8 +220,6 @@ bool CSimplifiedMNListDiff::BuildQuorumChainlockInfo(const CBlockIndex* blockInd
220220
it_sig->second.insert(idx_set.begin(), idx_set.end());
221221
}
222222
}
223-
224-
return true;
225223
}
226224

227225
UniValue CSimplifiedMNListDiff::ToJson(bool extended) const
@@ -363,10 +361,7 @@ bool BuildSimplifiedMNListDiff(const uint256& baseBlockHash, const uint256& bloc
363361
}
364362

365363
if (DeploymentActiveAfter(blockIndex, Params().GetConsensus(), Consensus::DEPLOYMENT_V20)) {
366-
if (!mnListDiffRet.BuildQuorumChainlockInfo(blockIndex)) {
367-
errorRet = strprintf("failed to build quorums chainlocks info");
368-
return false;
369-
}
364+
mnListDiffRet.BuildQuorumChainlockInfo(blockIndex);
370365
}
371366

372367
// TODO store coinbase TX in CBlockIndex

src/evo/simplifiedmns.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class CSimplifiedMNListDiff
164164

165165
bool BuildQuorumsDiff(const CBlockIndex* baseBlockIndex, const CBlockIndex* blockIndex,
166166
const llmq::CQuorumBlockProcessor& quorum_block_processor);
167-
bool BuildQuorumChainlockInfo(const CBlockIndex* blockIndex);
167+
void BuildQuorumChainlockInfo(const CBlockIndex* blockIndex);
168168

169169
[[nodiscard]] UniValue ToJson(bool extended = false) const;
170170
};

src/governance/classes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ CSuperblock::
407407
nStatus(SeenObjectStatus::Unknown),
408408
vecPayments()
409409
{
410-
CGovernanceObject* pGovObj = GetGovernanceObject(*governance);
410+
const CGovernanceObject* pGovObj = GetGovernanceObject(*governance);
411411

412412
if (!pGovObj) {
413413
throw std::runtime_error("CSuperblock: Failed to find Governance Object");

src/llmq/chainlocks.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ CChainLocksHandler::BlockTxs::mapped_type CChainLocksHandler::GetBlockTxs(const
424424
uint32_t blockTime;
425425
{
426426
LOCK(cs_main);
427-
auto* pindex = m_chainstate.m_blockman.LookupBlockIndex(blockHash);
427+
const auto* pindex = m_chainstate.m_blockman.LookupBlockIndex(blockHash);
428428
CBlock block;
429429
if (!ReadBlockFromDisk(block, pindex, Params().GetConsensus())) {
430430
return nullptr;
@@ -640,7 +640,7 @@ void CChainLocksHandler::Cleanup()
640640
}
641641

642642
for (auto it = blockTxs.begin(); it != blockTxs.end(); ) {
643-
auto* pindex = m_chainstate.m_blockman.LookupBlockIndex(it->first);
643+
const auto* pindex = m_chainstate.m_blockman.LookupBlockIndex(it->first);
644644
if (InternalHasChainLock(pindex->nHeight, pindex->GetBlockHash())) {
645645
for (const auto& txid : *it->second) {
646646
txFirstSeenTime.erase(txid);
@@ -659,7 +659,7 @@ void CChainLocksHandler::Cleanup()
659659
// tx has vanished, probably due to conflicts
660660
it = txFirstSeenTime.erase(it);
661661
} else if (!hashBlock.IsNull()) {
662-
auto* pindex = m_chainstate.m_blockman.LookupBlockIndex(hashBlock);
662+
const auto* pindex = m_chainstate.m_blockman.LookupBlockIndex(hashBlock);
663663
if (m_chainstate.m_chain.Tip()->GetAncestor(pindex->nHeight) == pindex && m_chainstate.m_chain.Height() - pindex->nHeight >= 6) {
664664
// tx got confirmed >= 6 times, so we can stop keeping track of it
665665
it = txFirstSeenTime.erase(it);

src/llmq/context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CEvoDB& evo
5454
}
5555

5656
LLMQContext::~LLMQContext() {
57-
// LLMQContext doesn't own these objects, but still need to care of them for consistancy:
57+
// LLMQContext doesn't own these objects, but still need to care of them for consistency:
5858
llmq::quorumInstantSendManager.reset();
5959
llmq::chainLocksHandler.reset();
6060
llmq::quorumManager.reset();

src/llmq/signing_shares.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ CSigSharesNodeState::Session* CSigSharesNodeState::GetSessionByRecvId(uint32_t s
152152

153153
bool CSigSharesNodeState::GetSessionInfoByRecvId(uint32_t sessionId, SessionInfo& retInfo)
154154
{
155-
auto* s = GetSessionByRecvId(sessionId);
155+
const auto* s = GetSessionByRecvId(sessionId);
156156
if (s == nullptr) {
157157
return false;
158158
}

src/masternode/utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void CMasternodeUtils::DoMaintenance(CConnman& connman, const CMasternodeSync& m
2929

3030
// Don't disconnect masternode connections when we have less then the desired amount of outbound nodes
3131
int nonMasternodeCount = 0;
32-
connman.ForEachNode(CConnman::AllNodes, [&](CNode* pnode) {
32+
connman.ForEachNode(CConnman::AllNodes, [&](const CNode* pnode) {
3333
if ((!pnode->IsInboundConn() &&
3434
!pnode->IsFeelerConn() &&
3535
!pnode->IsManualConn() &&

0 commit comments

Comments
 (0)