Analysis & Report
Custom reports
Build your own HTML reports: choose the blocks, write the texts with variables, show parts only when they matter, and get a file that is rebuilt at the end of every analysis.
Concepts
A custom report is a small file (.cdreport, JSON) that says what the report contains. At the end of each analysis CppDepend fills it with the analysis data and writes an HTML page next to the standard report.
Report_<name>.html- Sections group blocks under a heading. A section is left out when its condition is false or when all its blocks are hidden or empty.
- Blocks sit on a 12 column grid. Width 12 is full width, 6 is half, 4 a third, 3 a quarter. Blocks of one section flow left to right and wrap.
- Variables such as
{{Project}}or{{Issues.Total}}are replaced by values of the analysis, in texts, titles and conditions. - Conditions show or hide a section or a block, for example
Gates.Fail > 0. - The report is one self-contained HTML file. Local images and the logo are embedded, so it can be mailed or archived. It has a print layout (use Page break blocks to control pages).
Quick start
- Open Settings, Reporting, Custom Reports and click New report, give it a name (the name of the list and of the file). Existing reports are listed with an on/off check: only enabled reports are built at the end of the analysis.
- The Report Designer opens. Left: the palette of blocks. Middle: the report structure (sections and blocks). Right: the properties of what is selected.
- Add a block with Add to the selected section, or Add as its own section to put it at the root level. Reorder with Move up / Move down, copy with Duplicate.
- Click Preview in browser to see the report built with the data of the last analysis. Check lists the problems: unknown variables, wrong XPath, queries missing from the data.
- Data... chooses another analysis data file for the preview. Data explorer shows the XML of the data and helps to write XPath for the Table and Chart blocks.
- Save. Run the analysis (GUI or console). The file
Report_<name>.htmlappears in the output folder of the project.
<output folder>\ReportTemplates\*.cdreport. The data copy used by the designer is ReportTemplates\_data\ReportData.xml. More template files or folders can be added with the environment variable CPPDEPEND_REPORT_TEMPLATES (paths separated by ;).Report settings
Selected with the first line of the structure (the report name).
| Property | Type | Default | What it does |
|---|---|---|---|
| Name | text | Report | Name in the list and in the file name: Report_<name>.html (spaces become underscores). |
| Build this report at the end of the analysis | check | on | Off keeps the template but skips it. |
| Title (cover) | text | {{Project}} | Main title of the cover and of the browser tab. Variables allowed. |
| Subtitle | text | – | Line under the title. Variables allowed, for example Compared with {{ComparedWith}}. |
| Description | text | – | Note for people who edit the template. Not shown in the report. |
| Footer | text | Generated by CppDepend {{Version}} on {{Date}} | Last line of the page. Variables allowed. Empty removes it. |
| Accent color | #RRGGBB | #2f6fdb | Color of titles, links and charts. |
| Mode | auto | light | dark | auto | auto follows the system theme of the reader. |
| Font | CSS font list | system fonts | For example Georgia, serif. |
| Logo | file or URL | – | Shown on the cover. A local file (png, jpg, gif, svg, webp, up to 3 MB) is embedded in the page. |
| Show cover | check | on | The cover shows title, subtitle, analysis date and, when a baseline exists, «compared with». |
| Contents | check | off | Table of contents of the titled sections. Shown only when there are at least two. |
Parameters
A parameter is a named value available as {{Param.Name}} in texts and conditions. Each has a Name, a Label and a Default. When the report is built at the end of the analysis the default value is used (a program calling the engine can pass other values). Example: a parameter Audience with default Manager, and a section condition Param.Audience == 'Auditor'.
Common properties
Section
| Property | Type | Default | What it does |
|---|---|---|---|
| Title | text | – | Heading of the section and entry of the table of contents. Variables allowed. Empty = no heading. |
| Condition | condition | – | The whole section is left out when false. See Conditions. |
| Page break before | check | off | Starts the section on a new printed page. |
Every block
| Property | Type | Default | What it does |
|---|---|---|---|
| Title | text | – | Heading above the block, variables allowed. Not shown for plain blocks (KPI tiles, callout, divider, spacer, page break). The callout uses it as a bold lead-in. |
| Width | 1 to 12 | block specific | Columns of the 12 column grid. 12 = full, 6 = half, 4 = third, 3 = quarter. |
| Condition | condition | – | The block is left out when false. |
Properties that are text (title, text, paths, query names...) accept {{variables}}, unless a property says otherwise.
Block reference
17 block types in 5 groups. In every table, Property is the name used in the file; the designer shows the same fields with friendly labels. Width, title and condition are common to all blocks.
Content
Text
Contentdefault width 12/12Free text with a small Markdown subset and variables. Use it for introductions, explanations, conclusions and instructions.
| Property | Type | Default | What it does |
|---|---|---|---|
| Text | multiline | – | Headings # ## ###, lists (- item, 1. item), --- rule, **bold**, *italic*, `code`, links [text](https://...), {{variables}}. |
# Release review for {{Project}}
Analysis of **{{Date}}**, compared with {{ComparedWith}}.
- {{Issues.Added}} new issues, {{Issues.Fixed}} fixed
- Technical debt: {{Issues.DebtMin|dur}}
- Details: [coding standard](https://example.com/standard)Callout
Contentdefault width 12/12A highlighted message. Combine it with a condition to show it only when it matters, for example a warning when a quality gate fails.
| Property | Type | Default | What it does |
|---|---|---|---|
| Text | multiline | {{Gates.Fail}} quality gate(s) failed. | Message. Markdown subset and variables. |
| Kind | info | ok | warn | bad | info | Color of the callout: blue, green, orange or red. |
- The block Title is printed in bold before the text.
Kind = bad
Text = **{{Gates.Fail}} quality gate(s) failed.** Do not release before they are fixed.Image
Contentdefault width 6/12A picture from a file or a URL: logo, architecture diagram, screenshot.
| Property | Type | Default | What it does |
|---|---|---|---|
| Path | text | – | Local file path or http(s) URL. Variables allowed. Local files (png, jpg, gif, svg, webp, up to 3 MB) are embedded in the report. |
| Alt | text | – | Alternative text. |
| MaxHeight | number (px) | 260 | Maximum height; the picture keeps its proportions. |
- If the file does not exist the report shows «Image not found» instead of failing.
Divider
Contentdefault width 12/12A thin horizontal line between parts of a section.
No property. Use the block Title, Width and Condition only.
Spacer
Contentdefault width 12/12Vertical space.
| Property | Type | Default | What it does |
|---|---|---|---|
| Height | number (px) | 24 | From 0 to 400. |
Page break
Contentdefault width 12/12Starts a new page when the report is printed or saved as PDF from the browser. Invisible on screen.
No property. Use the block Title, Width and Condition only.
Numbers
KPI tiles
Numbersdefault width 12/12Big numbers in tiles: a label, a value, an optional note and an optional color rule. One tile per line.
| Property | Type | Default | What it does |
|---|---|---|---|
| Items | multiline | 4 sample lines | One tile per line: Label | value | note | tone rule. Label, value and note accept variables. Note and rule are optional. |
- Tone rule:
ok,warnorbad, then a comparison (== != > >= < <=) and a number. The tile gets that color when the rule is true:bad>0,warn>=5,ok==0. The value must be numeric (a trailing % is accepted). - A
|inside{{ }}(the formatter, as in{{Issues.DebtMin|dur}}) does not split the line. - Drawn without a frame; the block title is not shown.
Issues | {{Issues.Total}} | {{Issues.Added}} new, {{Issues.Fixed}} fixed
Technical debt | {{Issues.DebtMin|dur}}
Quality gates failed | {{Gates.Fail}} | of {{Gates.Total}} | bad>0
Rules violated | {{Rules.Violated}} | of {{Rules.Total}}
Coverage | {{Dash.Code coverage}} | | ok>=80Dashboard metrics
Numbersdefault width 12/12The metrics of the analysis dashboard (lines of code, technical debt, coverage...) with the change since the baseline: green or red arrows.
| Property | Type | Default | What it does |
|---|---|---|---|
| Names | text | – | Parts of the metric names, separated by comma or semicolon. The first metric containing each part is shown, in your order. Empty shows all the metrics. |
| Top | number | 12 | Maximum number of tiles. |
When there is no data: «The analysis has no dashboard data» or «No matching metric». Use the Data explorer to see the exact metric names.
Lines of code, Technical debt, CoverageIssues
Issues by severity
Issuesdefault width 6/12Number (or technical debt) of issues per severity: Blocker, Critical, High, Medium, Low, with the severity colors.
| Property | Type | Default | What it does |
|---|---|---|---|
| Style | donut | bars | donut | Chart style. |
| Metric | count | debt | count | Number of issues, or estimated fixing time. |
When there is no data: «No issues data in this analysis».
Issues by category, rule or file
Issuesdefault width 6/12Where the issues are: grouped by category, by rule or by file, as bars or as a table with links to the source pages.
| Property | Type | Default | What it does |
|---|---|---|---|
| By | category | rule | file | category | Grouping. |
| Top | number | 10 | Maximum number of rows. |
| Style | bars | table | bars | The table shows name, issues, debt (and severe issues for files) and links to the source page. |
| Metric | count | debt | count | What the bars measure and how the rows are sorted. |
By = file
Style = table
Top = 15Issues list
Issuesdefault width 12/12A filtered and sorted list of individual issues with severity, rule, element, source location (linked to the source page) and debt.
| Property | Type | Default | What it does |
|---|---|---|---|
| Severity | text | Blocker,Critical,High | Severities to show, comma separated. Empty shows all. |
| Category | text | – | Keeps issues whose category contains this text. |
| Rule | text | – | Keeps issues whose rule name contains this text. |
| OnlyNew | check | off | Only issues added since the baseline (tagged new). |
| Top | number | 20 | Maximum number of rows. A note tells how many more exist. |
| Sort | severity | debt | file | severity | Severity then debt, largest debt first, or file and line. |
- Very large results are truncated by the analysis; the block then says that only the first issues were kept.
When there is no data: «No issue matches».
Severity =
OnlyNew = true
Top = 50
Sort = debtRules and quality gates
Quality gates
Rulesdefault width 12/12The quality gates with status, value, baseline value and trend. Failed gates come first.
| Property | Type | Default | What it does |
|---|---|---|---|
| Status | all | fail | warn | pass | all | Which gates to list. |
| Summary | check | on | Chips with the totals: gates, fail, warn, pass. |
When there is no data: «No quality gates in this analysis».
Status = failRules
Rulesdefault width 12/12The rules with status, group, value, new and fixed issues. Critical rules first.
| Property | Type | Default | What it does |
|---|---|---|---|
| Status | violated | critical | all | violated | violated = warnings, critical warnings and rules in error. critical = critical only. |
| Top | number | 50 | Maximum number of rules. |
| Group | text | – | Keeps rules whose group name contains this text. |
| Summary | check | on | Chips with the totals: rules, critical, violated, errors. |
When there is no data: «No rules in this analysis» or «No rule matches».
Status = violated
Group = MemoryCoverage compliance
Rulesdefault width 12/12The coverage compliance outcome of the project: policy, standard, verdict, then each component with its criteria (required, covered, justified, remaining, raw and justified percentages, verdict).
No property. Use the block Title, Width and Condition only.
When there is no data: a message says that the analysis has no compliance result (no compliance kit or coverage policy). Hide the section with the condition above.
xpath:count(/NDepend/Compliance) > 0Data
Query result
Datadefault width 12/12The matched elements of a code query, shown as the standard report shows them: name, status, columns of the query, full name and a link to the source line. This puts the result of your own queries in the report.
| Property | Type | Default | What it does |
|---|---|---|---|
| Query | query | – | Name (or id) of the query. The designer lists the queries of the data. |
| Group | text | – | Used when no query is chosen: shows all the queries of this group. |
| Top | number | 50 | Maximum rows per query; a note tells how many more exist. |
| HideEmpty | check | off | Hides a query that has no result. |
- The query must be in the report data: in the rules or queries settings, switch on Show in report for its group (the IsReport flag). Otherwise the block says «Not in the report data» and Check reports it.
- The header of a query shows its status (ok, violated, critical, error) and the number of matched elements. A query error is shown in red.
Dead functionsTable from the data
Datadefault width 12/12A table built from any part of the report data with an XPath. Use it when no ready block shows what you need.
| Property | Type | Default | What it does |
|---|---|---|---|
| XPath | XPath | /NDepend/RuleResult//Query[@NbIssuesAdded != ''] | Selects the rows (elements). Variables allowed. |
| Columns | multiline | – | One column per line: Header | relative XPath. Empty = the attributes of the rows (up to 8). |
| SortBy | XPath | – | Relative XPath of the sort value. Numbers are sorted as numbers, other values as text. |
| Desc | check | on | Descending order. |
| Top | number | 30 | Maximum rows. |
- Column XPaths are relative to each row:
@Name,../@Name,string(.),count(Val). - See Data model for the elements and attributes.
When there is no data: «No row». A wrong XPath is listed by Check.
XPath = /NDepend/RuleResult//Query[@NbIssuesAdded != '' and @NbIssuesAdded != '0']
Columns = Rule | @Name
New | @NbIssuesAdded
Fixed | @NbIssuesFixed
SortBy = @NbIssuesAddedChart from the data
Datadefault width 6/12A chart built from any part of the report data with an XPath: one item per element, with a label and a number.
| Property | Type | Default | What it does |
|---|---|---|---|
| XPath | XPath | /NDepend/IssuesSummary/Category | Selects the items. |
| Label | relative XPath | @Name | Text of each bar or slice. |
| Value | relative XPath | @Count | Number of each item. |
| Style | hbar | vbar | line | donut | hbar | Chart style. |
| Top | number | 10 | Maximum items. |
XPath = /NDepend/IssuesSummary/Category
Label = @Name
Value = @DebtMin
Style = vbarVariables
Written {{Name}}. Click a name in the tables to copy it. Names are not case sensitive. An unknown name gives n/a and a warning in Check.
Where they work: texts, callouts, block and section titles, report title, subtitle and footer, KPI lines, image path, query and group names, XPath of the table and chart blocks, and conditions.
Report and analysis
| Variable | Value | Notes |
|---|---|---|
| {{Project}} | Name of the analyzed project | Alias {{AppName}}. |
| {{Date}} | Date of the analysis | |
| {{Version}} | CppDepend version that made the analysis | |
| {{ComparedWith}} | Date of the baseline analysis | Empty when there is no baseline. |
| {{Duration}} | Duration of the analysis | |
| {{Now}} | Date and time when the report is built | Format yyyy-MM-dd HH:mm. |
| {{Today}} | Date when the report is built | Format yyyy-MM-dd. |
| {{Template}} | Name of the report template |
Issues
| Variable | Value | Notes |
|---|---|---|
| {{Issues.Total}} | Number of issues | |
| {{Issues.Added}} | Issues added since the baseline | Alias Issues.New. |
| {{Issues.Fixed}} | Issues fixed since the baseline | |
| {{Issues.DebtMin}} | Technical debt in minutes | Alias Issues.Debt. Use |dur to show «3 h 20 min» or «2.5 days» (8 hour days). |
| {{Issues.Blocker}} | Number of Blocker issues | Also Issues.Critical, Issues.High, Issues.Medium, Issues.Low (the severity names of the analysis). |
| {{Issues.Truncated}} | True when a very large result was cut |
Quality gates, rules and compliance
| Variable | Value | Notes |
|---|---|---|
| {{Gates.Total}} | Number of quality gates | |
| {{Gates.Fail}} | Gates that failed | Alias Gates.Failed. |
| {{Gates.Warn}} | Gates in warning | Alias Gates.Warning. |
| {{Gates.Pass}} | Gates that passed | Alias Gates.Passed. |
| {{Rules.Total}} | Number of rules | |
| {{Rules.Violated}} | Rules with a warning or a critical warning | Critical ones are included. |
| {{Rules.Critical}} | Rules with a critical warning | |
| {{Rules.Errors}} | Rules whose execution failed | |
| {{Compliance.Verdict}} | Coverage compliance verdict | n/a when the analysis has no compliance result. |
| {{Compliance.Policy}} | Name of the coverage policy | |
| {{Compliance.Standard}} | Standard of the policy |
Dashboard, parameters and XPath
| Variable | Value | Notes |
|---|---|---|
| {{Dash.<part of a metric name>}} | Value of a dashboard metric | The first metric whose name contains the text, ignoring case: {{Dash.Lines of code}}, {{Dash.Technical debt}}. - when not found. Check the names in the Data explorer. |
| {{Param.<name>}} | Value of a report parameter | Default value of the parameter. Unknown name gives n/a. |
| {{xpath:<expression>}} | Result of an XPath on the report data | {{xpath:count(/NDepend/RuleResult//Query)}}, {{xpath:/NDepend/ReportInfo/@AppName}}. The first node or value is used. |
Formatters
| Formatter | Effect | Example |
|---|---|---|
|num | Thousands separators, no decimals | {{Dash.Lines of code|num}} → 1,254,300 |
|int | Rounded integer | {{xpath:avg(//Issue/@DebtMin)|int}} |
|dur | Minutes as a duration | {{Issues.DebtMin|dur}} → 2.5 days |
|pct | Percent with one decimal | {{xpath:42.567|pct}} → 42.6% |
|upper, |lower | Letter case | {{Compliance.Verdict|upper}} |
The formatter is the last | of the expression and only applies when it is one of these names. A value that is not a number is left as it is.
Conditions
A condition is empty (always true), a single value, or comparisons joined with && (and) and || (or).
| Form | Meaning | Example |
|---|---|---|
| comparison | == != > >= < <=. Both sides numeric: compared as numbers; otherwise as text, ignoring case. | Gates.Fail > 0 |
| text value | Quote text with ' or ". Quoted text and {{ }} accept variables. | Compliance.Verdict != 'Pass' |
| bare value | True unless empty, 0 or false. | Issues.Added |
! | Negation of a bare value or comparison. | !Issues.Truncated |
xpath: | Any XPath result as an operand. | xpath:count(/NDepend/Compliance) > 0 |
| combined | && binds tighter than ||. | Issues.Added >= 1 && Param.Audience == 'Auditor' |
Names are the variables of the table above, without the braces. A condition that cannot be evaluated keeps the section or block visible and adds a warning to Check, so a typo never hides content silently.
Text formatting
| Write | Result |
|---|---|
# Title, ## Subtitle | Headings (up to 4 levels), below the block title level |
- item or * item | Bullet list |
1. item | Numbered list |
--- | Horizontal rule |
**bold**, *italic*, `code` | Inline styles |
[text](https://...) | Link. Only http(s)://, ./ and # targets are accepted. |
| blank line | New paragraph. A single line break stays a line break. |
HTML in a text is shown as text, never executed.
Data model for XPath
The data is the unified report XML written by the analysis. The most useful parts (names of the attributes as in the file):
| Element (path) | Attributes and content |
|---|---|
/NDepend/ReportInfo | AppName, NDependDate, NDependVersion, ComparedWith, ComparisonAvailable, BuiltDuration |
/NDepend/Dashboard//* | items with Name, Value, DiffDesc, DiffImage |
/NDepend/QualityGateResult | NbQualityGates; //Query: Name, Status (QualityGateFail, QualityGateWarn...), Value, BaselineValue, Trend; parent Group/@Name |
/NDepend/RuleResult | NbRules, NbWarns, NbWarnsCritical, NbErrors; //Query: Name, Status (RuleOk, RuleWarn, RuleWarnCritical, Error), Value, NbIssuesAdded, NbIssuesFixed |
/NDepend/IssuesSummary | TotalIssues, TotalDebtMin, Added, Fixed, Truncated; children Severity, Category, Rule, File (Name, Count, DebtMin, Severe, Page) and Issue (Severity, Category, Rule, Name, File, Line, Page, DebtMin, IsNew) |
/NDepend/Compliance | Verdict, PolicyName, Standard; Components/Component (Name, Level, Files, Verdict) with Criteria/Criterion (Name, Required, RequiredPercent, Covered, Total, Justified, Remaining, RawPercent, AdjustedPercent, Verdict) |
/NDepend/QueryResult/Group/Query | Name, QueryId, Status, NbNodeMatched, KindOfNode, ErrorDesc; Columns/Column; Rows/Row (Name, FullName, SrcPage, SrcFile, SrcLine) with Val children. Only groups shown in the report are present. |
Built-in templates
| Template | For | Contains |
|---|---|---|
| Executive summary | Managers | KPI tiles, gate failure callout, issues by severity and category, most severe issues, rules behind the issues |
| Quality audit | Reviewers | Dashboard metrics, KPI tiles, quality gates, violated rules, files with most issues, issues list; table of contents |
| Compliance dossier | Audits | Status tiles, coverage compliance, gates, critical rules, issues by category; table of contents |
| Release delta | Releases | New and fixed issues, rules with new issues, list of the new issues (needs a baseline) |
The designer writes these four as editable files in the ReportTemplates folder when it is empty. Edit them, duplicate them, or delete what you do not need.
Recipes
Callout, Condition Gates.Fail > 0, Kind bad
**{{Gates.Fail}} of {{Gates.Total}} quality gates failed.** Fix them before the release.Section Condition Param.Audience == 'Auditor' with a Coverage compliance block; define the parameter Audience with default Manager
KPI tiles with New issues | {{Issues.Added}} | | bad>0 and an Issues list with OnlyNew; a section «Nothing new» with condition Issues.Added == 0
Switch on Show in report for the group of the queries, run the analysis, add a Query result block and pick the query (or the group)
Text: The code carries about **{{Issues.DebtMin|dur}}** of technical debt.
Table from the data with /NDepend/IssuesSummary/Rule, Columns Rule | @Name, Issues | @Count, Debt (min) | @DebtMin, SortBy @DebtMin
File format (.cdreport)
A template is plain JSON, so it can be versioned in git, reviewed, generated by a script or copied between projects. Property names are not case sensitive; comments and trailing commas are accepted. Unknown block types are skipped with a warning.
{
"Version": 1,
"Name": "Gate watch",
"Enabled": true,
"Title": "{{Project}}: gate watch",
"Subtitle": "Compared with {{ComparedWith}}",
"Footer": "Generated by CppDepend {{Version}} on {{Date}}",
"Theme": { "Accent": "#2f6fdb", "Mode": "auto", "ShowCover": true, "Toc": false },
"Parameters": [ { "Name": "Audience", "Label": "Audience", "Default": "Manager" } ],
"Sections": [
{
"Title": "Status",
"Blocks": [
{ "Type": "kpis", "Width": 12,
"Props": { "Items": "Gates failed | {{Gates.Fail}} | of {{Gates.Total}} | bad>0" } },
{ "Type": "callout", "Width": 12, "Condition": "Gates.Fail > 0",
"Props": { "Kind": "bad", "Text": "**{{Gates.Fail}} quality gate(s) failed.**" } }
]
},
{
"Title": "Failed gates", "Condition": "Gates.Fail > 0",
"Blocks": [ { "Type": "gates", "Width": 12, "Props": { "Status": "fail" } } ]
}
]
}In CI the reports are built by the analysis itself (see the GitLab integration document): keep the ReportTemplates folder in the repository or point CPPDEPEND_REPORT_TEMPLATES to it, and publish Report_*.html as job artifacts.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
A value shows n/a | Unknown variable. Check the spelling against the tables above. Check lists it as «Unknown variable». |
{{Dash...}} shows - | No dashboard metric contains that text. Look at the metric names in the Data explorer. |
| Block says «No row» | The XPath selects nothing. Test it in the Data explorer; the path starts at /NDepend. |
| Query result says «Not in the report data» | The group of the query is not shown in the report. Switch on Show in report for the group and run the analysis again. |
| A section is missing | Its condition is false, or all its blocks are hidden or empty. Remove the condition to test. |
| Image not found | Wrong path, unsupported format, or file larger than 3 MB. Use a URL or a smaller file. |
| The report is not produced | Report is turned off in the list, there is no .cdreport in ReportTemplates, or the analysis log shows «Custom report ... failed» (the log also lists the first warnings of each report). |
| Preview shows old numbers | The preview uses the data file of the last analysis. Run the analysis again, or choose the data with Data.... |
| Trends and «new» are empty | The analysis has no baseline. Set a baseline to compare with. |
Thanks for your feedback. Tell us more or request a feature.
