Skip to content

fix(scripts): make lint-cppcheck-dash actually report warnings - #7535

Open
PastaPastaPasta wants to merge 17 commits into
dashpay:developfrom
PastaPastaPasta:claude/mystifying-gauss-adccbd
Open

fix(scripts): make lint-cppcheck-dash actually report warnings#7535
PastaPastaPasta wants to merge 17 commits into
dashpay:developfrom
PastaPastaPasta:claude/mystifying-gauss-adccbd

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

test/lint/lint-cppcheck-dash.py has been effectively vacuous — it ran cppcheck, silently analyzed almost nothing, and always passed. Two failure modes:

  1. With the script's -D list, __GNUC__ is not defined, so src/attributes.h hits #error No known always_inline attribute (preprocessorErrorDirective), aborting cppcheck's analysis of nearly every translation unit. The error lines were then dropped by the output filter, which only keeps lines pointing at files from test/util/data/non-backported.txt.
  2. Even with preprocessing fixed, cppcheck 2.17.1 with --check-level=exhaustive crashes with an assertion in TokenList::setLang (child dies with signal 6) — and that crash message was explicitly listed in SUPPRESSED_WARNINGS.

Net effect: an injected canary warning in a non-backported file was not flagged, locally or in CI.

What was done?

Linter (test/lint/lint-cppcheck-dash.py):

  • Define __GNUC__ so preprocessing succeeds.
  • Add a FATAL_ERRORS list (preprocessorErrorDirective, internal errors/crashes) that fails the lint regardless of which file the line points at, so analysis failures can never again be silently filtered away.
  • Drop the signal-6 crash suppression (the TODO said to remove it with a newer cppcheck).
  • Skip note:/source-context lines: they don't carry the check id that suppressions match on, so orphaned notes of suppressed warnings leaked through the filter.
  • Wholesale-suppress the check ids with pre-existing violations in the tree (knownConditionTrueFalse, shadowFunction, uninitMemberVarNoCtor, etc.), documented as a burn-down TODO, so the linter can be enforced now. Messages matching ALWAYS_ENABLED_WARNINGS still override these suppressions.

Container (contrib/containers/ci/ci-slim.Dockerfile): bump cppcheck 2.17.1 → 2.21.0, which no longer crashes under --check-level=exhaustive.

Code fixes for the ~11 warnings that ALWAYS_ENABLED_WARNINGS patterns force-report (these cannot be suppressed by check id): removed dead locals (src/active/dkgsession.cpp, src/rpc/evo.cpp), made single-argument constructors explicit (chainlock::Chainlocks, CDSTXManager; no implicit-conversion call sites exist), inline-suppressed CBLSIdImplicit's intentionally implicit constructor, narrowed three static benchmark counters to their usage scope in src/evo/specialtxman.cpp (static storage duration unchanged), passed CSigBase by const reference in InitSession (callers already sliced identically by value; accessors are non-virtual), moved BlsCheck's by-value constructor parameters into members, and inline-suppressed a danglingTempReference false positive on a lifetime-extended range-for temporary in src/rpc/governance.cpp.

How Has This Been Tested?

With cppcheck 2.21.0 locally (matching the bumped container version):

  • Injected a canary (unreadVariable) into src/spork.cpp: the linter reports exactly that warning and exits 1.
  • Canary removed: full 273-file run is clean and exits 0.
  • Removed -D__GNUC__ to simulate failure mode 1: the attributes.h #error line surfaces via FATAL_ERRORS and the linter exits 1.
  • All touched translation units pass clang -fsyntax-only with the project's compile flags; test/lint/lint-python.py passes.

Note: the previously-suppressed count_if/find_if useStlAlgorithm variants are now covered by the wholesale id suppression along with the rest of the burn-down list.

Breaking Changes

None. CI lint may take somewhat longer since cppcheck now actually analyzes all 273 non-backported files with --check-level=exhaustive.

Checklist:

  • 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
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e6e4db3a-337c-491c-b25f-edab9d669fd8

📥 Commits

Reviewing files that changed from the base of the PR and between b44f9e3 and 97e975e.

