Repository navigation
Conversation
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
I found one new bug. In the code view of the Explorer report, the tooltips on the gutter markers show escaped HTML markup as literal text. addMark() assigns the result of tipHtml() straight to i.dataset.tip, but tipHtml() escapes its output a second time so it can go inside an HTML attribute. The browser only removes that second escaping when it parses an attribute in HTML source. A value set through dataset keeps it, so tip.innerHTML = el.dataset.tip displays <div class="tt-title">Line 1</div>… instead of a formatted tooltip. The other data-tip users build HTML markup, so they are not affected.
The Python side (parsing, baseline, history, metrics, products) and the htmlreport → reports/htmlreport move worked in my tests. I found no other problems.
Comments
| # | Comment | By | Where | Status |
|---|---|---|---|---|
| 1 | Gutter marker tooltip shows escaped HTML markup as literal text | AI review | reports/explorer/report.py:2541 |
🆕 New |
@danmar, please fix, resolve or reply to the open and new comments: #1.
Testing
What I built and ran
- Built
cppcheckinpr/(make -j8 cppcheck). It built without problems. The PR changes no C++ checker code, only a string in dmake, so I did not build or run testrunner. - Ran
test/tools/htmlreport/test_htmlreport.py. All 8 tests fail in this container withModuleNotFoundError: No module named 'pygments', which is a missing dependency here, not a fault of the PR. They also fail in base for the same reason. The traceback shows that the script was found at its new pathreports/htmlreport/cppcheck-htmlreport. - Searched the tree with grep and found no leftover references to the old
htmlreport/path.
Scenarios I ran reports/explorer/report.py on (cppcheck XML from small C files in src/core and src/net):
- Plain report: the output contains
index.html,report.css,report.js,data/results.jsanddata/src/{0,1}.js. Products were guessed asCoreandNet.node --check report.jsreports no syntax errors. --history histand--baseline res.xml --history hist: the new, fixed and trend counts were as expected (10 warnings, 2 new, 0 fixed, 3 reports in trend). The baseline without a date was put after the dated history file.- Hand-written v3 XML with metrics:
HISVOCFcame out as 10/3 = 3.33 andHISCOMFas 0.0, anddata/metrics.jswas correct.
Gutter tooltip bug
I reproduced it in node, using esc/tipHtml copied from report.js (the tipHtml copy is simplified: it leaves out the colour dot):
node -e "const esc=...; const tipHtml=...; console.log(tipHtml('Line 1', [[null,'uninitvar','error']]))"
<div class="tt-title">Line 1</div><div class="tt-row">uninitvar<b>error</b></div>
addMark() stores this string through dataset, so it reaches tip.innerHTML unchanged and the user sees the markup as text. There is no browser in the container, so I could not check this visually. The effect follows from how dataset and innerHTML work.
Automated review of 422f17c by Claude. The pull request was built and tested locally.
|
Test results for commit 422f17c (tools/test-my-pr.py, main compared to this PR): Test: http://ec2-51-20-36-10.eu-north-1.compute.amazonaws.com/pr-9100/ Posted automatically by the cppcheck PR test runner. +N: warnings only with this PR, -N: warnings only with main. The AI review is written by Claude and can be wrong. |
…script The gutter marker tooltip in the code view showed raw markup because tipHtml() output (escaped for a data-tip attribute) was assigned to el.dataset.tip. Add tipInner() for that case. Move the DOM-free javascript helpers into JS_LIB so they can be unit tested with node's built-in test runner, and add a pytest wrapper that runs the tests and syntax checks the generated report.js. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…into fix-15295 # Conflicts: # .github/workflows/scriptcheck.yml
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
The gutter tooltip problem from the earlier review is fixed: addMark() now uses tipInner(). I found two new problems, both small:
- Wrong code highlighting at chunk boundaries. The code view works out where block comments start and stop in two places, and they disagree.
scanBlock()treats every'as the start of a character literal. That includes C++14 digit separators (1'000) and quotes inside#include <...>/#errorlines.hl()handles these cases correctly, so on such a linescanBlock()misses a/*thathl()sees. The code is drawn in chunks of 250 lines. If a block comment that opens on such a line is still open at a chunk boundary, the next chunk starts with the wrong comment state and is highlighted wrongly. checkersReportalways shows as new + fixed when its text changes. Warnings without a hash, such ascheckersReport, are matched on id, message and file. Its message changes between XML v2 and v3, and also when the number of checkers changes, for example after a cppcheck upgrade. The baseline comparison then counts it as 1 new and 1 fixed warning.
Also, the scriptcheck workflow's pylint and py_compile steps don't include reports/explorer/report.py.
Comments
| # | Comment | By | Where | Status |
|---|---|---|---|---|
| 1 | Gutter marker tooltip shows escaped HTML markup as literal text | AI review | reports/explorer/report.py:2541 |
✅ Fixed |
| 2 | scanBlock treats digit separators/include quotes as char literals, disagrees with hl() | AI review | reports/explorer/report.py:1473 |
🆕 New |
| 3 | checkersReport (no hash) shows as new+fixed when its message changes | AI review | reports/explorer/report.py:186 |
🆕 New |
| 4 | reports/explorer/report.py is not linted / py_compiled in CI | AI review | .github/workflows/scriptcheck.yml:112 |
🆕 New (false negative) |
@danmar, please fix, resolve or reply to the open and new comments: #2, #3, #4.
For #4 (false negative), it is enough to create a Trac ticket and link it here. It does not need to be fixed in this PR.
Testing
Built and ran
- Built
cppcheckinpr/withmake -j8 cppcheck; it built cleanly. The only C++ change in the PR is a string in dmake, so I did not run testrunner. python3 -m pytest test/tools/explorer/explorer_js_test.py: 2 passed. The container has node.test/tools/htmlreportwas not run: thepygmentsmodule is missing in the container.- I generated XML with the PR's cppcheck from a small
src/core,src/netproject, as v2 and as v3 with--enable=all. Then I ranreports/explorer/report.pywith a plain report and with--baseline. Both worked, the products came out as Core and Net, andnode --checkfound no syntax errors in the generatedresults.js. - I grepped for leftover references to the old
htmlreport/path and found none.
Problem 1: block comment state differs between scanBlock and hl (/work/scratch/t.js; lib.js is JS_LIB from report.py with module.exports=CppcheckExplorer; added)
const {scanBlock, hl} = require('./lib.js');
const cases = ["int x = 1'000; /* start of comment", "char c = 'a'; /* x", "#include <a'b> /* x"];
for (const l of cases) { const st={block:false}; hl(l, st); console.log(JSON.stringify(l), 'scanBlock:', scanBlock(l,false), 'hl:', st.block); }$ node t.js
"int x = 1'000; /* start of comment" scanBlock: false hl: true
"char c = 'a'; /* x" scanBlock: true hl: true
"#include <a'b> /* x" scanBlock: false hl: true
buildView() uses scanBlock to compute the comment state at the start of each 250-line chunk. So when a comment like the first one is still open at a chunk boundary, the next chunk is highlighted as code instead of as a comment.
Problem 2: checkersReport counted as new and fixed
cd proj; cppcheck --enable=all --xml src 2> ../r.xml; cppcheck --enable=all --xml-version=3 src 2> ../r3.xml; cd ..
python3 reports/explorer/report.py r3.xml --baseline r.xml --source-dir proj -o out2
Wrote out2/index.html (11 warnings, 1 new, 1 fixed, 2 reports in trend)
The two files contain the same warnings. The only difference is the checkersReport message: Active checkers: 176/189 (use --checkers-report=<filename> to see details) in v2 against Active checkers: 176/189 in v3. The number in that message also changes when cppcheck adds checkers.
Automated review of 38f6275 by Claude. The pull request was built and tested locally.
| const d = line.charCodeAt(i + 1); | ||
| if (d === 47) return false; | ||
| if (d === 42) { block = true; i += 2; continue; } | ||
| } else if (c === 34 || c === 39) { |
There was a problem hiding this comment.
AI review
scanBlock() treats every ' as the start of a character literal, but hl() lexes 1'000 as a number and #include <a'b> as a header name. So on a line like int x = 1'000; /* comment scanBlock() returns false while hl() sets st.block = true. buildView() uses scanBlock for the comment state at the start of each 250-line chunk. If such a comment is still open at a chunk boundary, the next chunk is highlighted as code.
node: scanBlock("int x = 1'000; /* start of comment", false) -> false, hl(...) leaves st.block = true
A simple fix is to compute the chunk state with the same code that renders, for example by running hl(line, st) and using st.block, or by giving scanBlock the same number and preprocessor rules as hl().
| return 'h:' + r['hash'] | ||
| # No hash (e.g. missingInclude). Use a key that does not depend on line numbers. | ||
| files = '|'.join(loc['file'] for loc in r['locations']) | ||
| return 'k:%s|%s|%s' % (r['id'], r['msg'], files) |
There was a problem hiding this comment.
AI review
Warnings without a hash are matched on id|msg|files. checkersReport has no hash, and its message changes between XML v2 and v3 (... (use --checkers-report=<filename> to see details)). It also changes whenever the number of checkers changes, for example after a cppcheck upgrade. Comparing a v3 report with a v2 baseline of the same code gives 1 new, 1 fixed, and the dashboard counts it as a new information warning. Consider ignoring the message for checkersReport, or leaving it out of the new/fixed comparison.
| run: | | ||
| shopt -s globstar | ||
| pylint --jobs $(nproc) --py-version 3.7 addons/**/*.py htmlreport/cppcheck-htmlreport htmlreport/**/*.py test/**/*.py tools/**/*.py | ||
| pylint --jobs $(nproc) --py-version 3.7 addons/**/*.py reports/htmlreport/cppcheck-htmlreport reports/htmlreport/**/*.py test/**/*.py tools/**/*.py |
There was a problem hiding this comment.
AI review
The pylint and py_compile steps (lines 112 and 128–129) cover only reports/htmlreport/**, so the new reports/explorer/report.py is never linted or compiled with --py-version 3.7. Using reports/**/*.py instead would cover both.
No description provided.