Repository navigation
Fix #15295 (report : new html-report with dashboard) #9100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
danmar
wants to merge
4
commits into
cppcheck-opensource:main
Choose a base branch
from
cppchecksolutions:fix-15295
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,485
−30
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
70909e7
Fix #15295 (report : new html-report with dashboard)
dmcppcheck 422f17c
manual
dmcppcheck c7d9c0f
explorer: fix gutter marker tooltip and add tests for the report java…
dmcppcheck 38f6275
Merge branch 'main' of https://github.com/cppcheck-opensource/cppchec…
dmcppcheck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
|
|
||
| # Report | ||
|
|
||
| ## Overview | ||
|
|
||
| This folder contains a script report.py that converts a cppcheck xml report into a html report. | ||
|
|
||
| Only the python standard libraries are used. No extra dependencies shall be needed. | ||
|
|
||
| The html report is interactive, there are toggle buttons and stuff. | ||
|
|
||
| ## Performance | ||
|
|
||
| Very important. The report needs to be responsive for large projects with thousands of warnings. It's preferable that multiple files are created instead of a single HTML that contains everything. | ||
|
|
||
| ## Themes | ||
|
|
||
| There will be different themes. light/dark/etc | ||
|
|
||
| ## Dashboard | ||
|
|
||
| A dashboard shows an overview of warnings. The dashboard is designed for a team-leader that wants to see status. The dashboard should primarily present information in graphs. | ||
|
|
||
| ### Sections | ||
|
|
||
| - Executive summary: A text summary. Green/Red Badge if there are undefined behavior. A Green/red badge if there are security/safety issues (misra/cert). The badge is gray if misra/cert was not checked. | ||
| - Product filter strip: Buttons per "product". Products are guessed from the directory (src/core/ becomes "Core"), or set with --product-map. Clicking one filters the whole dashboard. Hide this if all source files are in the same folder. | ||
| - If several reports are provided we can show trend graphs. | ||
| - Show graphs both for "new" warnings and "all" warnings. | ||
| - 5 KPI tiles: Errors, warnings, style+perf+portability, total and affected files, with "+N vs previous". | ||
| - Quality trend over time: Line chart of total/errors/warnings across snapshots (--history DIR or --snapshot). With "new" warnings selected it shows the new warnings in each report, compared with the report before. Hide this if there is only 1 result file. | ||
| - Warnings by product: Bar chart. Hide this if there is only one product, or if a product is selected. | ||
| - Risk domain breakdown: Bar chart of IDs grouped into made-up groups ("Memory & Crash Safety", "Security", "Maintainability"…) by keyword matching or by CWE. | ||
| - If there are metrics then show some summary about that. | ||
|
|
||
| ## Result details | ||
|
|
||
| There is a result details view. All results are shown here. It's possible to toggle different warnings severities. It's possible to toggle IDs. | ||
|
|
||
| All warnings are shown in a list and if a warning is clicked the related code is shown in a tab. | ||
|
|
||
| ## Metrics | ||
|
|
||
| If there are metrics, a metrics report. | ||
|
|
||
| # Baseline : New and old warnings | ||
|
|
||
| Each warning has a hash in the xml report, if old baseline report(s) are provided then those warnings are "old". A warning in a new report is "new" if its hash does not match any baseline warning. | ||
|
|
||
| It should be indicated in the dashboard how many new/old warnings there are. It should be possible to see if warnings are new in the results view and it should be possible to hide old warnings. | ||
|
|
||
| ## Classification/guideline mode (MISRA, CERT, Cppcheck Premium) | ||
|
|
||
| When the XML has classification attributes, the report switches to a different mode: | ||
|
|
||
| - In the results list the severity is replaced by Classification and Guideline columns. Click on a column header to sort. | ||
| - A filter bar for Mandatory, Required, Advisory, Document, Disapplied and L1/L2/L3 replaces the severity filter. Classifications that are not used in the report are disabled. | ||
| - The dashboard graphs and KPI tiles use the classification instead of the severity, and there is a graph of the most violated guidelines. | ||
| - The severity is still shown in the warning details. | ||
|
|
||
|
|
||
| # Usage | ||
|
|
||
| cppcheck --xml ... 2> results.xml | ||
| python3 report.py results.xml -o cppcheck-report | ||
|
|
||
| # mark new/old warnings by comparing with a previous report | ||
| python3 report.py results.xml --baseline old-results.xml -o cppcheck-report | ||
|
|
||
| # trend graphs: older reports in a directory (results-2026-05-01.xml, ...) | ||
| python3 report.py results.xml --history history -o cppcheck-report | ||
|
|
||
| # metrics (Cppcheck Premium) | ||
| cppcheck --premium=metrics --xml-version=3 ... 2> results.xml | ||
| python3 report.py results.xml -o cppcheck-report | ||
|
|
||
| Then open `cppcheck-report/index.html` in a browser. | ||
|
|
||
| Options: | ||
|
|
||
| * `-o DIR`, `--output-dir DIR` directory where the report is written (default: cppcheck-report) | ||
| * `--xml FILE` xml report (xml files can also be given as positional arguments) | ||
| * `--baseline FILE` baseline xml report, warnings that are not in the baseline are new (can be given several times). `--old` is an alias. If it is not given, the newest `--history`/`--snapshot` report is used. | ||
| * `--history DIR` directory with older xml reports for the trend graphs. They are ordered by the date in the file name (`results-2026-05-01.xml`), or by file time. | ||
| * `--snapshot FILE` older xml report for the trend graphs (can be given several times, oldest first) | ||
| * `--product-map FILE` json file that maps path prefixes to product names: `{"src/core": "Core", "lib/net": "Network"}`. Without it, products are guessed from the first directory below the common source directory (`src/core/x.cpp` becomes "Core"). | ||
| * `--metrics-thresholds FILE` json file with metric thresholds, overrides the defaults: `{"cyclomaticComplexity": {"max": 15}, "HISCOMF": {"min": 10}}` | ||
| * `--source-dir DIR` where the source files are located (can be given several times). By default the current directory and the directories of the xml files are searched. | ||
| * `--source-encoding ENCODING` encoding of the source files (default: utf-8) | ||
| * `--title TITLE` report title | ||
| * `--theme THEME` default theme: light, apple, microsoft, dark, midnight, solarized (the viewer can switch theme in the report) | ||
|
|
||
| ## Report directory | ||
|
|
||
| index.html open this in a browser | ||
| report.css | ||
| report.js | ||
| data/results.js all warnings, trend data | ||
| data/metrics.js metrics (if the xml has metrics), loaded when needed | ||
| data/src/<n>.js source code, one file per source file, loaded when it is shown | ||
|
|
||
| The report works directly from the file system (no web server needed). Copy the whole directory to share it. | ||
|
|
||
| ## Combining several XML files | ||
|
|
||
| Multiple xml files can be provided: `--xml file1.xml --xml file2.xml`. Duplicate warnings (same hash and location) are only shown once. | ||
|
|
||
| ## Metric thresholds | ||
|
|
||
| The default thresholds are the HIS limits (same as Cppcheck Premium `HISReport.py`): | ||
|
|
||
| | Metric | Id | Threshold | | ||
| |---|---|---| | ||
| | Cyclomatic complexity v(G) | cyclomaticComplexity | max 10 | | ||
| | Statements STMT | HISStmt | max 50 | | ||
| | Execution paths PATH | HISPath | max 80 | | ||
| | Nesting depth LEVEL | HISLevel | max 4 | | ||
| | Called functions CALLS | HISCall | max 7 | | ||
| | Calling functions CALLING | HISCalling | max 5 | | ||
| | Parameters PARAM | HISParam | max 5 | | ||
| | Return points RETURN | HISReturn | max 1 | | ||
| | Goto statements GOTO | HISGoto | max 0 | | ||
| | Language scope VOCF | HISVOCF | max 4 (computed from HISVocf_N / HISVocf_D) | | ||
| | Comment density COMF % | HISCOMF | min 20 (computed from HISComment / HISStmtFile) | | ||
|
|
||
| They can be changed with `--metrics-thresholds`. | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI review
The pylint and
py_compilesteps (lines 112 and 128–129) cover onlyreports/htmlreport/**, so the newreports/explorer/report.pyis never linted or compiled with--py-version 3.7. Usingreports/**/*.pyinstead would cover both.