📒 Files selected for processing (88)
  • contrib/containers/ci/ci-slim.Dockerfile
  • src/active/context.h
  • src/active/dkgsession.cpp
  • src/active/dkgsession.h
  • src/active/dkgsessionhandler.h
  • src/bench/bls_dkg.cpp
  • src/bls/bls.cpp
  • src/bls/bls.h
  • src/bls/bls_worker.cpp
  • src/chainlock/chainlock.h
  • src/chainlock/signing.cpp
  • src/chainlock/signing.h
  • src/coinjoin/client.cpp
  • src/coinjoin/client.h
  • src/coinjoin/coinjoin.cpp
  • src/coinjoin/coinjoin.h
  • src/coinjoin/common.h
  • src/coinjoin/server.cpp
  • src/coinjoin/server.h
  • src/coinjoin/util.cpp
  • src/coinjoin/util.h
  • src/coinjoin/walletman.cpp
  • src/evo/core_write.cpp
  • src/evo/deterministicmns.cpp
  • src/evo/deterministicmns.h
  • src/evo/dmn_types.h
  • src/evo/mnhftx.h
  • src/evo/netinfo.cpp
  • src/evo/netinfo.h
  • src/evo/providertx.cpp
  • src/evo/simplifiedmns.cpp
  • src/evo/smldiff.cpp
  • src/evo/specialtxman.cpp
  • src/governance/governance.cpp
  • src/governance/governance.h
  • src/governance/net_governance.cpp
  • src/governance/signing.cpp
  • src/governance/superblock.cpp
  • src/governance/superblock.h
  • src/index/addressindex.cpp
  • src/index/addressindex.h
  • src/index/addressindex_types.h
  • src/index/timestampindex.cpp
  • src/index/timestampindex.h
  • src/init.cpp
  • src/instantsend/instantsend.h
  • src/instantsend/signing.cpp
  • src/instantsend/signing.h
  • src/llmq/commitment.cpp
  • src/llmq/core_write.cpp
  • src/llmq/debug.cpp
  • src/llmq/dkgmessages.h
  • src/llmq/dkgsessionmgr.h
  • src/llmq/ehf_signals.h
  • src/llmq/net_dkg.cpp
  • src/llmq/net_dkg.h
  • src/llmq/net_quorum.cpp
  • src/llmq/net_quorum.h
  • src/llmq/net_signing.cpp
  • src/llmq/observer.h
  • src/llmq/params.h
  • src/llmq/quorums.h
  • src/llmq/signing_shares.cpp
  • src/llmq/signing_shares.h
  • src/llmq/snapshot.h
  • src/llmq/utils.cpp
  • src/masternode/meta.h
  • src/node/interfaces.cpp
  • src/qt/clientfeeds.h
  • src/qt/donutchart.h
  • src/rpc/blockchain.cpp
  • src/rpc/coinjoin.cpp
  • src/rpc/evo.cpp
  • src/rpc/governance.cpp
  • src/rpc/masternode.cpp
  • src/rpc/quorums.cpp
  • src/stacktraces.cpp
  • src/stats/client.cpp
  • src/test/evo_netinfo_tests.cpp
  • src/test/util/llmq_tests.h
  • src/util/ranges_set.cpp
  • src/util/ranges_set.h
  • src/util/std23.h
  • src/wallet/bip39.cpp
  • src/wallet/coinjoin.cpp
  • src/wallet/hdchain.cpp
  • src/wallet/hdchain.h
  • test/lint/lint-cppcheck-dash.py
💤 Files with no reviewable changes (1)
  • src/active/dkgsession.cpp
🚧 Files skipped from review as they are similar to previous changes (83)
  • src/chainlock/chainlock.h
  • src/instantsend/signing.h
  • src/coinjoin/coinjoin.h
  • src/llmq/snapshot.h
  • src/coinjoin/util.h
  • src/masternode/meta.h
  • src/init.cpp
  • src/instantsend/instantsend.h
  • src/llmq/net_dkg.h
  • src/rpc/blockchain.cpp
  • src/evo/dmn_types.h
  • src/chainlock/signing.cpp
  • src/coinjoin/common.h
  • src/evo/netinfo.h
  • src/evo/smldiff.cpp
  • src/coinjoin/walletman.cpp
  • src/bls/bls.cpp
  • src/llmq/ehf_signals.h
  • src/wallet/hdchain.cpp
  • src/bench/bls_dkg.cpp
  • src/evo/mnhftx.h
  • src/coinjoin/client.cpp
  • src/bls/bls.h
  • src/governance/governance.h
  • src/evo/simplifiedmns.cpp
  • src/llmq/commitment.cpp
  • src/active/dkgsession.h
  • src/index/addressindex.h
  • src/governance/governance.cpp
  • src/test/evo_netinfo_tests.cpp
  • src/rpc/governance.cpp
  • src/wallet/hdchain.h
  • src/evo/deterministicmns.cpp
  • src/llmq/dkgsessionmgr.h
  • src/coinjoin/server.h
  • src/llmq/quorums.h
  • contrib/containers/ci/ci-slim.Dockerfile
  • src/llmq/utils.cpp
  • src/bls/bls_worker.cpp
  • src/coinjoin/util.cpp
  • src/active/dkgsessionhandler.h
  • src/llmq/net_dkg.cpp
  • src/coinjoin/coinjoin.cpp
  • src/llmq/net_quorum.cpp
  • src/coinjoin/client.h
  • src/llmq/net_quorum.h
  • src/wallet/coinjoin.cpp
  • src/index/timestampindex.cpp
  • src/governance/superblock.h
  • src/active/context.h
  • src/governance/superblock.cpp
  • src/node/interfaces.cpp
  • src/wallet/bip39.cpp
  • src/index/addressindex_types.h
  • src/index/timestampindex.h
  • src/evo/providertx.cpp
  • src/evo/specialtxman.cpp
  • src/evo/deterministicmns.h
  • src/evo/core_write.cpp
  • src/stats/client.cpp
  • src/llmq/observer.h
  • src/llmq/params.h
  • src/coinjoin/server.cpp
  • src/rpc/coinjoin.cpp
  • src/governance/signing.cpp
  • src/llmq/core_write.cpp
  • src/llmq/dkgmessages.h
  • src/stacktraces.cpp
  • src/evo/netinfo.cpp
  • src/chainlock/signing.h
  • src/llmq/signing_shares.cpp
  • src/rpc/evo.cpp
  • src/instantsend/signing.cpp
  • src/util/ranges_set.h
  • src/llmq/debug.cpp
  • src/qt/clientfeeds.h
  • src/governance/net_governance.cpp
  • src/rpc/masternode.cpp
  • src/qt/donutchart.h
  • src/rpc/quorums.cpp
  • src/index/addressindex.cpp
  • src/test/util/llmq_tests.h
  • src/util/std23.h

