height={100}
items={[
{ x: 1, y: 10, size: 7, data: 'foo' },
- { x: 2, y: 30, size: 5, color: 3, data: 'bar' },
+ { x: 2, y: 30, size: 5, data: 'bar' },
]}
padding={[0, 0, 0, 0]}
{...props}
...computeRating(issues, IssueType.Bug),
});
+ case MetricKey.software_quality_reliability_rating:
+ return mockMeasure({
+ metric: metricKey,
+ period: undefined,
+ ...computeRating(issues, IssueType.Bug),
+ });
+
case MetricKey.new_reliability_rating:
return mockMeasure({
metric: metricKey,
value: undefined,
});
+ case MetricKey.new_software_quality_reliability_rating:
+ return mockMeasure({
+ metric: metricKey,
+ period: {
+ index: 0,
+ ...computeRating(issues, IssueType.Bug),
+ },
+ value: undefined,
+ });
+
case MetricKey.sqale_rating:
return mockMeasure({
metric: metricKey,
...computeRating(issues, IssueType.CodeSmell),
});
+ case MetricKey.software_quality_maintainability_rating:
+ return mockMeasure({
+ metric: metricKey,
+ period: undefined,
+ ...computeRating(issues, IssueType.CodeSmell),
+ });
+
case MetricKey.new_maintainability_rating:
return mockMeasure({
metric: metricKey,
value: undefined,
});
+ case MetricKey.new_software_quality_maintainability_rating:
+ return mockMeasure({
+ metric: metricKey,
+ period: {
+ index: 0,
+ ...computeRating(issues, IssueType.CodeSmell),
+ },
+ value: undefined,
+ });
+
case MetricKey.security_rating:
return mockMeasure({
metric: metricKey,
...computeRating(issues, IssueType.Vulnerability),
});
+ case MetricKey.software_quality_security_rating:
+ return mockMeasure({
+ metric: metricKey,
+ period: undefined,
+ ...computeRating(issues, IssueType.Vulnerability),
+ });
+
case MetricKey.new_security_rating:
return mockMeasure({
metric: metricKey,
},
value: undefined,
});
+
+ case MetricKey.new_software_quality_security_rating:
+ return mockMeasure({
+ metric: metricKey,
+ period: {
+ index: 0,
+ ...computeRating(issues, IssueType.Vulnerability),
+ },
+ value: undefined,
+ });
}
}
function isIssueRelatedRating(metricKey: MetricKey) {
return [
MetricKey.reliability_rating,
+ MetricKey.software_quality_reliability_rating,
MetricKey.new_reliability_rating,
+ MetricKey.new_software_quality_reliability_rating,
MetricKey.sqale_rating,
+ MetricKey.software_quality_maintainability_rating,
MetricKey.new_maintainability_rating,
+ MetricKey.new_software_quality_maintainability_rating,
MetricKey.security_rating,
+ MetricKey.software_quality_security_rating,
MetricKey.new_security_rating,
+ MetricKey.new_software_quality_security_rating,
].includes(metricKey);
}
import { formatMeasure } from '~sonar-aligned/helpers/measures';
import { MetricKey, MetricType } from '~sonar-aligned/types/metrics';
import { getLeakValue } from '../../../components/measure/utils';
+import { SOFTWARE_QUALITY_RATING_METRICS_MAP } from '../../../helpers/constants';
import { isDiffMetric } from '../../../helpers/measures';
import { useMeasureQuery } from '../../../queries/measures';
import { useIsLegacyCCTMode } from '../../../queries/settings';
| MetricKey.releasability_rating;
function isNewRatingMetric(metricKey: MetricKey) {
- return metricKey.includes('_new');
+ return metricKey.includes('software_quality_');
}
const useGetMetricKeyForRating = (ratingMetric: RatingMetricKeys): MetricKey | null => {
if (isLoading) {
return null;
}
- return isLegacy ? ratingMetric : ((ratingMetric + '_new') as MetricKey);
+ return isLegacy ? ratingMetric : SOFTWARE_QUALITY_RATING_METRICS_MAP[ratingMetric];
};
export default function RatingComponent(props: Readonly<Props>) {
import ComponentsServiceMock from '../../../api/mocks/ComponentsServiceMock';
import { PARENT_COMPONENT_KEY, RULE_1 } from '../../../api/mocks/data/ids';
import IssuesServiceMock from '../../../api/mocks/IssuesServiceMock';
+import { MeasuresServiceMock } from '../../../api/mocks/MeasuresServiceMock';
import SettingsServiceMock from '../../../api/mocks/SettingsServiceMock';
import SourcesServiceMock from '../../../api/mocks/SourcesServiceMock';
import { CCT_SOFTWARE_QUALITY_METRICS } from '../../../helpers/constants';
const sourcesHandler = new SourcesServiceMock();
const issuesHandler = new IssuesServiceMock();
const settingsHandler = new SettingsServiceMock();
+const measuresHandler = new MeasuresServiceMock();
const JUPYTER_ISSUE = {
issue: mockRawIssue(false, {
sourcesHandler.reset();
issuesHandler.reset();
settingsHandler.reset();
+ measuresHandler.reset();
});
it('should allow navigating through the tree', async () => {
import withMetricsContext from '../../../app/components/metrics/withMetricsContext';
import { CodeScope, getCodeUrl, getProjectUrl } from '../../../helpers/urls';
import { WithBranchLikesProps, useBranchesQuery } from '../../../queries/branch';
-import {
- useComponentBreadcrumbsQuery,
- useComponentChildrenQuery,
- useComponentQuery,
-} from '../../../queries/component';
+import { useComponentBreadcrumbsQuery, useComponentQuery } from '../../../queries/component';
+import { useComponentTreeQuery } from '../../../queries/measures';
import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like';
import { Component, ComponentMeasure, Dict, Metric } from '../../../types/types';
import { getCodeMetrics } from '../utils';
data: componentWithChildren,
isLoading: isChildrenLoading,
fetchNextPage,
- } = useComponentChildrenQuery({
+ } = useComponentTreeQuery({
strategy: 'children',
component: location.query.selected ?? component.key,
metrics: getCodeMetrics(component.qualifier, branchLike, {
import { Location } from '~sonar-aligned/types/router';
import ListFooter from '../../../components/controls/ListFooter';
import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissingInfoMessage';
-import { CCT_SOFTWARE_QUALITY_METRICS, OLD_TAXONOMY_METRICS } from '../../../helpers/constants';
+import {
+ CCT_SOFTWARE_QUALITY_METRICS,
+ LEAK_OLD_TAXONOMY_RATINGS,
+ OLD_TAXONOMY_METRICS,
+ OLD_TAXONOMY_RATINGS,
+ SOFTWARE_QUALITY_RATING_METRICS,
+} from '../../../helpers/constants';
import { KeyboardKeys } from '../../../helpers/keycodes';
import { translate } from '../../../helpers/l10n';
-import { areCCTMeasuresComputed } from '../../../helpers/measures';
+import {
+ areCCTMeasuresComputed,
+ areSoftwareQualityRatingsComputed,
+} from '../../../helpers/measures';
import { BranchLike } from '../../../types/branch-like';
import { isApplication } from '../../../types/component';
import { Component, ComponentMeasure, Dict, Metric } from '../../../types/types';
const allComponentsHaveSoftwareQualityMeasures = components.every((component) =>
areCCTMeasuresComputed(component.measures),
);
+ const allComponentsHaveRatings = components.every((component) =>
+ areSoftwareQualityRatingsComputed(component.measures),
+ );
- const filteredMetrics = difference(
- metricKeys,
- allComponentsHaveSoftwareQualityMeasures ? OLD_TAXONOMY_METRICS : CCT_SOFTWARE_QUALITY_METRICS,
- ).map((key) => metrics[key]);
+ const filteredMetrics = difference(metricKeys, [
+ ...(allComponentsHaveSoftwareQualityMeasures
+ ? OLD_TAXONOMY_METRICS
+ : CCT_SOFTWARE_QUALITY_METRICS),
+ ...(allComponentsHaveRatings
+ ? [...OLD_TAXONOMY_RATINGS, ...LEAK_OLD_TAXONOMY_RATINGS]
+ : SOFTWARE_QUALITY_RATING_METRICS),
+ ]).map((key) => metrics[key]);
let defaultTitle = translate('code.page');
if (isApplication(baseComponent?.qualifier)) {
within(ui.measuresRow('folderA').get()).getByRole('cell', { name: '2' }),
).toBeInTheDocument();
+ await ui.arrowDown(); // Select the 1st element ("folderA")
await ui.arrowRight(); // Open "folderA"
await ui.arrowDown(); // Select the 1st element ("out.tsx")
x: MetricKey.ncloc,
y: MetricKey.reliability_remediation_effort,
size: MetricKey.reliability_issues,
- colors: [MetricKey.reliability_rating_new],
+ colors: [MetricKey.software_quality_reliability_rating],
},
Security: {
x: MetricKey.ncloc,
y: MetricKey.security_remediation_effort,
size: MetricKey.security_issues,
- colors: [MetricKey.security_rating_new],
+ colors: [MetricKey.software_quality_security_rating],
},
Maintainability: {
x: MetricKey.ncloc,
y: MetricKey.sqale_index,
size: MetricKey.maintainability_issues,
- colors: [MetricKey.sqale_rating_new],
+ colors: [MetricKey.software_quality_maintainability_rating],
},
Coverage: {
x: MetricKey.complexity,
x: MetricKey.sqale_index,
y: MetricKey.coverage,
size: MetricKey.ncloc,
- colors: [MetricKey.reliability_rating_new, MetricKey.security_rating_new],
+ colors: [
+ MetricKey.software_quality_reliability_rating,
+ MetricKey.software_quality_security_rating,
+ ],
yDomain: [100, 0],
},
};
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { MetricKey } from '~sonar-aligned/types/metrics';
+import { SOFTWARE_QUALITY_RATING_METRICS_MAP } from '../../../helpers/constants';
interface Domains {
[domain: string]: { categories?: string[]; order: string[] };
MetricKey.new_reliability_issues,
MetricKey.new_bugs,
MetricKey.new_reliability_rating,
- MetricKey.new_reliability_rating_new,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.new_reliability_rating],
MetricKey.new_reliability_remediation_effort,
- MetricKey.new_reliability_remediation_effort_new,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.new_reliability_remediation_effort],
OVERALL_CATEGORY,
MetricKey.reliability_issues,
MetricKey.bugs,
MetricKey.reliability_rating,
- MetricKey.reliability_rating_new,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.reliability_rating],
MetricKey.reliability_remediation_effort,
- MetricKey.reliability_remediation_effort_new,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.reliability_remediation_effort],
],
},
MetricKey.new_security_issues,
MetricKey.new_vulnerabilities,
MetricKey.new_security_rating,
- MetricKey.new_security_rating_new,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.new_security_rating],
MetricKey.new_security_remediation_effort,
- MetricKey.new_security_remediation_effort_new,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.new_security_remediation_effort],
OVERALL_CATEGORY,
MetricKey.security_issues,
MetricKey.vulnerabilities,
MetricKey.security_rating,
- MetricKey.security_rating_new,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.security_rating],
MetricKey.security_remediation_effort,
- MetricKey.security_remediation_effort_new,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.security_remediation_effort],
],
},
NEW_CODE_CATEGORY,
MetricKey.new_security_hotspots,
MetricKey.new_security_review_rating,
- MetricKey.new_security_review_rating_new,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.new_security_review_rating],
MetricKey.new_security_hotspots_reviewed,
OVERALL_CATEGORY,
MetricKey.security_hotspots,
MetricKey.security_review_rating,
- MetricKey.security_review_rating_new,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.security_review_rating],
MetricKey.security_hotspots_reviewed,
],
},
MetricKey.new_maintainability_issues,
MetricKey.new_code_smells,
MetricKey.new_technical_debt,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.new_technical_debt],
MetricKey.new_sqale_debt_ratio,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.new_sqale_debt_ratio],
MetricKey.new_maintainability_rating,
- MetricKey.new_maintainability_rating_new,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.new_maintainability_rating],
OVERALL_CATEGORY,
MetricKey.maintainability_issues,
MetricKey.code_smells,
MetricKey.sqale_index,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.sqale_index],
MetricKey.sqale_debt_ratio,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.sqale_debt_ratio],
MetricKey.sqale_rating,
- MetricKey.sqale_rating_new,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.sqale_rating],
MetricKey.effort_to_reach_maintainability_rating_a,
- MetricKey.effort_to_reach_maintainability_rating_a_new,
+ SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.effort_to_reach_maintainability_rating_a],
],
},
import A11ySkipTarget from '~sonar-aligned/components/a11y/A11ySkipTarget';
import { translate } from '../../../helpers/l10n';
import useFollowScroll from '../../../hooks/useFollowScroll';
+import { useIsLegacyCCTMode } from '../../../queries/settings';
import { Domain } from '../../../types/measures';
import { MeasureEnhanced } from '../../../types/types';
import { PROJECT_OVERVEW, Query, isProjectOverview, populateDomainsFromMeasures } from '../utils';
export default function Sidebar(props: Readonly<Props>) {
const { showFullMeasures, updateQuery, componentKey, selectedMetric, measures } = props;
const { top: topScroll, scrolledOnce } = useFollowScroll();
- const domains = populateDomainsFromMeasures(measures);
+ const { data: isLegacy } = useIsLegacyCCTMode();
+ const domains = populateDomainsFromMeasures(measures, isLegacy);
const handleChangeMetric = React.useCallback(
(metric: string) => {
MetricKey.new_violations,
];
-export const populateDomainsFromMeasures = memoize((measures: MeasureEnhanced[]): Domain[] => {
- let populatedMeasures = measures
- .filter((measure) => !DEPRECATED_METRICS.includes(measure.metric.key as MetricKey))
- .map((measure) => {
- const isDiff = isDiffMetric(measure.metric.key);
- const calculatedValue = getCCTMeasureValue(
- measure.metric.key,
- isDiff ? measure.leak : measure.value,
+export const populateDomainsFromMeasures = memoize(
+ (measures: MeasureEnhanced[], isLegacy?: boolean): Domain[] => {
+ let populatedMeasures = measures
+ .filter((measure) => !DEPRECATED_METRICS.includes(measure.metric.key as MetricKey))
+ .map((measure) => {
+ const isDiff = isDiffMetric(measure.metric.key);
+ const calculatedValue = getCCTMeasureValue(
+ measure.metric.key,
+ isDiff ? measure.leak : measure.value,
+ );
+
+ return {
+ ...measure,
+ ...{ [isDiff ? 'leak' : 'value']: calculatedValue },
+ };
+ });
+
+ if (!isLegacy && areLeakCCTMeasuresComputed(measures)) {
+ populatedMeasures = populatedMeasures.filter(
+ (measure) => !LEAK_OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey),
);
+ } else {
+ populatedMeasures = populatedMeasures.filter(
+ (measure) => !LEAK_CCT_SOFTWARE_QUALITY_METRICS.includes(measure.metric.key as MetricKey),
+ );
+ }
+
+ // Both new and overall code will exist after next analysis
+ if (!isLegacy && areSoftwareQualityRatingsComputed(measures)) {
+ populatedMeasures = populatedMeasures.filter(
+ (measure) =>
+ !OLD_TAXONOMY_RATINGS.includes(measure.metric.key as MetricKey) &&
+ !LEAK_OLD_TAXONOMY_RATINGS.includes(measure.metric.key as MetricKey),
+ );
+ } else {
+ populatedMeasures = populatedMeasures.filter(
+ (measure) => !SOFTWARE_QUALITY_RATING_METRICS.includes(measure.metric.key as MetricKey),
+ );
+ }
- return {
- ...measure,
- ...{ [isDiff ? 'leak' : 'value']: calculatedValue },
- };
- });
-
- if (areLeakCCTMeasuresComputed(measures)) {
- populatedMeasures = populatedMeasures.filter(
- (measure) => !LEAK_OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey),
- );
- }
-
- // Both new and overall code will exist after next analysis
- if (areSoftwareQualityRatingsComputed(measures)) {
- populatedMeasures = populatedMeasures.filter(
- (measure) =>
- !OLD_TAXONOMY_RATINGS.includes(measure.metric.key as MetricKey) &&
- !LEAK_OLD_TAXONOMY_RATINGS.includes(measure.metric.key as MetricKey),
- );
- }
-
- if (areCCTMeasuresComputed(measures)) {
- populatedMeasures = populatedMeasures.filter(
- (measure) => !OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey),
- );
- }
+ if (!isLegacy && areCCTMeasuresComputed(measures)) {
+ populatedMeasures = populatedMeasures.filter(
+ (measure) => !OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey),
+ );
+ } else {
+ populatedMeasures = populatedMeasures.filter(
+ (measure) => !CCT_SOFTWARE_QUALITY_METRICS.includes(measure.metric.key as MetricKey),
+ );
+ }
- return groupByDomains(populatedMeasures);
-});
+ return groupByDomains(populatedMeasures);
+ },
+);
export function getMetricSubnavigationName(
metric: Metric,
jest.mock('../../../../api/measures', () => {
return {
...jest.requireActual('../../../../sonar-aligned/types/metrics'),
- getMeasuresWithMetrics: jest.fn().mockResolvedValue({
+ getMeasuresWithPeriodAndMetrics: jest.fn().mockResolvedValue({
component: {
key: '',
name: '',
MetricKey.security_issues,
].every((key) => measures[key] === undefined);
const noRatingMetrics = [
- MetricKey.reliability_rating_new,
- MetricKey.sqale_rating_new,
- MetricKey.security_rating_new,
+ MetricKey.software_quality_reliability_rating,
+ MetricKey.software_quality_maintainability_rating,
+ MetricKey.software_quality_security_rating,
].every((key) => measures[key] === undefined);
const awaitingScan =
(noSoftwareQualityMetrics || noRatingMetrics) &&
};
const newRatings = {
- [MetricKey.reliability_rating_new]: mockMeasure({
- metric: MetricKey.reliability_rating_new,
+ [MetricKey.software_quality_reliability_rating]: mockMeasure({
+ metric: MetricKey.software_quality_reliability_rating,
value: '2',
}),
- [MetricKey.sqale_rating_new]: mockMeasure({
- metric: MetricKey.sqale_rating_new,
+ [MetricKey.software_quality_maintainability_rating]: mockMeasure({
+ metric: MetricKey.software_quality_maintainability_rating,
value: '2',
}),
- [MetricKey.security_rating_new]: mockMeasure({
- metric: MetricKey.security_rating_new,
+ [MetricKey.software_quality_security_rating]: mockMeasure({
+ metric: MetricKey.software_quality_security_rating,
value: '2',
}),
- [MetricKey.security_review_rating_new]: mockMeasure({
- metric: MetricKey.security_review_rating_new,
+ [MetricKey.software_quality_security_review_rating]: mockMeasure({
+ metric: MetricKey.software_quality_security_review_rating,
value: '2',
}),
};
HIGH: 0,
total: 3,
}),
- [MetricKey.sqale_rating_new]: '2',
- [MetricKey.reliability_rating_new]: '2',
- [MetricKey.security_rating_new]: '2',
- [MetricKey.security_review_rating_new]: '2',
+ [MetricKey.software_quality_maintainability_rating]: '2',
+ [MetricKey.software_quality_reliability_rating]: '2',
+ [MetricKey.software_quality_security_rating]: '2',
+ [MetricKey.software_quality_security_review_rating]: '2',
[MetricKey.code_smells]: '4',
[MetricKey.bugs]: '5',
[MetricKey.vulnerabilities]: '6',
HIGH: 0,
total: 3,
}),
- [MetricKey.sqale_rating_new]: '2',
- [MetricKey.reliability_rating_new]: '2',
- [MetricKey.security_rating_new]: '2',
- [MetricKey.security_review_rating_new]: '2',
+ [MetricKey.software_quality_maintainability_rating]: '2',
+ [MetricKey.software_quality_reliability_rating]: '2',
+ [MetricKey.software_quality_security_rating]: '2',
+ [MetricKey.software_quality_security_review_rating]: '2',
[MetricKey.code_smells]: '4',
[MetricKey.bugs]: '5',
[MetricKey.vulnerabilities]: '6',
];
export const OLD_TAXONOMY_RATINGS = [
+ MetricKey.releasability_rating,
MetricKey.sqale_rating,
MetricKey.security_rating,
MetricKey.reliability_rating,
MetricKey.security_review_rating,
+ MetricKey.sqale_index,
+ MetricKey.reliability_remediation_effort,
+ MetricKey.security_remediation_effort,
+ MetricKey.sqale_debt_ratio,
+ MetricKey.effort_to_reach_maintainability_rating_a,
];
export const LEAK_OLD_TAXONOMY_RATINGS = [
MetricKey.new_security_rating,
MetricKey.new_reliability_rating,
MetricKey.new_security_review_rating,
+ MetricKey.new_technical_debt,
+ MetricKey.new_security_remediation_effort,
+ MetricKey.new_reliability_remediation_effort,
+ MetricKey.new_sqale_debt_ratio,
];
export const OLD_TO_NEW_TAXONOMY_METRICS_MAP: { [key in MetricKey]?: MetricKey } = {
];
export const SOFTWARE_QUALITY_RATING_METRICS_MAP: Record<string, MetricKey> = {
- [MetricKey.sqale_rating]: MetricKey.sqale_rating_new,
- [MetricKey.security_rating]: MetricKey.security_rating_new,
- [MetricKey.reliability_rating]: MetricKey.reliability_rating_new,
- [MetricKey.security_review_rating]: MetricKey.security_review_rating_new,
- [MetricKey.releasability_rating]: MetricKey.releasability_rating_new,
- [MetricKey.new_maintainability_rating]: MetricKey.new_maintainability_rating_new,
- [MetricKey.new_security_rating]: MetricKey.new_security_rating_new,
- [MetricKey.new_reliability_rating]: MetricKey.new_reliability_rating_new,
- [MetricKey.new_security_review_rating]: MetricKey.new_security_review_rating_new,
+ [MetricKey.releasability_rating]: MetricKey.software_quality_releasability_rating,
+ [MetricKey.sqale_rating]: MetricKey.software_quality_maintainability_rating,
+ [MetricKey.security_rating]: MetricKey.software_quality_security_rating,
+ [MetricKey.reliability_rating]: MetricKey.software_quality_reliability_rating,
+ [MetricKey.security_review_rating]: MetricKey.software_quality_security_review_rating,
+ [MetricKey.reliability_remediation_effort]:
+ MetricKey.software_quality_reliability_remediation_effort,
+ [MetricKey.security_remediation_effort]: MetricKey.software_quality_security_remediation_effort,
+ [MetricKey.sqale_index]: MetricKey.software_quality_maintainability_remediation_effort,
+ [MetricKey.sqale_debt_ratio]: MetricKey.software_quality_maintainability_debt_ratio,
+ [MetricKey.effort_to_reach_maintainability_rating_a]:
+ MetricKey.effort_to_reach_software_quality_maintainability_rating_a,
+ [MetricKey.new_maintainability_rating]: MetricKey.new_software_quality_maintainability_rating,
+ [MetricKey.new_security_rating]: MetricKey.new_software_quality_security_rating,
+ [MetricKey.new_reliability_rating]: MetricKey.new_software_quality_reliability_rating,
+ [MetricKey.new_security_review_rating]: MetricKey.new_software_quality_security_review_rating,
+ [MetricKey.new_technical_debt]: MetricKey.new_software_quality_maintainability_remediation_effort,
+ [MetricKey.new_reliability_remediation_effort]:
+ MetricKey.new_software_quality_reliability_remediation_effort,
+ [MetricKey.new_security_remediation_effort]:
+ MetricKey.new_software_quality_security_remediation_effort,
+ [MetricKey.new_sqale_debt_ratio]: MetricKey.new_software_quality_maintainability_debt_ratio,
};
export const SOFTWARE_QUALITY_RATING_METRICS = [
- MetricKey.sqale_rating_new,
- MetricKey.security_rating_new,
- MetricKey.reliability_rating_new,
- MetricKey.security_review_rating_new,
- MetricKey.releasability_rating_new,
- MetricKey.new_maintainability_rating_new,
- MetricKey.new_security_rating_new,
- MetricKey.new_reliability_rating_new,
- MetricKey.new_security_review_rating_new,
+ MetricKey.software_quality_releasability_rating,
+ MetricKey.software_quality_maintainability_rating,
+ MetricKey.software_quality_security_rating,
+ MetricKey.software_quality_reliability_rating,
+ MetricKey.software_quality_security_review_rating,
+ MetricKey.software_quality_maintainability_remediation_effort,
+ MetricKey.software_quality_reliability_remediation_effort,
+ MetricKey.software_quality_security_remediation_effort,
+ MetricKey.software_quality_maintainability_debt_ratio,
+ MetricKey.effort_to_reach_software_quality_maintainability_rating_a,
+ MetricKey.new_software_quality_maintainability_rating,
+ MetricKey.new_software_quality_security_rating,
+ MetricKey.new_software_quality_reliability_rating,
+ MetricKey.new_software_quality_security_review_rating,
+ MetricKey.new_software_quality_maintainability_remediation_effort,
+ MetricKey.new_software_quality_reliability_remediation_effort,
+ MetricKey.new_software_quality_security_remediation_effort,
+ MetricKey.new_software_quality_maintainability_debt_ratio,
];
export const PROJECT_KEY_MAX_LEN = 400;
CCT_SOFTWARE_QUALITY_METRICS,
LEAK_CCT_SOFTWARE_QUALITY_METRICS,
LEAK_OLD_TAXONOMY_METRICS,
- SOFTWARE_QUALITY_RATING_METRICS,
} from './constants';
import { translate } from './l10n';
import { isDefined } from './types';
);
}
export function areSoftwareQualityRatingsComputed(measures?: Measure[] | MeasureEnhanced[]) {
- return SOFTWARE_QUALITY_RATING_METRICS.every((metric) =>
+ return [
+ MetricKey.software_quality_security_rating,
+ MetricKey.software_quality_security_rating,
+ MetricKey.software_quality_maintainability_rating,
+ ].every((metric) =>
measures?.find((measure) =>
isMeasureEnhanced(measure) ? measure.metric.key === metric : measure.metric === metric,
),
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import {
- infiniteQueryOptions,
- queryOptions,
- useQuery,
- useQueryClient,
-} from '@tanstack/react-query';
+import { queryOptions, useQuery, useQueryClient } from '@tanstack/react-query';
import { groupBy, omit } from 'lodash';
import { BranchParameters } from '~sonar-aligned/types/branch-like';
import { getTasksForComponent } from '../api/ce';
-import {
- getBreadcrumbs,
- getComponent,
- getComponentData,
- getComponentTree,
-} from '../api/components';
-import { getNextPageParam, getPreviousPageParam } from '../helpers/react-query';
+import { getBreadcrumbs, getComponent, getComponentData } from '../api/components';
import { MetricKey } from '../sonar-aligned/types/metrics';
import { Component, Measure } from '../types/types';
-import { StaleTime, createInfiniteQueryHook, createQueryHook } from './common';
+import { StaleTime, createQueryHook } from './common';
const NEW_METRICS = [
MetricKey.software_quality_maintainability_rating,
},
);
-export const useComponentChildrenQuery = createInfiniteQueryHook(
- ({
- strategy,
- component,
- metrics,
- additionalData,
- }: {
- additionalData: Parameters<typeof getComponentTree>[3];
- component: Parameters<typeof getComponentTree>[1];
- metrics: Parameters<typeof getComponentTree>[2];
- strategy: 'children' | 'leaves';
- }) => {
- const queryClient = useQueryClient();
- return infiniteQueryOptions({
- queryKey: ['component', component, 'tree', strategy, { metrics, additionalData }],
- queryFn: async ({ pageParam }) => {
- const result = await getComponentTree(
- strategy,
- component,
- metrics?.filter((m) => !NEW_METRICS.includes(m as MetricKey)),
- { ...additionalData, p: pageParam },
- );
- const measuresMapByMetricKeyForBaseComponent = groupBy(
- result.baseComponent.measures,
- 'metric',
- );
- metrics?.forEach((metricKey) => {
- const measure = measuresMapByMetricKeyForBaseComponent[metricKey]?.[0] ?? null;
- queryClient.setQueryData<Measure>(
- ['measures', 'details', result.baseComponent.key, metricKey],
- measure,
- );
- });
-
- result.components.forEach((childComponent) => {
- const measuresMapByMetricKeyForChildComponent = groupBy(
- childComponent.measures,
- 'metric',
- );
- metrics?.forEach((metricKey) => {
- const measure = measuresMapByMetricKeyForChildComponent[metricKey]?.[0] ?? null;
- queryClient.setQueryData<Measure>(
- ['measures', 'details', childComponent.key, metricKey],
- measure,
- );
- });
- });
- return result;
- },
- getNextPageParam: (data) => getNextPageParam({ page: data.paging }),
- getPreviousPageParam: (data) => getPreviousPageParam({ page: data.paging }),
- initialPageParam: 1,
- staleTime: 60_000,
- });
- },
-);
-
export const useComponentDataQuery = createQueryHook(
(data: Parameters<typeof getComponentData>[0]) => {
return queryOptions({
import { MetricKey } from '../sonar-aligned/types/metrics';
import { BranchLike } from '../types/branch-like';
import { Measure } from '../types/types';
-import {createInfiniteQueryHook, createQueryHook} from './common';
+import { createInfiniteQueryHook, createQueryHook } from './common';
const NEW_METRICS = [
MetricKey.software_quality_maintainability_rating,
{ ...additionalData, p: pageParam, ...branchLikeQuery },
);
- // const measuresMapByMetricKeyForBaseComponent = groupBy(
- // result.baseComponent.measures,
- // 'metric',
- // );
- // metrics?.forEach((metricKey) => {
- // const measure = measuresMapByMetricKeyForBaseComponent[metricKey]?.[0] ?? null;
- // queryClient.setQueryData<Measure>(
- // [
- // 'measures',
- // 'details',
- // result.baseComponent.key,
- // 'branchLike',
- // branchLikeQuery,
- // metricKey,
- // ],
- // measure,
- // );
- // });
+ if (result.baseComponent.measures && result.baseComponent.measures.length > 0) {
+ const measuresMapByMetricKeyForBaseComponent = groupBy(
+ result.baseComponent.measures,
+ 'metric',
+ );
+ metrics?.forEach((metricKey) => {
+ const measure = measuresMapByMetricKeyForBaseComponent[metricKey]?.[0] ?? null;
+ queryClient.setQueryData<Measure>(
+ [
+ 'measures',
+ 'details',
+ result.baseComponent.key,
+ 'branchLike',
+ branchLikeQuery,
+ metricKey,
+ ],
+ measure,
+ );
+ });
+ }
+
result.components.forEach((childComponent) => {
const measuresMapByMetricKeyForChildComponent = groupBy(
childComponent.measures,
new_reliability_rating_distribution = 'new_reliability_rating_distribution',
new_software_quality_reliability_rating_distribution = 'new_software_quality_reliability_rating_distribution',
new_reliability_remediation_effort = 'new_reliability_remediation_effort',
- new_reliability_remediation_effort_new = 'new_reliability_remediation_effort_new',
+ new_software_quality_reliability_remediation_effort = 'new_software_quality_reliability_remediation_effort',
new_security_hotspots = 'new_security_hotspots',
new_security_hotspots_reviewed = 'new_security_hotspots_reviewed',
new_security_issues = 'new_security_issues',
new_security_rating_distribution = 'new_security_rating_distribution',
new_software_quality_security_rating_distribution = 'new_software_quality_security_rating_distribution',
new_security_remediation_effort = 'new_security_remediation_effort',
- new_security_remediation_effort_new = 'new_security_remediation_effort_new',
+ new_software_quality_security_remediation_effort = 'new_software_quality_security_remediation_effort',
new_security_review_rating = 'new_security_review_rating',
new_software_quality_security_review_rating = 'new_software_quality_security_review_rating',
new_security_review_rating_distribution = 'new_security_review_rating_distribution',
new_software_quality_security_review_rating_distribution = 'new_software_quality_security_review_rating_distribution',
new_sqale_debt_ratio = 'new_sqale_debt_ratio',
+ new_software_quality_maintainability_debt_ratio = 'new_software_quality_maintainability_debt_ratio',
new_technical_debt = 'new_technical_debt',
+ new_software_quality_maintainability_remediation_effort = 'new_software_quality_maintainability_remediation_effort',
new_uncovered_conditions = 'new_uncovered_conditions',
new_uncovered_lines = 'new_uncovered_lines',
new_violations = 'new_violations',
software_quality_reliability_rating_distribution = 'software_quality_reliability_rating_distribution',
reliability_rating_effort = 'reliability_rating_effort',
reliability_remediation_effort = 'reliability_remediation_effort',
- reliability_remediation_effort_new = 'reliability_remediation_effort_new',
+ software_quality_reliability_remediation_effort = 'software_quality_reliability_remediation_effort',
reopened_issues = 'reopened_issues',
security_hotspots = 'security_hotspots',
security_hotspots_reviewed = 'security_hotspots_reviewed',
software_quality_security_rating_distribution = 'software_quality_security_rating_distribution',
security_rating_effort = 'security_rating_effort',
security_remediation_effort = 'security_remediation_effort',
- security_remediation_effort_new = 'security_remediation_effort_new',
+ software_quality_security_remediation_effort = 'software_quality_security_remediation_effort',
security_review_rating = 'security_review_rating',
software_quality_security_review_rating = 'software_quality_security_review_rating',
security_review_rating_distribution = 'security_review_rating_distribution',
skipped_tests = 'skipped_tests',
sonarjava_feedback = 'sonarjava_feedback',
sqale_debt_ratio = 'sqale_debt_ratio',
+ software_quality_maintainability_debt_ratio = 'software_quality_maintainability_debt_ratio',
sqale_index = 'sqale_index',
+ software_quality_maintainability_remediation_effort = 'software_quality_maintainability_remediation_effort',
sqale_rating = 'sqale_rating',
software_quality_maintainability_rating = 'software_quality_maintainability_rating',
statements = 'statements',