Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Code quality metrics

Frank Niessink edited this page Oct 1, 2018 · 3 revisions

HQ currently only supports SonarQube as metric source for code quality metrics.

First, create a SonarQube metric source and add it to the project:

SONAR = metric_source.Sonar("http://sonar:9000/")
PROJECT = Project(
   ...
   metric_sources={metric_source.Sonar: SONAR})

Then, for each component and application, tell HQ which key to use:

COMPONENT = Component(
    ...
    metric_source_ids={SONAR: "key of component in Sonar"})

Applications and components have the requirement.CodeQuality and the requirement.ViolationsBySeverity by default. The violations by severity requirement makes HQ measure blocker, critical, and major violations (minor and info violations not reported on). To have HQ measure the violations by type (bugs, vulnerabilities, and code smells) turn on the requirement.ViolationsByType add it to the component or application:

COMPONENT = Component(
    ...
    added_requirements=[requirement.ViolationsByType])

To turn off the violations by severity metrics, remove the requirement:

COMPONENT = Component(
    ...
    removed_requirements=[requirement.ViolationsBySeverity])
Clone this wiki locally