Walkthrough

The pull request updates cppcheck tooling and suppressions, replaces manual loops with C++20 ranges algorithms, adds explicit default initialization, and marks overridden destructors. It also simplifies APIs by removing unused parameters, adding static and const qualifiers, changing unnecessary copies to references or moves, and updating governance, index, RPC, wallet, and UI call sites.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • dashpay/dash#7302: Both changes modify ProTx validation in src/evo/providertx.cpp.
  • dashpay/dash#7525: Both changes modify the timestamp-index API in src/index/timestampindex.cpp and src/index/timestampindex.h.
  • dashpay/dash#7539: Both changes modify AsyncSignIfMember and its signing-manager parameter.

Suggested reviewers: udjinm6

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.92% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: making lint-cppcheck-dash report cppcheck warnings.
Description check ✅ Passed The description directly explains the linter fixes, cppcheck upgrade, code changes, and validation performed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Aug 3, 2026

Copy link
Copy Markdown

🕓 Ready for review — 1 ahead in queue (commit 97e975e)
Queue position: 2/19 · 2 reviews active
ETA: start ~09:25 UTC · complete ~09:45 UTC (median 20m across 30 recent reviews; 2 slots)
Queued 3h 48m ago · Last checked: 2026-08-04 09:10 UTC

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 53576af0a1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +141 to +143
if re.search(fatal_regexp, line):
warnings.append(line)
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fail when cppcheck exits unsuccessfully

When cppcheck is killed (for example by OOM during the exhaustive parallel run) or encounters another failure whose output lacks these four strings, dependencies_output.returncode is ignored and warnings can remain empty, so the linter exits successfully without analyzing anything. This is the same vacuous-success mode the change intends to prevent; I reproduced it with a fake cppcheck that exits 137 with no output, for which this script returned 0. Treat any nonzero subprocess return code as a lint failure in addition to parsing fatal diagnostics.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

@PastaPastaPasta PastaPastaPasta changed the title fix(lint): make lint-cppcheck-dash actually report warnings fix(scripts): make lint-cppcheck-dash actually report warnings Aug 3, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preliminary review — Codex only

The cppcheck preprocessing fix, version upgrade, warning filtering, and associated warning cleanups appear sound. However, the linter still ignores cppcheck's process exit status, so analyzer failures outside the small recognized-message list can silently pass, contradicting the PR's goal of preventing vacuous analysis.

Validated blockers were found in the Codex precheck. Sonnet is deferred until a fresh Codex revalidation clears the blocker gate.

Review provenance

  • Codex reviewers: gpt-5.6-sol — general (completed), gpt-5.6-sol — dash-core-commit-history (completed)
  • Verifier: gpt-5.6-sol — verifier
  • Sonnet: not run (deferred by blocker gate)

🔴 1 blocking

