PricingDownload
Product

Platform

All features44 capabilities, from IDE to CICompliance KitsISO 26262, DO-178C, IEC 62304...AI GovernanceControl AI-generated C/C++ codeWhat’s new in 2027Latest version highlightsScreenshotsSee the product in action

Analyze & improve

Coding standardsMISRA, CERT, CWE, AUTOSARArchitecture & dependenciesGraphs, matrix, cyclesTechnical debtMeasured in hours and dollarsQuality gatesStop regressions in CISmart Code CityYour codebase in 3D

Integrations

IDE pluginsVisual Studio, VS Code, CLion...CI/CD pipelinesJenkins, Azure DevOps, GitHub, GitLabSonarQube pluginC/C++ results in SonarQubeExternal analyzersClang-Tidy, Cppcheck, coverageFeature on Demand
Solutions

By need

Functional safetyCompliance kits per standardCoding standardsMISRA, CERT, AUTOSAR, ISO...Legacy modernizationRefactor large C/C++ safelyCode auditExpert review of your codebaseM&A due diligenceAssess technical health fast

By role

DevelopersSoftware architectsTech leadsDevOps engineersEngineering managersProject managers

CTOsCIOs / IT leadersQA engineersSecurity leadersComplianceConsultantsRequest a guided PoC
Industries

Safety-critical

AutomotiveISO 26262, MISRA, AUTOSARAerospace & DefenseDO-178C programsMedical DevicesIEC 62304 softwareEnergy & UtilitiesIEC 61508 systemsEmbedded SystemsFirmware and devices

Enterprise

Financial ServicesTrading and paymentsGame DevelopmentEngines and large C++Software VendorsCommercial C/C++ productsGovernmentAgencies and contractorsAll industries & case studies
Resources

Learn

DocumentationGuides, rules and CI setupKnowledge baseFrequently asked questionsBlogC and C++ code quality articlesRelease notesEvery version since 2009

Customers

Case studiesSuccess storiesTestimonialsWhat users sayOur customersCompanies using CppDependGold Code QualityOpen source projects we rate

Programs & company

Feature on DemandMissing features built for freeFree for open sourceLicenses for OSS and studentsContact usSales and supportEULALicense agreement
Docs
Documentation

User Guides

Code Map (Treemap)

The Code Map draws the whole code base as nested rectangles: the area shows one metric, the color shows another. This page explains every control of the screen, every menu and every action, with screenshots of a real analysis of Cppcheck 2.22 (69,282 lines of code, 4,858 methods).

11 min readUser GuidesCppDepend 2027

What the treemap shows

Every rectangle is a code element: a project, a namespace, a type or a method, depending on the level. Elements are nested inside their parent: at method level, the methods of a type are drawn side by side inside the rectangle of that type, which sits inside its namespace and its project. Two metrics are read at the same time:

VisualMeaningDefault
AreaProportional to the Size metric. A big rectangle is a big element.Lines of code (LOC)
ColorThe value of the color metric, from green (good) through yellow and orange to red (poor).Maintainability

With the defaults, a large red rectangle is a large method that is hard to maintain: the first place to look when you plan refactoring. In Cppcheck, the red blocks gather in the tokenizer, the template simplifier and the checkers, while the libraries simplecpp and tinyxml2 stay mostly green.

Code Map of Cppcheck 2.22: methods sized by lines of code and colored by maintainability
The Code Map of Cppcheck 2.22 at method level: size = lines of code, color = maintainability.

Opening the Code Map

FromHow
Quality DashboardIn the LOC tile, click Treemap (next to Smart Code City, Code Insight and Code Quest).
Code Quest (query results)Export › Export to treemap opens the map with the result highlighted. See Show a query result on the map.

The page title in the top bar reads Code Map. Use the back and forward arrows at the right of the top bar to return to the page you came from.

The screen at a glance

The numbers in the screenshot match the table below. Controls 1 to 11 form the toolbar; 12 and 13 are parts of the map itself. Hovering any toolbar control shows a tooltip with the text quoted in the table.

