Skip to end of metadata
Go to start of metadata

Table of Contents

 

The component viewer is the central place of SonarQube: it displays the source code of a file (may it be a source file or a test file), along with a lot of information:

  • Overall measures of the file, like lines of code, complexity, number of methods, ...etc
  • Issues (generated by the rules activated on the quality profile)  and their related technical debt
  • Duplicated blocks detected on the same file or on other files (from within the project or outside of it - if cross-project duplication is activated)
  • Lines and branches covered or not by unit or integration tests
  • SCM information (if the SCM Activity Plugin is installed) like who committed this specific line and when
  • List of all tests of a given test file, along with their execution time and their status

 

You will land on the component viewer:

  • when drilling down from project dashboards using hunting services
  • when reviewing issues on the Issues page
  • when searching for a particular file in the top-right search engine

General overview

Layout

The component viewer is composed of 3 parts:

  • The header that displays useful information and actions
  • The workspace that is used to keep track of navigation between files
  • The source code of the file, decorated with more or less information based on the activated decorations

The header

The header contains 5 tabs, one per main axis: measures, issues & technical debt, coverage, duplications and SCM. 

  • Each tab can be expanded to display more information and show filtering actions
    • Those filtering actions modify which part of the source code is visible
  • On top of each tab (except the first one), a light blue bar can be toggled to activate decoration of the source code
    • The decoration action modify which information is visible on the source code


Filtering actions and decorations are tow different concepts that are not necessarily linked together

Icon

For instance, it's possible to filter the source code to see only the parts where there are info issues, while keeping the coverage information displayed on those lines - like in the example below:

The Workspace concept

The workspace is a place that keeps track of navigation between files in order to help you:

  • remember which files you've just visited 
  • quickly move back to one of them

It is populated as soon as you initiate a navigation using the 2 following features (that are detailed later on this page):

  • Duplicated blocks 
  • Coverage per tests

Note that the workspace is automatically cleaned up once you stop navigating through these 2 features.

The source code

The main purpose of the component viewer is to show source code:

Highlight of usage and declaration of variables and methods is available for Java only

Icon

This feature is available for Java code only for the moment, and limited to the scope of the file. It allows to answer the questions:

  • Where is this variable or method declared? 
  • Where is it used?

Note that the target is to generalise this feature to other languages and to references out of the current file.

 

Overall measures

The first tab of the component viewer displays the most useful measures on a source file, organised by main categories:

Technical debt and issues

Technical debt is one of the major concepts that SonarQube deals with - the technical debt of a file being the sum of the technical debt contributed by each issue detected on this file.

The expanded tab offers 3 different kind of actions to understand where the technical debt of a file is located and to better manage it:

  • Time Changes, to display only added issues since a given period (see Differential Views for more information)
  • Resolution / Severity / Rule filters, to display only some issues on the currently selected period
  • Bulk Change, to make changes on the issues that are currently displayed 

To better understand how to review issues (comment, assign, link to an action plan, ... etc), please read the Issues documentation page.

Display of issues on a file is limited to 100

Icon

For performance and usability reasons, it's not possible to display the detail block of more than 100 issues. If the selected filter is supposed to show more than 100 issues, only the first 100 will have the detail block available for review, the remaining ones will only be shown with the squiggle line.

 

 

 

 

 

  • No labels