]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-18638 Remove deprecated fields in Rule API response
authorAmbroise C <ambroise.christea@sonarsource.com>
Thu, 9 Mar 2023 10:37:28 +0000 (11:37 +0100)
committersonartech <sonartech@sonarsource.com>
Mon, 13 Mar 2023 20:02:45 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx
server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsMeta-test.tsx
server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap
server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetailsMeta-test.tsx.snap
server/sonar-web/src/main/js/helpers/testMocks.ts
server/sonar-web/src/main/js/types/types.ts

index 6f248fcb6cce16ffcfe9604d1528b7c0768aaa72..d74f0b6bd0760bc662330bc474d9828387543253 100644 (file)
@@ -179,18 +179,17 @@ export default class RuleDetailsMeta extends React.PureComponent<Props> {
 
   renderRemediation = () => {
     const { ruleDetails } = this.props;
-    if (!ruleDetails.debtRemFnType) {
+    if (!ruleDetails.remFnType) {
       return null;
     }
     return (
       <Tooltip overlay={translate('coding_rules.remediation_function')}>
         <li className="coding-rules-detail-property" data-meta="remediation-function">
-          {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}`}
         </li>
       </Tooltip>
     );
index 2da3cd49a4de3b18e9c58249850524b3fe914594..723c9cad1b49785315b30a548826442bf576b366 100644 (file)
@@ -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 = {
index 1ac517499da21efd179a035d94c0af74cbbb67a9..7b2ac325222e03e81201b72b9f6e725b185c3479 100644 (file)
@@ -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": [
index f2e2b7c283cc5f927d7e3b249564cdf3df0e290e..cb2bfa942b0af4389b78e439e9bacf5bf3e7aecb 100644 (file)
@@ -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"
       />
     </li>
+    <Tooltip
+      overlay="coding_rules.remediation_function"
+    >
+      <li
+        className="coding-rules-detail-property"
+        data-meta="remediation-function"
+      >
+        coding_rules.remediation_function.LINEAR_OFFSET
+        :
+         1min
+         +2min
+         per test
+      </li>
+    </Tooltip>
   </ul>
 </div>
 `;
index dc0809f441333eaec7ba50192bd1990d68fb6a53..9b2b7c653325e9d78a4b5843b90c41b869d5b3a8 100644 (file)
@@ -570,11 +570,6 @@ export function mockRuleDetails(overrides: Partial<RuleDetails> = {}): 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',
index b921015846d8ebe68c403e6a6dc8b7391671af6a..7c98fcd7bbdef3981eb3ce133a6cb0cf7981fd7e 100644 (file)
@@ -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;