Skip to content

Commit 422f17c

Browse files
committed
manual
1 parent 70909e7 commit 422f17c

1 file changed

Lines changed: 49 additions & 26 deletions

File tree

‎man/manual.md‎

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,18 @@ The `.cfg` file format is documented in the `Reference: Cppcheck .cfg format` (<
13411341

13421342
# HTML report
13431343

1344-
You can convert the XML output from Cppcheck into a HTML report. You'll need Python and the pygments module (<http://pygments.org/>) for this to work. In the Cppcheck source tree there is a folder reports/htmlreport that contains a script that transforms a Cppcheck XML file into HTML output.
1344+
## Overview
1345+
1346+
Using AI, you can easily and quickly create a script that converts the Cppcheck XML output into a nice-looking HTML report with any features you want.
1347+
1348+
We provide 2 ready made scripts:
1349+
1350+
* htmlreport: results view
1351+
* explorer: dashboard, results view, metrics (if available)
1352+
1353+
## htmlreport
1354+
1355+
The script `cppcheck-htmlreport` converts a Cppcheck XML file into a HTML output. You'll need Python and the pygments module (<http://pygments.org/>) for this to work.
13451356

13461357
This command generates the help screen:
13471358

@@ -1374,7 +1385,7 @@ or
13741385
cppcheck-htmlreport --file=err.xml --report-dir=test1 \
13751386
--source-dir=https://github.com/<username>/<repo>/blob/<branch>/
13761387

1377-
## Choosing between local annotated HTML and remote repository links
1388+
### Choosing between local annotated HTML and remote repository links
13781389

13791390
`cppcheck-htmlreport` supports two modes for linking to source files:
13801391

@@ -1394,26 +1405,26 @@ handled by the hosting service.
13941405
In general, local mode fits air-gapped environments, while remote mode works
13951406
best for CI workflows and large or private repositories.
13961407

1397-
# Cppcheck Explorer report
1408+
## Explorer report
13981409

1399-
The script `reports/explorer/report.py` in the Cppcheck source tree converts Cppcheck XML output into a Cppcheck Explorer report, which you view in a browser. The report has a dashboard with graphs, and a results view where you can filter the warnings and see the related source code. It is designed to be responsive also when there are thousands of warnings.
1410+
The script `reports/explorer/report.py` creates a Cppcheck Explorer report. The report has a dashboard with graphs, and a results view where you can filter the warnings and see the related source code. If the XML file contains metrics, these are shown as well. The report is designed to be responsive also when there are thousands of warnings.
14001411

14011412
You only need Python to run the script, no extra modules are required.
14021413

1403-
## Generating a report
1414+
### Generating a report
14041415

1405-
First analyze the code and save the results in a XML file, then generate the report:
1416+
First analyze the code and save the results in an XML file, then generate the report:
14061417

14071418
cppcheck --enable=style --xml src 2> results.xml
14081419
python3 reports/explorer/report.py results.xml -o cppcheck-report
14091420

1410-
Open `cppcheck-report/index.html` in a browser. No web server is needed. To share the report, copy the whole `cppcheck-report` folder. Note that the report contains the source code.
1421+
Open `cppcheck-report/index.html` in a browser. To share the report, copy the whole `cppcheck-report` folder. Note that the report contains the source code.
14111422

14121423
The source files are searched for in the current folder and in the folder of the XML file. Use `--source-dir` if they are located somewhere else:
14131424

14141425
python3 reports/explorer/report.py results.xml --source-dir=path/to/project -o cppcheck-report
14151426

1416-
## New and old warnings
1427+
### New and old warnings
14171428

14181429
If you provide the XML results from an earlier analysis as a baseline, then the report shows which warnings are new:
14191430

@@ -1424,7 +1435,7 @@ If you provide the XML results from an earlier analysis as a baseline, then the
14241435
cppcheck --enable=style --xml src 2> results.xml
14251436
python3 reports/explorer/report.py results.xml --baseline=baseline.xml -o cppcheck-report
14261437

1427-
## Trend graphs
1438+
### Trend graphs
14281439

14291440
Save the XML results from each analysis in a folder and use `--history` to get trend graphs. The results are ordered by the date in the filename:
14301441

@@ -1437,6 +1448,34 @@ Save the XML results from each analysis in a folder and use `--history` to get t
14371448

14381449
If no `--baseline` is given, then the newest report in the history is used as baseline.
14391450

1451+
::: {.content-visible when-profile="premium"}
1452+
1453+
### Metrics
1454+
1455+
To generate metrics, add option `--premium=metrics`. The metrics are saved in the XML v3 report.
1456+
Example:
1457+
1458+
cppcheck --premium=metrics test.c --xml-version=3 2> res.xml
1459+
python3 reports/explorer/report.py res.xml -o cppcheck-report
1460+
1461+
The dashboard shows a summary of the metrics and the metrics view shows the values for each
1462+
function and file. Values that exceed the thresholds are highlighted.
1463+
1464+
The default thresholds are the HIS limits. You can change them by providing a JSON file. Example `thresholds.json`:
1465+
1466+
{
1467+
"cyclomaticComplexity": {"max": 15},
1468+
"HISCOMF": {"min": 10}
1469+
}
1470+
1471+
Use the option `--metrics-thresholds` to load the file:
1472+
1473+
python3 reports/explorer/report.py res.xml --metrics-thresholds=thresholds.json -o cppcheck-report
1474+
1475+
:::
1476+
1477+
### All options
1478+
14401479
To see all options, run:
14411480

14421481
python3 reports/explorer/report.py -h
@@ -1597,23 +1636,7 @@ Example:
15971636

15981637
cppcheck --premium=metrics test.c --xml-version=3 2> res.xml
15991638

1600-
To view the metrics, it is recommended that you generate a [Cppcheck Explorer report](#cppcheck-explorer-report):
1601-
1602-
python3 reports/explorer/report.py res.xml -o cppcheck-report
1603-
1604-
Open `cppcheck-report/index.html` in a browser. The dashboard shows a summary of the metrics and the metrics view shows
1605-
the values for each function and file. Values that exceed the thresholds are highlighted.
1606-
1607-
The default thresholds are the HIS limits. You can change them by providing a JSON file. Example `thresholds.json`:
1608-
1609-
{
1610-
"cyclomaticComplexity": {"max": 15},
1611-
"HISCOMF": {"min": 10}
1612-
}
1613-
1614-
Use the option `--metrics-thresholds` to load the file:
1615-
1616-
python3 reports/explorer/report.py res.xml --metrics-thresholds=thresholds.json -o cppcheck-report
1639+
A report that shows the metrics can be created, for example see the chapter [Explorer report](#explorer-report).
16171640

16181641
If you want the metrics in CSV format, we provide a small simple python script for that:
16191642

0 commit comments

Comments
 (0)