1 additional finding(s) omitted (not in diff).

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `test/lint/lint-cppcheck-dash.py`:
- [BLOCKING] test/lint/lint-cppcheck-dash.py:132-137: Nonzero cppcheck exits still pass the lint
  The completed process's `returncode` is never checked. A top-level cppcheck failure that does not emit one of the four recognized `FATAL_ERRORS` strings—such as SIGKILL/OOM, an assertion with different wording, a configuration-loading failure, or an unsupported option—is filtered out and the script exits successfully when no recognized warnings remain. This was reproduced with a cppcheck shim that prints `cppcheck: error: failed to load configuration` and exits 2; the linter exits 0. Because ordinary cppcheck findings do not produce a nonzero status unless `--error-exitcode` is configured, failing on any nonzero status preserves the existing warning filtering while ensuring analyzer failures cannot silently pass.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Potential PR merge conflicts

This is advisory only. It does not block CI, but it marks PRs that will likely need a rebase depending on merge order.

If this PR merges first

These open PRs will likely need a rebase:

If these PRs merge first

This PR will likely need a rebase:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/rpc/blockchain.cpp`:
- Line 568: Update TimestampIndex::ReadRange and GetBlockHashes to return a
boolean success status, propagating pcursor->Status() failures instead of
silently using partial blockHashes. In the getblockhashes RPC flow around
g_timestampindex->GetBlockHashes, check the returned status and raise
RPC_MISC_ERROR before constructing the successful result.

In `@test/lint/lint-cppcheck-dash.py`:
- Around line 128-132: Update the diagnostic filter in the cppcheck parsing
logic to retain the supported non-noise severities: error, warning, style,
performance, and portability. Continue discarding information, note, and
source-context lines before suppression matching.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cdb36e58-3397-4802-b0c9-cff23cdeb7a0

📥 Commits

Reviewing files that changed from the base of the PR and between 0017f50 and d802b17.

📒 Files selected for processing (88)
  • contrib/containers/ci/ci-slim.Dockerfile
  • src/active/context.h
  • src/active/dkgsession.cpp
  • src/active/dkgsession.h
  • src/active/dkgsessionhandler.h
  • src/bench/bls_dkg.cpp
  • src/bls/bls.cpp
  • src/bls/bls.h
  • src/bls/bls_worker.cpp
  • src/chainlock/chainlock.h
  • src/chainlock/signing.cpp
  • src/chainlock/signing.h
  • src/coinjoin/client.cpp
  • src/coinjoin/client.h
  • src/coinjoin/coinjoin.cpp
  • src/coinjoin/coinjoin.h
  • src/coinjoin/common.h
  • src/coinjoin/server.cpp
  • src/coinjoin/server.h
  • src/coinjoin/util.cpp
  • src/coinjoin/util.h
  • src/coinjoin/walletman.cpp
  • src/evo/core_write.cpp
  • src/evo/deterministicmns.cpp
  • src/evo/deterministicmns.h
  • src/evo/dmn_types.h
  • src/evo/mnhftx.h
  • src/evo/netinfo.cpp
  • src/evo/netinfo.h
  • src/evo/providertx.cpp
  • src/evo/simplifiedmns.cpp
  • src/evo/smldiff.cpp
  • src/evo/specialtxman.cpp
  • src/governance/governance.cpp
  • src/governance/governance.h
  • src/governance/net_governance.cpp
  • src/governance/signing.cpp
  • src/governance/superblock.cpp
  • src/governance/superblock.h
  • src/index/addressindex.cpp
  • src/index/addressindex.h
  • src/index/addressindex_types.h
  • src/index/timestampindex.cpp
  • src/index/timestampindex.h
  • src/init.cpp
  • src/instantsend/instantsend.h
  • src/instantsend/signing.cpp
  • src/instantsend/signing.h
  • src/llmq/commitment.cpp
  • src/llmq/core_write.cpp
  • src/llmq/debug.cpp
  • src/llmq/dkgmessages.h
  • src/llmq/dkgsessionmgr.h
  • src/llmq/ehf_signals.h
  • src/llmq/net_dkg.cpp
  • src/llmq/net_dkg.h
  • src/llmq/net_quorum.cpp
  • src/llmq/net_quorum.h
  • src/llmq/net_signing.cpp
  • src/llmq/observer.h
  • src/llmq/params.h
  • src/llmq/quorums.h
  • src/llmq/signing_shares.cpp
  • src/llmq/signing_shares.h
  • src/llmq/snapshot.h
  • src/llmq/utils.cpp
  • src/masternode/meta.h
  • src/node/interfaces.cpp
  • src/qt/clientfeeds.h
  • src/qt/donutchart.h
  • src/rpc/blockchain.cpp
  • src/rpc/coinjoin.cpp
  • src/rpc/evo.cpp
  • src/rpc/governance.cpp
  • src/rpc/masternode.cpp
  • src/rpc/quorums.cpp
  • src/stacktraces.cpp
  • src/stats/client.cpp
  • src/test/evo_netinfo_tests.cpp
  • src/test/util/llmq_tests.h
  • src/util/ranges_set.cpp
  • src/util/ranges_set.h
  • src/util/std23.h
  • src/wallet/bip39.cpp
  • src/wallet/coinjoin.cpp
  • src/wallet/hdchain.cpp
  • src/wallet/hdchain.h
  • test/lint/lint-cppcheck-dash.py
💤 Files with no reviewable changes (2)
  • src/governance/net_governance.cpp
  • src/active/dkgsession.cpp

Comment thread src/rpc/blockchain.cpp
if (!g_timestampindex->GetBlockHashes(high, low, blockHashes)) {
throw JSONRPCError(RPC_MISC_ERROR, "Failed to read timestamp index.");
}
g_timestampindex->GetBlockHashes(high, low, blockHashes);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 12 --glob '*.{cpp,h}' '\bGetBlockHashes\s*\(' src

Repository: dashpay/dash

Length of output: 3913


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '--- candidate files ---\n'
git ls-files src/index src/rpc | rg '(^src/index/(.*db.*|db|timestamp)|^src/rpc/blockchain\.cpp$)' || true

printf '\n--- timestamp index db declarations/usages ---\n'
rg -n -C 8 'class .*DB|struct .*DB|ReadRange|WriteRange|GetRange|ReadTimestampIndex|CTimestampIndexKey|TimestampIndex' src/index src/common src --iglob '*.{cpp,h}'

printf '\n--- read index db file outline ---\n'
ast-grep outline src/index/db.cpp --view expanded 2>/dev/null || true

printf '\n--- relevant timestamp/read range slices ---\n'
sed -n '1,180p' src/index/db.cpp
sed -n '1,160p' src/index/timestampindex.cpp

Repository: dashpay/dash

Length of output: 241


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- candidate files ---'
git ls-files src/index src/rpc | rg '(^src/index/(.*db.*|db|timestamp)|^src/rpc/blockchain\.cpp$)' || true

printf '%s\n' ''
printf '%s\n' '--- timestamp index db declarations/usages ---'
rg -n -C 8 'class .*DB|struct .*DB|ReadRange|WriteRange|GetRange|ReadTimestampIndex|CTimestampIndexKey|TimestampIndex' src/index src/common src --iglob '*.{cpp,h}' || true

printf '%s\n' ''
printf '%s\n' '--- relevant timestamp/read range slices ---'
sed -n '1,180p' src/index/db.cpp
sed -n '1,160p' src/index/timestampindex.cpp

Repository: dashpay/dash

Length of output: 50369


Handle timestamp-index read errors in getblockhashes.

TimestampIndex::ReadRange() ignores pcursor->Status() failures, and GetBlockHashes() passes that void result back to the RPC. A database read error can still build a successful JSON response from partial blockHashes; add a bool return from the read APIs and return the read-failure RPC_MISC_ERROR before constructing result.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/rpc/blockchain.cpp` at line 568, Update TimestampIndex::ReadRange and
GetBlockHashes to return a boolean success status, propagating pcursor->Status()
failures instead of silently using partial blockHashes. In the getblockhashes
RPC flow around g_timestampindex->GetBlockHashes, check the returned status and
raise RPC_MISC_ERROR before constructing the successful result.

