Engineering summary: Code Quality
Purpose
Code Quality summary shows metrics related to the quality of a written code such as a code complexity, maintainability, violations, duplicates, etc.. Metric values are aggregated for the items selected in Project settings/Code Quality management system (e.g. Sonar).
How metric helps
Code Quality summary helps to understand, assess and track code health and quality and take actions to improve a code writing process in the team.
How metric works
Chart overview
Chart provides several views:
1 Main view: shows aggregated values for the metrics (on the left) and the same for each project (table on the right):
2 Single view: it opens by click on an item in the table at Main view. Single view reveals metrics values for a selected project:
3 Drill down: it opens by click on a metric name at Single view (a hyperlink). Depending on a metric there opens a chart revealing a metric trend in time:
Calculation
The chart is based on a Code Quality data source configuration; only selected projects are taken into account:
See also Sonar configuration.
Metrics included into Main view:
Metric | Calculation | Unit of Measure |
---|---|---|
Total Projects | absolute number of selected projects | item |
Technical Debt | the sum of tech debt for selected projects | hours |
Vulnerabilities | absolute number of vulnerabilities (all types) in selected projects | item |
Code Smells | absolute number of code smells in selected projects | item |
Unit Test Coverage | Σ(UT1*LOC1 + UT2*LOC2 ...+UTn*LOCn)/ΣLOC1..n where UT - unit test coverage in a particular project LOC - number of code lines in a particular project Example: Given:
Code Coverage = (100*0.7 + 300 * 06)/(100+300)*100% = 62.5 % | % |
Duplicated Code | Σ(DL1*LOC1 + DL2*LOC2 ...+DLn*LOCn)/ΣLOC1..n where DL - number of duplicated lines in a particular project LOC - number of code lines in a particular project | % |
Maintainability Grade | ∑Grade*LOC / ∑LOC, where - Grade is A..E per Sonar for a project:
Rounding the result: down to the whole number and then take the grade from the above. Example: | grade |
Quality Gate* status: Passed | absolute number of projects meet quality gate measures | item |
Quality Gate status: Failed | absolute number of projects do not meet quality gate measures | item |
Lines of Codes | absolute number of code lines in selected projects | item |
Files | absolute number of files in selected projects | item |
Classes | absolute number of classes in selected projects | item |
*See more about quality gates in Sonar.
Metrics included into single view:
Metric | Calculation | Unit of Measure |
---|---|---|
Maintainability Grade | ∑Grade*LOC / ∑LOC, where
Rounding the result: down to the whole number and then take the grade from the above. Example: | grade |
Technical Debt | sum of a tech debt for a selected project | hour |
Duplicated Code | ΣDLN0*LOCN0 *100% where DL - number of duplicated lines for a selected project LOC - number of code lines for a selected project | % |
Code Smells | absolute number of code smells in a selected project | item |
Blocker | absolute number of all Blocker issues for a selected project | item |
Critical | absolute number of all Critical issues for a selected project | item |
Major | absolute number of all Major issues for a selected project | item |
Minor | absolute number of all Minor issues for a selected project | item |
Vulnerability | absolute number of vulnerabilities (all types) in a selected project | item |
Security Rating | overall grade of a security reliability of the project code base from "A" (the best) to "E" (the worst). | grade |
Unit Test Coverage | percentage of a source code covered by unit tests | % |
Line of codes | total number of code lines for a selected project | item |
Success | percentage of successful unit tests | % |
Failure | number of failures in unit testes for a selected project | item |
Error | number of errors in unit tests for a selected project | item |
Test | number of tests in a selected project | item |
By click on a hyperlink in single view the following charts open:
Hyperlink | Chart to show |
---|---|
Maintainability Grade | |
Technical Debt | |
Duplicated code | |
Blocker issues | |
Vulnerability | |
Security rating | |
Unit test coverage | |
Lines of code | |
Unit tests: Success | |
Unit tests: Test |
Data Source
Data for the chart can be collected from Sonar.