MeasuresAndMetaWithPeriod,
MeasuresForProjects,
} from '../types/measures';
+import { MetricKey, MetricType } from '../types/metrics';
import { Measure } from '../types/types';
const COMPONENT_URL = '/api/measures/component';
}).catch(throwGlobalError);
}
-export function getMeasuresWithPeriodAndMetrics(
+export async function getMeasuresWithPeriodAndMetrics(
component: string,
metrics: string[],
branchParameters?: BranchParameters,
): Promise<MeasuresAndMetaWithPeriod & MeasuresAndMetaWithMetrics> {
- return getJSON(COMPONENT_URL, {
+ // TODO: Remove this mock (SONAR-21488)
+ const mockedMetrics = metrics.filter(
+ (metric) =>
+ ![
+ MetricKey.maintainability_issues,
+ MetricKey.reliability_issues,
+ MetricKey.security_issues,
+ ].includes(metric as MetricKey),
+ );
+ const result = await getJSON(COMPONENT_URL, {
additionalFields: 'period,metrics',
component,
- metricKeys: metrics.join(','),
+ metricKeys: mockedMetrics.join(','),
...branchParameters,
}).catch(throwGlobalError);
+ if (metrics.includes(MetricKey.maintainability_issues)) {
+ result.metrics.push({
+ key: MetricKey.maintainability_issues,
+ name: 'Maintainability Issues',
+ description: 'Maintainability Issues',
+ domain: 'Maintainability',
+ type: MetricType.Data,
+ higherValuesAreBetter: false,
+ qualitative: true,
+ hidden: false,
+ bestValue: '0',
+ });
+ result.component.measures?.push({
+ metric: MetricKey.maintainability_issues,
+ period: {
+ index: 0,
+ value: JSON.stringify({
+ total: 3,
+ high: 1,
+ medium: 1,
+ low: 1,
+ }),
+ },
+ });
+ }
+ if (metrics.includes(MetricKey.reliability_issues)) {
+ result.metrics.push({
+ key: MetricKey.reliability_issues,
+ name: 'Reliability Issues',
+ description: 'Reliability Issues',
+ domain: 'Reliability',
+ type: MetricType.Data,
+ higherValuesAreBetter: false,
+ qualitative: true,
+ hidden: false,
+ bestValue: '0',
+ });
+ result.component.measures?.push({
+ metric: MetricKey.reliability_issues,
+ period: {
+ index: 0,
+ value: JSON.stringify({
+ total: 2,
+ high: 0,
+ medium: 1,
+ low: 1,
+ }),
+ },
+ });
+ }
+ if (metrics.includes(MetricKey.security_issues)) {
+ result.metrics.push({
+ key: MetricKey.security_issues,
+ name: 'Security Issues',
+ description: 'Security Issues',
+ domain: 'Security',
+ type: MetricType.Data,
+ higherValuesAreBetter: false,
+ qualitative: true,
+ hidden: false,
+ bestValue: '0',
+ });
+ result.component.measures?.push({
+ metric: MetricKey.security_issues,
+ period: {
+ index: 0,
+ value: JSON.stringify({
+ total: 1,
+ high: 0,
+ medium: 0,
+ low: 1,
+ }),
+ },
+ });
+ }
+ return result;
}
export function getMeasuresForProjects(
import { QualityGateStatus, QualityGateStatusCondition } from '../../../types/quality-gates';
import { Component, MeasureEnhanced, Metric, Period, QualityGate } from '../../../types/types';
import '../styles.css';
-import { HISTORY_METRICS_LIST, METRICS } from '../utils';
+import { BRANCH_OVERVIEW_METRICS, HISTORY_METRICS_LIST } from '../utils';
import BranchOverviewRenderer from './BranchOverviewRenderer';
interface Props {
// render them.
const metricKeys =
projectStatus.conditions !== undefined
- ? uniq([...METRICS, ...projectStatus.conditions.map((c) => c.metricKey)])
- : METRICS;
+ ? uniq([...BRANCH_OVERVIEW_METRICS, ...projectStatus.conditions.map((c) => c.metricKey)])
+ : BRANCH_OVERVIEW_METRICS;
this.loadMeasuresAndMeta(key, branch, metricKeys).then(
({ measures, metrics, period }) => {
) => {
return getMeasuresWithPeriodAndMetrics(
componentKey,
- metricKeys.length > 0 ? metricKeys : METRICS,
+ metricKeys.length > 0 ? metricKeys : BRANCH_OVERVIEW_METRICS,
getBranchLikeQuery(branchLike),
).then(({ component: { measures }, metrics, period }) => {
return {
import { QualityGateStatusConditionEnhanced } from '../../types/quality-gates';
import { Dict, RawQuery } from '../../types/types';
-export const METRICS: string[] = [
+export const BRANCH_OVERVIEW_METRICS: string[] = [
// quality gate
MetricKey.alert_status,
MetricKey.quality_gate_details, // TODO: still relevant?
MetricKey.accepted_issues,
MetricKey.new_accepted_issues,
MetricKey.high_impact_accepted_issues,
+ MetricKey.maintainability_issues,
+ MetricKey.reliability_issues,
+ MetricKey.security_issues,
// bugs
MetricKey.bugs,
line_coverage = 'line_coverage',
lines = 'lines',
lines_to_cover = 'lines_to_cover',
+ maintainability_issues = 'maintainability_issues',
maintainability_rating_distribution = 'maintainability_rating_distribution',
maintainability_rating_effort = 'maintainability_rating_effort',
major_violations = 'major_violations',
releasability_effort = 'releasability_effort',
releasability_rating = 'releasability_rating',
releasability_rating_distribution = 'releasability_rating_distribution',
+ reliability_issues = 'reliability_issues',
reliability_rating = 'reliability_rating',
reliability_rating_effort = 'reliability_rating_effort',
reliability_rating_distribution = 'reliability_rating_distribution',
reopened_issues = 'reopened_issues',
security_hotspots = 'security_hotspots',
security_hotspots_reviewed = 'security_hotspots_reviewed',
+ security_issues = 'security_issues',
security_rating = 'security_rating',
security_rating_effort = 'security_rating_effort',
security_rating_distribution = 'security_rating_distribution',