From: Ambroise C Date: Thu, 9 Mar 2023 10:37:28 +0000 (+0100) Subject: SONAR-18638 Remove deprecated fields in Rule API response X-Git-Tag: 10.0.0.68432~149 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=82c7e9e96b598e50cdc90f7927213d21e7c6ff10;p=sonarqube.git SONAR-18638 Remove deprecated fields in Rule API response --- diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx index 6f248fcb6cc..d74f0b6bd07 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx @@ -179,18 +179,17 @@ export default class RuleDetailsMeta extends React.PureComponent { renderRemediation = () => { const { ruleDetails } = this.props; - if (!ruleDetails.debtRemFnType) { + if (!ruleDetails.remFnType) { return null; } return (
  • - {translate('coding_rules.remediation_function', ruleDetails.debtRemFnType)} + {translate('coding_rules.remediation_function', ruleDetails.remFnType)} {':'} - {ruleDetails.debtRemFnOffset !== undefined && ` ${ruleDetails.debtRemFnOffset}`} - {ruleDetails.debtRemFnCoeff !== undefined && ` +${ruleDetails.debtRemFnCoeff}`} - {ruleDetails.effortToFixDescription !== undefined && - ` ${ruleDetails.effortToFixDescription}`} + {ruleDetails.remFnBaseEffort !== undefined && ` ${ruleDetails.remFnBaseEffort}`} + {ruleDetails.remFnGapMultiplier !== undefined && ` +${ruleDetails.remFnGapMultiplier}`} + {ruleDetails.gapDescription !== undefined && ` ${ruleDetails.gapDescription}`}
  • ); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsMeta-test.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsMeta-test.tsx index 2da3cd49a4d..723c9cad1b4 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsMeta-test.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsMeta-test.tsx @@ -35,6 +35,10 @@ const RULE: RuleDetails = { langName: 'Java', scope: 'MAIN', type: 'CODE_SMELL', + remFnType: 'LINEAR_OFFSET', + remFnBaseEffort: '1min', + remFnGapMultiplier: '2min', + gapDescription: 'per test', }; const EXTERNAL_RULE: RuleDetails = { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap index 1ac517499da..7b2ac325222 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap @@ -22,11 +22,6 @@ exports[`should render correctly: loaded 1`] = ` ruleDetails={ { "createdAt": "2014-12-16T17:26:54+0100", - "debtOverloaded": false, - "debtRemFnOffset": "5min", - "debtRemFnType": "CONSTANT_ISSUE", - "defaultDebtRemFnOffset": "5min", - "defaultDebtRemFnType": "CONSTANT_ISSUE", "defaultRemFnBaseEffort": "5min", "defaultRemFnType": "CONSTANT_ISSUE", "descriptionSections": [ @@ -64,11 +59,6 @@ exports[`should render correctly: loaded 1`] = ` ruleDetails={ { "createdAt": "2014-12-16T17:26:54+0100", - "debtOverloaded": false, - "debtRemFnOffset": "5min", - "debtRemFnType": "CONSTANT_ISSUE", - "defaultDebtRemFnOffset": "5min", - "defaultDebtRemFnType": "CONSTANT_ISSUE", "defaultRemFnBaseEffort": "5min", "defaultRemFnType": "CONSTANT_ISSUE", "descriptionSections": [ @@ -137,11 +127,6 @@ exports[`should render correctly: loaded 1`] = ` ruleDetails={ { "createdAt": "2014-12-16T17:26:54+0100", - "debtOverloaded": false, - "debtRemFnOffset": "5min", - "debtRemFnType": "CONSTANT_ISSUE", - "defaultDebtRemFnOffset": "5min", - "defaultDebtRemFnType": "CONSTANT_ISSUE", "defaultRemFnBaseEffort": "5min", "defaultRemFnType": "CONSTANT_ISSUE", "descriptionSections": [ @@ -178,11 +163,6 @@ exports[`should render correctly: loaded 1`] = ` ruleDetails={ { "createdAt": "2014-12-16T17:26:54+0100", - "debtOverloaded": false, - "debtRemFnOffset": "5min", - "debtRemFnType": "CONSTANT_ISSUE", - "defaultDebtRemFnOffset": "5min", - "defaultDebtRemFnType": "CONSTANT_ISSUE", "defaultRemFnBaseEffort": "5min", "defaultRemFnType": "CONSTANT_ISSUE", "descriptionSections": [ diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetailsMeta-test.tsx.snap b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetailsMeta-test.tsx.snap index f2e2b7c283c..cb2bfa942b0 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetailsMeta-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetailsMeta-test.tsx.snap @@ -33,10 +33,14 @@ exports[`should display right meta info 1`] = ` { "createdAt": "2013-07-26T09:40:51+0200", "descriptionSections": [], + "gapDescription": "per test", "key": "squid:S1133", "lang": "java", "langName": "Java", "name": "Deprecated code should be removed", + "remFnBaseEffort": "1min", + "remFnGapMultiplier": "2min", + "remFnType": "LINEAR_OFFSET", "repo": "squid", "scope": "MAIN", "severity": "INFO", @@ -123,6 +127,20 @@ exports[`should display right meta info 1`] = ` date="2013-07-26T09:40:51+0200" /> + +
  • + coding_rules.remediation_function.LINEAR_OFFSET + : + 1min + +2min + per test +
  • +
    `; diff --git a/server/sonar-web/src/main/js/helpers/testMocks.ts b/server/sonar-web/src/main/js/helpers/testMocks.ts index dc0809f4413..9b2b7c65332 100644 --- a/server/sonar-web/src/main/js/helpers/testMocks.ts +++ b/server/sonar-web/src/main/js/helpers/testMocks.ts @@ -570,11 +570,6 @@ export function mockRuleDetails(overrides: Partial = {}): RuleDetai lang: 'java', langName: 'Java', params: [], - defaultDebtRemFnType: 'CONSTANT_ISSUE', - defaultDebtRemFnOffset: '5min', - debtOverloaded: false, - debtRemFnType: 'CONSTANT_ISSUE', - debtRemFnOffset: '5min', defaultRemFnType: 'CONSTANT_ISSUE', defaultRemFnBaseEffort: '5min', remFnType: 'CONSTANT_ISSUE', diff --git a/server/sonar-web/src/main/js/types/types.ts b/server/sonar-web/src/main/js/types/types.ts index b921015846d..7c98fcd7bbd 100644 --- a/server/sonar-web/src/main/js/types/types.ts +++ b/server/sonar-web/src/main/js/types/types.ts @@ -570,17 +570,11 @@ export interface RulesUpdateRequest { export interface RuleDetails extends Rule { createdAt: string; - debtOverloaded?: boolean; - debtRemFnCoeff?: string; - debtRemFnOffset?: string; - debtRemFnType?: string; - defaultDebtRemFnOffset?: string; - defaultDebtRemFnType?: string; defaultRemFnBaseEffort?: string; defaultRemFnType?: string; descriptionSections?: RuleDescriptionSection[]; educationPrinciples?: string[]; - effortToFixDescription?: string; + gapDescription?: string; htmlDesc?: string; htmlNote?: string; internalKey?: string; @@ -588,6 +582,7 @@ export interface RuleDetails extends Rule { mdDesc?: string; mdNote?: string; remFnBaseEffort?: string; + remFnGapMultiplier?: string; remFnOverloaded?: boolean; remFnType?: string; repo: string;