The Code Map screen with numbered callouts on every toolbar control
The Code Map screen, numbered.
#ControlTooltipWhat it does
1Level drop-downLevel of the city: project, namespace, type or methodChooses the kind of element drawn as a rectangle. See Level.
2Zoom in (magnifier +)Zoom inEnlarges the map so that the labels of smaller elements become readable. Scroll to move around a zoomed map.
3Zoom valueThe number displayed between the two zoom buttons (19 here).
4Zoom out (magnifier −)Zoom outShrinks the map back.
5Reset view (circular arrow)Reset the view: zoom position camera and highlightsReturns to the full map at the initial zoom and position, and removes any highlight.
6Size drop-downMetric that defines the size of each city elementThe metric that sets the area of each rectangle. See Size metric.
7Color buttonColor the treemap by a metricA simple on/off button, with no menu. Click it to remove the colors (gray map); click again to bring them back. The highlighted state means colors are on. See Map without color.
8Color metric drop-down (the metric name right after the Color button)Metric that defines the color of each city elementThe metric that sets the color. See Color metric.
9Info toggle (i)Show/Hide City Code Elements Info TooltipOn (highlighted, default): hovering shows the full details card. Off: only a one-line label. See Hovering an element.
10Top N drop-down (bar chart)Highlight the top elements by the current size metricHighlights the 10 to 5,000 largest elements. See Top N.
11Reset HighlightRemove the highlight and show the whole treemapClears a Top N or query highlight and brings every element back to full brightness.
12Parent labelThe name of the enclosing element, drawn in its top-left corner: here the projects cppcheck and cli.
13Element rectangleOne code element. Its name is written inside when the rectangle is large enough (here expandTemplate). Hover it, right-click it or double-click it (below).

Level: what a rectangle is

Click the Level drop-down (1) and pick one of the four levels. The size and color metrics you chose are kept when you switch.

Level menu: Project, Namespace, Type, Method
The Level menu.
LevelOne rectangle isUse it to
ProjectA project of the solutionCompare the weight of the projects. Cppcheck has two: the cppcheck library and the small cli front end.
NamespaceA namespaceSee how the code is organized. In Cppcheck most of the code lives in the global namespace; simplecpp, tinyxml2, ValueFlow and clangimport are the named ones.
TypeA class, struct or the __Globals pseudo-type (free functions)Find the big classes. Tokenizer, SymbolDatabase, CheckOtherImpl, TemplateSimplifier and ImportProject stand out.
MethodA function or methodFind the individual functions to fix. This is the default level.
Code Map at namespace level
Namespace level: the global namespace dominates; named namespaces are on the right.
Code Map at type level
Type level: the largest classes of Cppcheck, colored by maintainability.

Size metric

Click the Size drop-down (6). At method level the list is:

Size metric menu at method level
The Size menu at method level.
MetricThe area shows
# lines of code (LOC)Lines of code of the method. Shows where the code is.
Cyclomatic Complexity (CC)Number of independent paths. Shows where the complexity is.
# MethodsNumber of methods (one per method at this level; meaningful at type, namespace and project levels).
# OverloadsNumber of overloads sharing the method name.
# ParametersNumber of parameters.
# VariablesNumber of local variables.
Method LevelDepth of the method in the call layering (0 for methods that call nothing of your code).
# Methods calledHow many methods it calls (efferent coupling).
# Methods calling meHow many methods call it (afferent coupling): the popular methods.
Method RankImportance in the call graph, computed like a page rank.
# lines of code coveredLines executed by tests (needs coverage data imported in the project).
# lines of code not coveredLines not executed by tests (needs coverage data).

The other levels offer the metrics that make sense for them, for example the number of methods or types they contain.

Color metric

The color of each rectangle depends on one metric. To change it, click the list next to the Color button (8 in the screenshot). By default it shows Maintainability. Pick another metric in the list:

