import DocumentationLink from '../../components/common/DocumentationLink';
import { DocLink } from '../../helpers/doc-links';
import { translate } from '../../helpers/l10n';
+import { useIsLegacyCCTMode } from '../../queries/settings';
import { ComponentQualifier } from '../../sonar-aligned/types/component';
interface Props {
export default function ChangeInCalculation({ qualifier }: Readonly<Props>) {
const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);
- // const { data: isLegacy, isLoading } = useIsLegacyCCTMode();
+ const { data: isLegacy, isLoading } = useIsLegacyCCTMode();
- // if (isLegacy || isLoading) {
- // return null;
- // }
+ if (isLegacy || isLoading) {
+ return null;
+ }
return (
<Popover
);
const filteredMetrics = difference(metricKeys, [
- ...(allComponentsHaveSoftwareQualityMeasures
+ ...(allComponentsHaveSoftwareQualityMeasures && !isLegacy
? OLD_TAXONOMY_METRICS
: CCT_SOFTWARE_QUALITY_METRICS),
...(allComponentsHaveRatings && !isLegacy
await user.click(ui.maintainabilityDomainBtn.get());
[
'component_measures.metric.new_maintainability_issues.name 5',
- 'Added Technical Debt work_duration.x_minutes.1',
- 'Technical Debt Ratio on New Code 1.0%',
- 'Maintainability Rating on New Code metric.has_rating_X.E metric.sqale_rating.tooltip.E.0.0%',
+ 'Software Quality Maintainability Remediation Effort on new code work_duration.x_minutes.1',
+ 'Software Quality Technical Debt Ratio on New Code 1.0%',
+ 'Software Quality Maintainability Rating on New Code metric.has_rating_X.D metric.software_quality_maintainability_rating.tooltip.D.0.0%',
'component_measures.metric.maintainability_issues.name 2',
- 'Technical Debt work_duration.x_minutes.1',
- 'Technical Debt Ratio 1.0%',
- 'Maintainability Rating metric.has_rating_X.E metric.sqale_rating.tooltip.E.0.0%',
- 'Effort to Reach Maintainability Rating A work_duration.x_minutes.1',
+ 'Software Quality Maintainability Remediation Effort work_duration.x_minutes.1',
+ 'Software Quality Technical Debt Ratio 1.0%',
+ 'Software Quality Maintainability Rating metric.has_rating_X.D metric.software_quality_maintainability_rating.tooltip.D.0.0%',
+ 'Software Quality Effort to Reach Maintainability Rating A work_duration.x_minutes.1',
].forEach((measure) => {
expect(ui.measureLink(measure).get()).toBeInTheDocument();
});
});
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should correctly render the default overview and navigation in legacy mode', async () => {
+ it('should correctly render the default overview and navigation in legacy mode', async () => {
settingsHandler.set(SettingsKey.LegacyMode, 'true');
const { ui, user } = getPageObject();
renderMeasuresApp();
].forEach((measure) => {
expect(ui.measureLink(measure).get()).toBeInTheDocument();
});
- // expect(screen.getByText('overview.missing_project_dataTRK')).toBeInTheDocument();
+ expect(screen.getByText('overview.missing_project_dataTRK')).toBeInTheDocument();
});
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should show old measures and no flag message if no rating measures and legacy mode', async () => {
+ it('should show old measures and no flag message if no rating measures and legacy mode', async () => {
settingsHandler.set(SettingsKey.LegacyMode, 'true');
measuresHandler.deleteComponentMeasure(
'foo',
await user.click(
ui
.measureLink(
- 'Maintainability Rating on New Code metric.has_rating_X.E metric.sqale_rating.tooltip.E.0.0%',
+ 'Software Quality Maintainability Rating metric.has_rating_X.D metric.software_quality_maintainability_rating.tooltip.D.0.0%',
)
.get(),
);
import '../../../components/search-navigator.css';
import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissingInfoMessage';
import { translate } from '../../../helpers/l10n';
-import { areCCTMeasuresComputed } from '../../../helpers/measures';
+import {
+ areCCTMeasuresComputed,
+ areSoftwareQualityRatingsComputed,
+} from '../../../helpers/measures';
import { useCurrentBranchQuery } from '../../../queries/branch';
import { useMeasuresComponentQuery } from '../../../queries/measures';
/>
</FlagMessage>
)}
- {!areCCTMeasuresComputed(measures) && (
+ {(!areCCTMeasuresComputed(measures) ||
+ !areSoftwareQualityRatingsComputed(measures)) && (
<AnalysisMissingInfoMessage
className="sw-mb-4"
qualifier={component?.qualifier as ComponentQualifier}
};
});
- if (areLeakCCTMeasuresComputed(measures)) {
+ if (!isLegacy && areLeakCCTMeasuresComputed(measures)) {
populatedMeasures = populatedMeasures.filter(
(measure) => !LEAK_OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey),
);
);
}
- if (areCCTMeasuresComputed(measures)) {
+ if (!isLegacy && areCCTMeasuresComputed(measures)) {
populatedMeasures = populatedMeasures.filter(
(measure) => !OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey),
);
import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissingInfoMessage';
import { parseDate } from '../../../helpers/dates';
import { translate } from '../../../helpers/l10n';
-import { areCCTMeasuresComputed, isDiffMetric } from '../../../helpers/measures';
+import {
+ areCCTMeasuresComputed,
+ areSoftwareQualityRatingsComputed,
+ isDiffMetric,
+} from '../../../helpers/measures';
import { CodeScope } from '../../../helpers/urls';
import { useProjectAiCodeAssuredQuery } from '../../../queries/ai-code-assurance';
import { useDismissNoticeMutation } from '../../../queries/users';
);
// Check if any potentially missing uncomputed measure is not present
- // const isMissingMeasures =
- // !areCCTMeasuresComputed(measures) || !areSoftwareQualityRatingsComputed(measures);
- const isMissingMeasures = !areCCTMeasuresComputed(measures);
+ const isMissingMeasures =
+ !areCCTMeasuresComputed(measures) || !areSoftwareQualityRatingsComputed(measures);
const selectTab = (tab: CodeScope) => {
router.replace({ query: { ...query, codeScope: tab } });
getIssueTypeBySoftwareQuality,
} from '../../../helpers/issues';
import { isDefined } from '../../../helpers/types';
+import { useIsLegacyCCTMode } from '../../../queries/settings';
import { Branch } from '../../../types/branch-like';
import { SoftwareImpactMeasureData, SoftwareQuality } from '../../../types/clean-code-taxonomy';
import { QualityGateStatusConditionEnhanced } from '../../../types/quality-gates';
const { component, conditions, softwareQuality, ratingMetricKey, measures, branch } = props;
const intl = useIntl();
- // const { data: isLegacy } = useIsLegacyCCTMode();
+ const { data: isLegacy } = useIsLegacyCCTMode();
// Find measure for this software quality
const metricKey = softwareQualityToMeasure(softwareQuality);
const measureRaw = measures.find((m) => m.metric.key === metricKey);
- const measure = JSON.parse(measureRaw?.value ?? 'null') as SoftwareImpactMeasureData;
+ const measure = isLegacy
+ ? undefined
+ : (JSON.parse(measureRaw?.value ?? 'null') as SoftwareImpactMeasureData);
const alternativeMeasure = measures.find(
(m) => m.metric.key === SOFTWARE_QUALITIES_METRIC_KEYS_MAP[softwareQuality].deprecatedMetric,
);
'overview.measures.software_impact.improve_rating_tooltip.A.software_quality.RELIABILITY.software_quality.reliability.A.overview.measures.software_impact.severity.LOW.improve_tooltip',
);
- ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Maintainability, 'E', 2);
+ ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Maintainability, 'D', 2);
await ui.expectSoftwareImpactMeasureCardRatingTooltip(
SoftwareQuality.Maintainability,
- 'E',
- 'overview.measures.software_impact.improve_rating_tooltip.MAINTAINABILITY.software_quality.MAINTAINABILITY.software_quality.maintainability.E.overview.measures.software_impact.severity.HIGH.improve_tooltip',
+ 'D',
+ 'overview.measures.software_impact.improve_rating_tooltip.MAINTAINABILITY.software_quality.MAINTAINABILITY.software_quality.maintainability.D.overview.measures.software_impact.severity.HIGH.improve_tooltip',
);
});
await user.click(await ui.overallCodeButton.find());
- ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Maintainability, 'E', 2, '');
+ ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Maintainability, 'D', 2, '');
});
it('should render old measures if software impact are missing', async () => {
},
);
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should display info about missing analysis if a project did not compute ratings', async () => {
+ it('should display info about missing analysis if a project did not compute ratings', async () => {
measuresHandler.deleteComponentMeasure('foo', MetricKey.software_quality_security_rating);
measuresHandler.deleteComponentMeasure(
'foo',
).toBeInTheDocument();
});
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should display old measures if in legacy mode', async () => {
+ it('should display old measures if in legacy mode', async () => {
settingsHandler.set(SettingsKey.LegacyMode, 'true');
const { user, ui } = getPageObjects();
renderBranchOverview();
});
describe('ratings', () => {
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should combine old and new rating + gaps', async () => {
+ it('should combine old and new rating + gaps', async () => {
timeMachineHandler.setMeasureHistory([
mockMeasureHistory({
metric: MetricKey.reliability_rating,
expect(ui.gapInfoMessage.get()).toBeInTheDocument();
});
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should not show old rating if new one was always there', async () => {
+ it('should not show old rating if new one was always there', async () => {
timeMachineHandler.setMeasureHistory([
mockMeasureHistory({
metric: MetricKey.reliability_rating,
).toBeInTheDocument();
});
-// eslint-disable-next-line jest/no-disabled-tests
-it.skip('should show non legacy filters', async () => {
+it('should show non legacy filters', async () => {
settingsHandler.set(SettingsKey.LegacyMode, 'false');
renderPageSidebar();
MetricKey.maintainability_issues,
MetricKey.security_issues,
].every((key) => measures[key] === undefined);
- // const noRatingMetrics = [
- // MetricKey.software_quality_reliability_rating,
- // MetricKey.software_quality_maintainability_rating,
- // MetricKey.software_quality_security_rating,
- // ].every((key) => measures[key] === undefined);
+ const noRatingMetrics = [
+ MetricKey.software_quality_reliability_rating,
+ MetricKey.software_quality_maintainability_rating,
+ MetricKey.software_quality_security_rating,
+ ].every((key) => measures[key] === undefined);
const awaitingScan =
- noSoftwareQualityMetrics &&
+ (noSoftwareQualityMetrics || noRatingMetrics) &&
!isNewCode &&
!isEmpty(analysisDate) &&
measures.ncloc !== undefined;
import { duplicationRatingConverter } from '../../../../components/measure/utils';
import { translate } from '../../../../helpers/l10n';
import { isDefined } from '../../../../helpers/types';
+import { useIsLegacyCCTMode } from '../../../../queries/settings';
import { Dict } from '../../../../types/types';
import ProjectCardMeasure from './ProjectCardMeasure';
);
}
-function renderRatings(props: ProjectCardMeasuresProps) {
+function renderRatings(props: ProjectCardMeasuresProps, isLegacy: boolean) {
const { isNewCode, measures, componentKey } = props;
const measuresByCodeLeak = isNewCode
iconLabel: translate(`metric.${MetricKey.security_issues}.short_name`),
noShrink: true,
metricKey:
- measures[MetricKey.security_issues] === undefined
+ isLegacy || measures[MetricKey.security_issues] === undefined
? MetricKey.vulnerabilities
: MetricKey.security_issues,
metricRatingKey: MetricKey.security_rating,
{
iconLabel: translate(`metric.${MetricKey.reliability_issues}.short_name`),
metricKey:
- measures[MetricKey.reliability_issues] === undefined
+ isLegacy || measures[MetricKey.reliability_issues] === undefined
? MetricKey.bugs
: MetricKey.reliability_issues,
metricRatingKey: MetricKey.reliability_rating,
{
iconLabel: translate(`metric.${MetricKey.maintainability_issues}.short_name`),
metricKey:
- measures[MetricKey.maintainability_issues] === undefined
+ isLegacy || measures[MetricKey.maintainability_issues] === undefined
? MetricKey.code_smells
: MetricKey.maintainability_issues,
metricRatingKey: MetricKey.sqale_rating,
export default function ProjectCardMeasures(props: ProjectCardMeasuresProps) {
const { isNewCode, measures, componentQualifier } = props;
- // const { data: isLegacy } = useIsLegacyCCTMode();
+ const { data: isLegacy } = useIsLegacyCCTMode();
const { ncloc } = measures;
const measureList = [
renderNewIssues(props),
- ...renderRatings(props),
+ ...renderRatings(props, !!isLegacy),
renderCoverage(props),
renderDuplication(props),
].filter(isDefined);
value: '3',
}),
};
-
beforeEach(() => {
measuresHandler.setComponents({
component: mockComponent({ key: PROJECT.key }),
[PROJECT.key]: oldRatings,
});
});
-
it('should not display awaiting analysis badge and do not display old measures', async () => {
measuresHandler.registerComponentMeasures({
- [PROJECT.key]: {
- ...newRatings,
- ...oldRatings,
- },
+ [PROJECT.key]: newRatings,
});
renderProjectCard({
...PROJECT,
expect(screen.getByText('1')).toBeInTheDocument();
expect(screen.getByText('2')).toBeInTheDocument();
expect(screen.getByText('3')).toBeInTheDocument();
- await waitFor(() => expect(screen.getAllByText('A')).toHaveLength(3));
+ await waitFor(() => expect(screen.getAllByText('B')).toHaveLength(3));
await waitFor(() => expect(screen.getAllByText('C')).toHaveLength(1));
expect(screen.queryByText('projects.awaiting_scan')).not.toBeInTheDocument();
expect(screen.queryByText('4')).not.toBeInTheDocument();
expect(screen.queryByText('5')).not.toBeInTheDocument();
expect(screen.queryByText('6')).not.toBeInTheDocument();
- expect(screen.queryByText('B')).not.toBeInTheDocument();
+ expect(screen.queryByText('A')).not.toBeInTheDocument();
});
it('should display awaiting analysis badge and show the old measures', async () => {
[MetricKey.vulnerabilities]: '6',
},
});
- expect(await screen.findByText('1')).toBeInTheDocument();
- expect(screen.queryByText('projects.awaiting_scan')).not.toBeInTheDocument();
-
+ expect(await screen.findByText('projects.awaiting_scan')).toBeInTheDocument();
+ expect(screen.getByText('1')).toBeInTheDocument();
expect(screen.getByText('2')).toBeInTheDocument();
expect(screen.getByText('3')).toBeInTheDocument();
expect(screen.queryByText('4')).not.toBeInTheDocument();
expect(screen.queryByText('projects.awaiting_scan')).not.toBeInTheDocument();
});
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should not display awaiting analysis badge if legacy mode is enabled', async () => {
+ it('should not display awaiting analysis badge if legacy mode is enabled', async () => {
settingsHandler.set(SettingsKey.LegacyMode, 'true');
renderProjectCard({
...PROJECT,
expect(screen.queryByText('projects.awaiting_scan')).not.toBeInTheDocument();
});
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should not display new values if legacy mode is enabled', async () => {
+ it('should not display new values if legacy mode is enabled', async () => {
settingsHandler.set(SettingsKey.LegacyMode, 'true');
measuresHandler.registerComponentMeasures({
[PROJECT.key]: {
import * as React from 'react';
import { FormattedMessage, useIntl } from 'react-intl';
import { DocLink } from '../../helpers/doc-links';
+import { useIsLegacyCCTMode } from '../../queries/settings';
import DocumentationLink from '../common/DocumentationLink';
interface AnalysisMissingInfoMessageProps {
qualifier,
className,
}: Readonly<AnalysisMissingInfoMessageProps>) {
+ const { data: isLegacy, isLoading } = useIsLegacyCCTMode();
const intl = useIntl();
- // const { data: isLegacy, isLoading } = useIsLegacyCCTMode();
- if (hide) {
+ if (hide || isLoading || isLegacy) {
return null;
}
setSimpleSettingValue,
} from '../api/settings';
import { translate } from '../helpers/l10n';
-import { ExtendedSettingDefinition } from '../types/settings';
+import { ExtendedSettingDefinition, SettingsKey } from '../types/settings';
import { createQueryHook } from './common';
import { invalidateAllMeasures } from './measures';
);
export const useIsLegacyCCTMode = () => {
- return useQuery({
- queryKey: ['mocked-legacy-mode'],
- queryFn: () => Promise.resolve(true),
- });
- // return useGetValueQuery(
- // { key: SettingsKey.LegacyMode },
- // { staleTime: Infinity, select: (data) => data?.value === 'true' },
- // );
+ return useGetValueQuery(
+ { key: SettingsKey.LegacyMode },
+ { staleTime: Infinity, select: (data) => data?.value === 'true' },
+ );
};
export function useResetSettingsMutation() {