Comment on lines +128 to +132
# 'note:' and source-context lines only make sense next to their parent
# warning; on their own (e.g. when the parent is suppressed) they are
# noise, and they don't carry the check id the suppressions match on.
if ' warning: ' not in line and ' error: ' not in line:
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Locate lint-cppcheck-dash.py"
fd -a 'lint-cppcheck-dash.py' .

echo
echo "Relevant file excerpt"
if [ -f test/lint/lint-cppcheck-dash.py ]; then
  nl -ba test/lint/lint-cppcheck-dash.py | sed -n '1,220p'
fi

echo
echo "Search for cppcheck/GCC and suppression handling symbols"
rg -n "cppcheck|ALWAYS_ENABLED_WARNINGS|SUPPRESSED_WARNINGS|GCC|style|performance|portability|note:" test/lint/lint-cppcheck-dash.py src test -S || true

echo
echo "Check for cppcheck canary/fixtures/tests"
rg -n "cppcheck-dash|lint-cppcheck|cppcheck" test/lint/LintRunner.py test/lint test .github ci 2>/dev/null || true

Repository: dashpay/dash

Length of output: 294


🌐 Web query:

Cppcheck report output GCC format information warning error style performance portability note severity

💡 Result:

To generate GCC-compatible report output in Cppcheck, you should use the --template=gcc flag [1][2]. This formats the error messages to match the standard GCC diagnostic output format [1][2]. Cppcheck categorizes findings into specific severity levels, which can be identified in reports [3][4]: 1. Error: Indicates a severe issue, such as a memory leak or other certain programming error [3][4]. 2. Warning: Used for dangerous coding patterns that may lead to runtime errors (e.g., uninitialized member variables) [3][4]. 3. Style: General recommendations for code cleanup, such as redundant or unreachable code; these improve maintainability rather than fixing bugs [3][4]. 4. Performance: Suggests suboptimal code that, if corrected, may result in better performance [3][4]. 5. Portability: Highlights code that is not portable across different platforms or bitnesses (e.g., 32-bit vs. 64-bit systems) [3][4]. 6. Information: Informational messages about the checking process itself, such as missing header files [3][4]. 7. Debug: Messages intended for developer use [4]. You can suppress specific warnings using the --suppress flag, which follows the format [error id]:[filename]:[line] [5][6]. The warning ID is typically found in square brackets at the end of the error message provided by Cppcheck (e.g., [arrayIndexOutOfBounds]) [1][7]. Alternatively, you can use inline suppressions by placing // cppcheck-suppress warningId above the relevant code line [7].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Relevant file excerpt"
awk '{printf "%6d  %s\n", NR, $0}' test/lint/lint-cppcheck-dash.py | sed -n '1,260p'

