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).
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:
| Visual | Meaning | Default |
|---|---|---|
| Area | Proportional to the Size metric. A big rectangle is a big element. | Lines of code (LOC) |
| Color | The 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.

Opening the Code Map
| From | How |
|---|---|
| Quality Dashboard | In 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.

| # | Control | Tooltip | What it does |
|---|---|---|---|
| 1 | Level drop-down | Level of the city: project, namespace, type or method | Chooses the kind of element drawn as a rectangle. See Level. |
| 2 | Zoom in (magnifier +) | Zoom in | Enlarges the map so that the labels of smaller elements become readable. Scroll to move around a zoomed map. |
| 3 | Zoom value | The number displayed between the two zoom buttons (19 here). | |
| 4 | Zoom out (magnifier −) | Zoom out | Shrinks the map back. |
| 5 | Reset view (circular arrow) | Reset the view: zoom position camera and highlights | Returns to the full map at the initial zoom and position, and removes any highlight. |
| 6 | Size drop-down | Metric that defines the size of each city element | The metric that sets the area of each rectangle. See Size metric. |
| 7 | Color button | Color the treemap by a metric | A 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. |
| 8 | Color metric drop-down (the metric name right after the Color button) | Metric that defines the color of each city element | The metric that sets the color. See Color metric. |
| 9 | Info toggle (i) | Show/Hide City Code Elements Info Tooltip | On (highlighted, default): hovering shows the full details card. Off: only a one-line label. See Hovering an element. |
| 10 | Top N drop-down (bar chart) | Highlight the top elements by the current size metric | Highlights the 10 to 5,000 largest elements. See Top N. |
| 11 | Reset Highlight | Remove the highlight and show the whole treemap | Clears a Top N or query highlight and brings every element back to full brightness. |
| 12 | Parent label | The name of the enclosing element, drawn in its top-left corner: here the projects cppcheck and cli. | |
| 13 | Element rectangle | One 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 | One rectangle is | Use it to |
|---|---|---|
| Project | A project of the solution | Compare the weight of the projects. Cppcheck has two: the cppcheck library and the small cli front end. |
| Namespace | A namespace | See 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. |
| Type | A class, struct or the __Globals pseudo-type (free functions) | Find the big classes. Tokenizer, SymbolDatabase, CheckOtherImpl, TemplateSimplifier and ImportProject stand out. |
| Method | A function or method | Find the individual functions to fix. This is the default level. |


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

| Metric | The 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. |
| # Methods | Number of methods (one per method at this level; meaningful at type, namespace and project levels). |
| # Overloads | Number of overloads sharing the method name. |
| # Parameters | Number of parameters. |
| # Variables | Number of local variables. |
| Method Level | Depth of the method in the call layering (0 for methods that call nothing of your code). |
| # Methods called | How many methods it calls (efferent coupling). |
| # Methods calling me | How many methods call it (afferent coupling): the popular methods. |
| Method Rank | Importance in the call graph, computed like a page rank. |
| # lines of code covered | Lines executed by tests (needs coverage data imported in the project). |
| # lines of code not covered | Lines 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:

| Metric | Red means |
|---|---|
| Debt | High technical debt (estimated time to fix its issues). |
| # lines of code (LOC) | Long method. |
| # lines of comment / Percentage Comment | Few comments (low values are colored as poor). |
| Maintainability | Low 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, # Variables | High counts. |
| Method Level, # Methods called, # Methods calling me, Method Rank | High position or coupling in the call graph. |
| Percentage Coverage, # lines of code covered / not covered | Poorly 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 | Color | You find |
|---|---|---|
| Lines of code | Maintainability | Large code that is hard to maintain (default). |
| Lines of code | Debt | Where the technical debt sits. |
| Cyclomatic Complexity | Debt | Complex code that is also in poor shape. |
| Cyclomatic Complexity | Percentage Coverage | Complex methods that tests do not reach. |
| # Methods calling me | Cyclomatic Complexity | Popular and complex methods: risky to change. |
| Lines of code | Percentage Comment | Large, 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.

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.

checkFunctionVariableUsage_iterateScopes, one of the 20 most complex functions of Cppcheck.| Part of the card | Content (example) |
|---|---|
| Path | Project cppcheck › namespace Global Namespace › type CheckUnusedVarImpl › file checkunusedvar.cpp, line 702. The icon after the line number opens the file. |
| Name | checkFunctionVariableUsage_iterateScopes(...) |
| LOC | Lines of code: 303 |
| Debt | Estimated time to fix the issues: 6d 3h |
| MI | Maintainability index, colored: 5 |
| Rating | Debt rating from A to E: E |
| CC | Cyclomatic complexity: 237 |
| Issues | Rule violations in the element: 247 |
| EC | Efferent coupling (elements it uses): 117 |
| COMMENTS | Lines of comment: 13 |
| Help line | Double 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.

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.

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.

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.

Right-click menu
Right-click any rectangle to act on that element.

| Item | What it does |
|---|---|
| Prompt Builder › | Builds a ready-to-use AI prompt about the element (submenu below). |
| Show on Code Insight | Opens the element in Code Insight, with its metrics, issues and dependencies. |
| Review Diff since Baseline | Shows what changed in the element since the baseline analysis. |
| Open source in CppDepend | Opens the source code in the built-in viewer. |
| Open Source in IDE | Opens the file in your IDE at the element. |
| Show on Dependency Graph | Opens the Call Graph with this element. |
| Append it to Graph | Adds the element to the graph already open. |
| Append it with its dependencies | Adds 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

| Item | The prompt asks the AI to |
|---|---|
| Understand | Explain what the element does. |
| Refactor | Propose a refactoring that keeps the behavior. |
| Resolve Issues | Fix the rule violations reported on the element. |
| Document | Write the missing documentation. |
| Test | Write unit tests for it. |
Select Issues

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)

| Item | Lists the methods |
|---|---|
| ... that are Using Me Directly | that call the element. |
| ... that are Using Me (Directly or Indirectly) | that reach the element through any call chain. |
| ... that I Use Directly | that 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.

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.
- 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. - Click Export above the result grid, then Export to treemap.


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.

Click Reset Highlight to see the whole map again.
Recipes
| Question | Settings |
|---|---|
| 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 it | Right-click › Prompt Builder › Refactor or Resolve Issues. |
| Where does my query match? | Code Quest › Export › Export to treemap. |
Related pages
- Call Graph: follow the dependencies of a hotspot.
- Dependency Matrix (DSM): see coupling between components.
- Analyze your first project: get the analysis these maps are drawn from.
Thanks for your feedback. Tell us more or request a feature.