Color metric menu at method level
The Color metric menu at method level.
MetricRed means
DebtHigh technical debt (estimated time to fix its issues).
# lines of code (LOC)Long method.
# lines of comment / Percentage CommentFew comments (low values are colored as poor).
MaintainabilityLow maintainability index (default color).
Cyclomatic Complexity (CC)Many execution paths.
Flash (bytes) / RAM (bytes)Large memory footprint, when linker map data is provided.
# Overloads, # Parameters, # VariablesHigh counts.
Method Level, # Methods called, # Methods calling me, Method RankHigh position or coupling in the call graph.
Percentage Coverage, # lines of code covered / not coveredPoorly tested code (needs coverage data).

Whatever the metric, green always reads as fine: the scale is reversed for metrics where a high value is good, such as maintainability and coverage.

Combining size and color

The map is most useful when size and color answer two questions at once. Here, size = Cyclomatic Complexity and color = Debt: the big red blocks are complex functions that also carry a lot of debt.

Size Cyclomatic Complexity, color Debt
Size = cyclomatic complexity, color = debt.
SizeColorYou find
Lines of codeMaintainabilityLarge code that is hard to maintain (default).
Lines of codeDebtWhere the technical debt sits.
Cyclomatic ComplexityDebtComplex code that is also in poor shape.
Cyclomatic ComplexityPercentage CoverageComplex methods that tests do not reach.
# Methods calling meCyclomatic ComplexityPopular and complex methods: risky to change.
Lines of codePercentage CommentLarge, undocumented code.
Flash (bytes)RAM (bytes)Memory footprint on embedded targets.

Map without color

Click the Color button (7) to remove the colors. This button has no menu, it is a plain on/off switch. The rectangles are drawn in shaded gray and only the area matters, which makes the size metric easier to compare. Click again to restore the colors.

Code Map with coloring switched off
Coloring off, size = cyclomatic complexity.

Hovering an element

Move the mouse over a rectangle: it gets a blue frame and, with the Info toggle (9) on, a details card appears.

Details card of checkFunctionVariableUsage_iterateScopes
The details card of checkFunctionVariableUsage_iterateScopes, one of the 20 most complex functions of Cppcheck.
Part of the cardContent (example)
PathProject cppcheck › namespace Global Namespace › type CheckUnusedVarImpl › file checkunusedvar.cpp, line 702. The icon after the line number opens the file.
NamecheckFunctionVariableUsage_iterateScopes(...)
LOCLines of code: 303
DebtEstimated time to fix the issues: 6d 3h
MIMaintainability index, colored: 5
RatingDebt rating from A to E: E
CCCyclomatic complexity: 237
IssuesRule violations in the element: 247
ECEfferent coupling (elements it uses): 117
COMMENTSLines of comment: 13
Help lineDouble Click: Recommendations · Right Click: Advanced Actions · "You can deactivate this tooltip from the toolbar". The cross at the top right closes the card.

Switch Info off to explore a crowded map: hovering then shows only a one-line label with the element name and its lines of code.

One-line label shown when Info is off
With Info off: name and LOC only.

Top N: highlight the largest elements

Click the bar-chart drop-down (10) and choose how many elements to highlight: Select Top 10, 20, 50, 100, 200, 500, 1000, 2000 or 5000.

Top N menu
The Top N menu.

CppDepend ranks the elements of the current level by the current Size metric and highlights the first N: they keep their bright color while every other element is dimmed. With size = cyclomatic complexity, Select Top 20 shows the 20 most complex functions of Cppcheck, such as checkFormatString, simplifyTypedefCpp, findGarbageCode and checkScope.

Top 20 methods by cyclomatic complexity highlighted
Select Top 20 with size = cyclomatic complexity.

Click Reset Highlight (11) to return to the normal map.

Zooming

Click Zoom in (2) to enlarge the map: labels appear on rectangles that were too small to carry one. Scroll to move around, Zoom out (4) to come back, or Reset view (5) to return in one click to the full map.

Zoomed Code Map
After a few clicks on Zoom in: more method names are readable.