echo
echo "Search for cppcheck handling symbols"
grep -RInE "cppcheck|ALWAYS_ENABLED_WARNINGS|SUPPRESSED_WARNINGS|GCC|style|performance|portability|information|note" test/lint/lint-cppcheck-dash.py test/lint test .github ci README.md 2>/dev/null || true

echo
echo "Behavioral probe of current line-filtering slice"
python3 - <<'PY'
from pathlib import Path
src = Path('test/lint/lint-cppcheck-dash.py').read_text()
idx = src.find("if ' warning: ' not in line and ' error: ' not in line:")
print("current_guard_find", idx)
for severity in ["error:", "warning:", "style:", "performance:", "portability:", "information:", "note:"]:
    line = f"{__file__}:123: {severity} message [undefMacro]"
    print(severity, bool(" warning: " in line or " error: " in line))
PY

echo
echo "Check installed cppcheck availability/version"
if command -v cppcheck >/dev/null 2>&1; then
  cppcheck --version || true
else
  echo "cppcheck not installed"
fi

Repository: dashpay/dash

Length of output: 20273


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Build a minimal C++ file emitting different cppcheck GCC severities"
tmpdir="$(mktemp -d)"
cat > "$tmpdir/test.cpp" <<'CPP'
// cppcheck:style:Redundant initialization.
char redundantInitialized = 0;

// cppcheck:performance:Use of unary operator not needed.
void unary() {
    int x = +1;
}

// cppcheck:portability:Bit shift operand has undefined behavior.
void shift() {
    unsigned u = 1;
    volatile unsigned r = u << 32;
}

// cppcheck:information:Missing preprocessor directive explanation.
int missingInclude;

void noteParent() {
    int *p = nullptr;
    // cppcheck-suppress nullPointerRedundantCheck
    *p = 1; // cppcheck:note:pointer p might be null.
}
CPP

echo
echo "cppcheck output"
cppcheck --version
cppcheck --enable=all --style --performance --portability --information --inline-suppr --template=gcc -I "$tmpdir" "$tmpdir/test.cpp" 2>&1 || true

echo
echo "Filter simulation"
python3 - <<'PY'
out = """
/home/jailuser/git/test.cpp:1:5: style: Redundant initialization. The variable 'redundantInitialized' is assigned a value that is never used. [redu ndantNextlineCheck]
/home/jailuser/git/test.cpp:6:5: performance: Unary operator '+' is redundant.
/home/jailuser/git/test.cpp:11:15: portability: Bit shift operand has undefined behavior.
/home/jailuser/git/test.cpp:16:1: information: Missing include header explanation.
/home/jailuser/git/test.cpp:22:5: note: pointer p might be null.
"""
for line in out.strip().splitlines():
    print(repr(line), bool(" warning: " in line or " error: " in line))
PY

Repository: dashpay/dash

Length of output: 857


🌐 Web query:

Cppcheck 2.21 --template=gcc output format style warning information severity line

💡 Result:

When using Cppcheck with the --template=gcc option, the output follows a format compatible with GCC compiler messages, which is designed for integration with build systems and IDEs [1][2][3]. The output format generated by --template=gcc is: {file}:{line}:{column}: {severity}: {message} [{id}] For example, a typical output line looks like this: samples/arrayIndexOutOfBounds/bad.c:6:6: warning: Array 'a[2]' accessed at index 2, which is out of bounds. [arrayIndexOutOfBounds] Key components of this format include: - {file}: The path to the source file where the issue was detected [2]. - {line}: The line number where the issue occurs [2]. - {column}: The column number within the line [2]. - {severity}: The classification of the finding (e.g., warning, error, style, performance, portability, or information) [2]. - {message}: The descriptive text explaining the detected issue [2]. - {id}: The unique identifier (warning ID) for the specific check [2]. This predefined template provides a standard, machine-parsable structure [3]. If you require a custom format, you can define your own template using the --template option with supported specifiers such as {file}, {line}, {column}, {severity}, {message}, and {id} [2][3].

Citations:


🌐 Web query:

Cppcheck 2.21 --errorlist style performance portability information available command line options

💡 Result:

In Cppcheck 2.21, the categories style, performance, portability, and information are defined as severity levels for diagnostic messages [1][2]. These can be enabled or disabled via command-line options [3][4]. Severities Overview: - style: Used for stylistic issues such as redundant code, unused functions, operator precedence, and constness [1][5]. - performance: Used for runtime performance suggestions based on general knowledge; fixing these does not guarantee measurable speed improvements [1][5]. - portability: Used for implementation-defined behavior, 64-bit portability issues, and certain types of undefined behavior that may work as intended on specific platforms [1][5]. - information: Used for configuration problems that do not relate to the syntactical correctness of the code but indicate that the Cppcheck configuration could be improved [1][2]. Command-Line Options: - --enable=: Enables additional checks. You can enable these categories individually or in combination (e.g., --enable=style,performance) [3][4]. - --enable=style: This specific option enables all coding style checks, which includes messages with the severities 'style', 'performance', and 'portability' [3][4]. - --errorlist: Prints a list of all possible error messages in XML format to the console [6][3][7]. This is the authoritative command for identifying all checks available in your installed version of Cppcheck [6]. For output formatting, the --template option allows you to define custom message formats using placeholders such as {severity}, {message}, {file}, and {line} [1][2][3]. For example, --template='{file}:{line},{severity},{id},{message}' can be used to structure the report [3]. When --xml is used, these severity levels are included as attributes in the XML output [1][2].

Citations:


Keep valid non-noise cppcheck diagnostic severities.

The script runs cppcheck --enable=all --template=gcc, whose GCC-formatted diagnostics use severities such as error, warning, style, performance, portability, and information. The current filter leaves only warning and error, so style, performance, portability, and information findings are discarded before suppression checking. Match the supported non-noise severities explicitly, and continue discarding only information, note, and source-context lines.

🧰 Tools
🪛 ast-grep (0.45.0)

[warning] 132-132: Regex pattern passed to re is built from a non-literal (variable, call, concatenation, or f-string) value. If that value is attacker-controlled it can introduce a malicious pattern with catastrophic backtracking (ReDoS). Use a hardcoded literal pattern, or validate/escape untrusted input with re.escape() and bound the regex complexity before compiling.
Context: re.search(files_regexp, line)
Note: [CWE-1333] Inefficient Regular Expression Complexity.