Right-click any rectangle to act on that element.

Right-click menu of an element
The right-click menu.
ItemWhat it does
Prompt Builder ›Builds a ready-to-use AI prompt about the element (submenu below).
Show on Code InsightOpens the element in Code Insight, with its metrics, issues and dependencies.
Review Diff since BaselineShows what changed in the element since the baseline analysis.
Open source in CppDependOpens the source code in the built-in viewer.
Open Source in IDEOpens the file in your IDE at the element.
Show on Dependency GraphOpens the Call Graph with this element.
Append it to GraphAdds the element to the graph already open.
Append it with its dependenciesAdds the element plus what it uses and what uses it.
Select Issues / Projects / Modules / Namespaces / Types / Methods / Fields ›Lists related elements in Code Quest (submenus below).

Prompt Builder

Prompt Builder submenu
Prompt Builder: Understand, Refactor, Resolve Issues, Document, Test.
ItemThe prompt asks the AI to
UnderstandExplain what the element does.
RefactorPropose a refactoring that keeps the behavior.
Resolve IssuesFix the rule violations reported on the element.
DocumentWrite the missing documentation.
TestWrite unit tests for it.

Select Issues

Select Issues submenu
Select Issues: all issues, or only those that changed since the baseline.

All my Issues lists every issue of the element. The three others need a baseline: Added Since Baseline, Added or Worsened Since Baseline and Fixed Since Baseline.

Select Methods (and the other Select menus)

Select Methods submenu
Select Methods: callers and callees, direct or indirect.
ItemLists the methods
... that are Using Me Directlythat call the element.
... that are Using Me (Directly or Indirectly)that reach the element through any call chain.
... that I Use Directlythat the element calls.
... that I Use (Directly or Indirectly)that the element reaches through any call chain.

Projects, Modules, Namespaces, Types and Fields offer the same choices for their kind of element. The choice opens Code Quest with the CQLinq query already written and run. For checkFunctionVariableUsage_iterateScopes, "Using Me Directly" finds 2 methods of CheckUnusedVarImpl: the caller checkFunctionVariableUsage and the function itself, which is recursive.

Code Quest opened by Select Methods
The generated query and its result in Code Quest.

Show a query result on the map

Any query result can be drawn on the treemap. Example: the methods of your own code with a cyclomatic complexity above 20.

  1. In Code Quest, run the query from m in JustMyCode.Methods where m.CyclomaticComplexity > 20 orderby m.CyclomaticComplexity descending select new { m, m.CyclomaticComplexity, m.NbLinesOfCode }. On Cppcheck it returns 495 methods.
  2. Click Export above the result grid, then Export to treemap.
Query result in Code Quest
The query result: 495 methods, grouped by project and type.
Export menu of a query result
Export › Export to treemap (the menu also exports to graph, matrix, HTML, Excel, XML and text).

The Code Map opens with the 495 methods highlighted and every other method dimmed: you see at once that complexity is concentrated in a few areas of the code base.

Query result highlighted on the Code Map
The 495 methods with CC > 20, highlighted on the map.

Click Reset Highlight to see the whole map again.

Recipes

QuestionSettings
Where should I refactor first?Method level, size LOC, color Maintainability. Start with the large red rectangles.
Which classes are the biggest?Type level, size LOC.
What are the 20 most complex functions?Method level, size Cyclomatic Complexity, Top N › Select Top 20.
Where is the debt?Size LOC or CC, color Debt.
Which complex code is untested?Size Cyclomatic Complexity, color Percentage Coverage (import coverage first).
Who calls this hotspot?Right-click › Select Methods › that are Using Me, or Show on Dependency Graph.
Ask an AI to fix itRight-click › Prompt Builder › Refactor or Resolve Issues.
Where does my query match?Code Quest › Export › Export to treemap.

Related pages

Was this page helpful?
Evaluating CppDepend on a production codebase?Get a guided proof of concept with our static analysis architects.
Request a PoC