(redos-non-literal-regex-python)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/lint/lint-cppcheck-dash.py` around lines 128 - 132, Update the
diagnostic filter in the cppcheck parsing logic to retain the supported
non-noise severities: error, warning, style, performance, and portability.
Continue discarding information, note, and source-context lines before
suppression matching.

@PastaPastaPasta
PastaPastaPasta force-pushed the claude/mystifying-gauss-adccbd branch from d802b17 to b44f9e3 Compare August 3, 2026 21:45

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b44f9e3217

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# These must always fail the lint (regardless of which file they point at),
# otherwise analysis silently ends up vacuous.
FATAL_ERRORS = (
"preprocessorErrorDirective",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat parser syntax errors as fatal

When cppcheck aborts a translation unit with an error such as src/validation.h:...: error: syntax error [syntaxError], this list does not classify it as fatal, and the later file filter discards it because the included header is outside non-backported.txt. The linter can therefore pass after cppcheck skipped analysis of one or more targeted files; include syntaxError and other analysis-abort diagnostics in the path-independent fatal set.

AGENTS.md reference: AGENTS.md:L48-L50

Useful? React with 👍 / 👎.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preliminary review — Codex only

Two in-scope blockers remain at exact head b44f9e3. PF-1 is still valid because cppcheck's process status is ignored; separately, the latest suppression burn-down re-enables useStlAlgorithm while the diagnostic filter discards its style-severity output, so the check is not actually enforced.

Validated blockers were found in the Codex precheck. Sonnet is deferred until a fresh Codex revalidation clears the blocker gate.

Review provenance

  • Codex reviewers: gpt-5.6-sol — general (completed), gpt-5.6-sol — dash-core-commit-history (completed)
  • Verifier: gpt-5.6-sol — verifier
  • Sonnet: not run (deferred by blocker gate)

🔴 2 blocking

1 additional finding(s) omitted (not in diff).

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `test/lint/lint-cppcheck-dash.py`:
- [BLOCKING] test/lint/lint-cppcheck-dash.py:122-127: Nonzero cppcheck exits still pass the lint
  The completed process is captured, but dependencies_output.returncode is never inspected. FATAL_ERRORS only catches four textual markers, so a command-line/configuration failure, crash, OOM termination, or other unsuccessful cppcheck exit can produce no retained warning and let the script exit successfully without completing analysis. This reproduces on the current head with a cppcheck shim that exits 2 after version detection: lint-cppcheck-dash.py exits 0. Because the command does not use --error-exitcode, ordinary diagnostics do not make cppcheck return nonzero, so every nonzero process status can safely be treated as an analyzer failure.
- [BLOCKING] test/lint/lint-cppcheck-dash.py:134-138: The diagnostic filter discards cppcheck style findings
  The GCC-formatted output filter retains only error and warning severities. Cppcheck classifies both unreadVariable and the useStlAlgorithm check re-enabled by the head commit as style, so these diagnostics are discarded before the allowlist and suppression logic runs. A current-head shim emitting a style-severity unreadVariable diagnostic for a targeted file makes the script exit 0, and cppcheck's error list confirms that useStlAlgorithm and unreadVariable have style severity. Performance and portability findings enabled by --enable=all are also silently discarded.

Comment on lines +134 to +138
# 'note:' and source-context lines only make sense next to their parent
# warning; on their own (e.g. when the parent is suppressed) they are
# noise, and they don't carry the check id the suppressions match on.
if ' warning: ' not in line and ' error: ' not in line:
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking: The diagnostic filter discards cppcheck style findings

The GCC-formatted output filter retains only error and warning severities. Cppcheck classifies both unreadVariable and the useStlAlgorithm check re-enabled by the head commit as style, so these diagnostics are discarded before the allowlist and suppression logic runs. A current-head shim emitting a style-severity unreadVariable diagnostic for a targeted file makes the script exit 0, and cppcheck's error list confirms that useStlAlgorithm and unreadVariable have style severity. Performance and portability findings enabled by --enable=all are also silently discarded.

Suggested change
# 'note:' and source-context lines only make sense next to their parent
# warning; on their own (e.g. when the parent is suppressed) they are
# noise, and they don't carry the check id the suppressions match on.
if ' warning: ' not in line and ' error: ' not in line:
continue
# Keep primary diagnostics while discarding information, notes, and source context.
if not re.search(r' (?:error|warning|style|performance|portability): ', line):
continue

source: ['codex']

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

The cppcheck linter has been silently analyzing nothing (see next commit), letting several warnings in non-backported files accumulate. Fix the ones that the linter's ALWAYS_ENABLED_WARNINGS patterns force-report: remove unused/dead locals, make single-argument constructors explicit (with an inline suppression for CBLSIdImplicit, whose implicit conversion is intentional), narrow benchmark counters to the scope they are used in, pass CSigBase and BlsCheck constructor arguments by reference/move, and inline-suppress a danglingTempReference false positive on a lifetime-extended range-for temporary.
The linter has been vacuous in two ways. First, without __GNUC__ defined, src/attributes.h hits '#error No known always_inline attribute', which aborts cppcheck's analysis of nearly every translation unit; the resulting preprocessorErrorDirective lines were then dropped by the output filter because they don't point at files from non-backported.txt. Second, even with preprocessing fixed, cppcheck 2.17.1 crashes with an assertion in TokenList::setLang under --check-level=exhaustive, and that crash was explicitly suppressed.

Define __GNUC__ so preprocessing succeeds, bump cppcheck to 2.21.0 (which no longer crashes with exhaustive checking) and drop the crash suppression, and treat analysis failures (preprocessorErrorDirective, internal errors) as lint failures regardless of which file they point at so the linter can never silently go vacuous again. Filter out 'note:'/source-context lines, which don't carry the check id that suppressions match on and would leak through when their parent warning is suppressed. Finally, suppress the check ids with pre-existing violations in the tree so the linter can be enforced; these should be burned down and re-enabled over time.
@PastaPastaPasta
PastaPastaPasta force-pushed the claude/mystifying-gauss-adccbd branch from b44f9e3 to 97e975e Compare August 4, 2026 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants