]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-20197 Add taxonomy types to rules
authorstanislavh <stanislav.honcharov@sonarsource.com>
Fri, 18 Aug 2023 09:00:01 +0000 (11:00 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 22 Aug 2023 20:03:05 +0000 (20:03 +0000)
16 files changed:
server/sonar-web/src/main/js/api/mocks/CodingRulesServiceMock.ts
server/sonar-web/src/main/js/api/mocks/IssuesServiceMock.ts
server/sonar-web/src/main/js/api/mocks/data/issues.ts
server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts
server/sonar-web/src/main/js/apps/issues/sidebar/AttributeCategoryFacet.tsx
server/sonar-web/src/main/js/apps/issues/sidebar/SeverityFacet.tsx
server/sonar-web/src/main/js/apps/issues/sidebar/SoftwareQualityFacet.tsx
server/sonar-web/src/main/js/apps/issues/test-utils.tsx
server/sonar-web/src/main/js/apps/issues/utils.ts
server/sonar-web/src/main/js/components/icons/SoftwareImpactSeverityIcon.tsx
server/sonar-web/src/main/js/components/shared/CleanCodeAttributePill.tsx
server/sonar-web/src/main/js/components/shared/SoftwareImpactPill.tsx
server/sonar-web/src/main/js/helpers/testMocks.ts
server/sonar-web/src/main/js/types/clean-code-taxonomy.ts [new file with mode: 0644]
server/sonar-web/src/main/js/types/issues.ts
server/sonar-web/src/main/js/types/types.ts

index 74a3b51f0a126efce5f0aa5dfc98af413fc3a9bc..df68b91786c7c9a70e083be7db2c985b5d152c20 100644 (file)
@@ -143,6 +143,9 @@ export default class CodingRulesServiceMock {
         'sysTags',
         'tags',
         'type',
+        'cleanCodeAttributeCategory',
+        'cleanCodeAttribute',
+        'impacts',
       ])
     );
   }
index bef870b12223aea4e0b4714c91cb59fd608be9d4..24b07b1d60c7f793b278bf5fc3da6470460cb2fb 100644 (file)
@@ -31,10 +31,14 @@ import { mockIssueAuthors, mockIssueChangelog } from '../../helpers/mocks/issues
 import { RequestData } from '../../helpers/request';
 import { getStandards } from '../../helpers/security-standard';
 import { mockLoggedInUser, mockPaging, mockRuleDetails } from '../../helpers/testMocks';
+import {
+  CleanCodeAttributeCategory,
+  SoftwareImpactSeverity,
+  SoftwareQuality,
+} from '../../types/clean-code-taxonomy';
 import { SearchRulesResponse } from '../../types/coding-rules';
 import {
   ASSIGNEE_ME,
-  CleanCodeAttributeCategory,
   IssueResolution,
   IssueStatus,
   IssueTransition,
@@ -44,8 +48,6 @@ import {
   RawIssue,
   RawIssuesResponse,
   ReferencedComponent,
-  SoftwareImpactSeverity,
-  SoftwareQuality,
 } from '../../types/issues';
 import { SearchRulesQuery } from '../../types/rules';
 import { Standards } from '../../types/security';
index c4dd9c4ddd008f1cb933e859fabfee7de22f5f7c..4731f0558493001bfd5d70f7ae7bd04a4eb999ef 100644 (file)
@@ -23,6 +23,10 @@ import { mockSnippetsByComponent } from '../../../helpers/mocks/sources';
 import { mockLoggedInUser, mockRawIssue } from '../../../helpers/testMocks';
 import {
   CleanCodeAttributeCategory,
+  SoftwareImpactSeverity,
+  SoftwareQuality,
+} from '../../../types/clean-code-taxonomy';
+import {
   IssueActions,
   IssueResolution,
   IssueScope,
@@ -30,8 +34,6 @@ import {
   IssueStatus,
   IssueType,
   RawIssue,
-  SoftwareImpactSeverity,
-  SoftwareQuality,
 } from '../../../types/issues';
 import { Dict, FlowType, SnippetsByComponent } from '../../../types/types';
 import {
index 6f9dd64af3e9ad2b08f54278198bf9396c689990..15c4260b27cdc1b2d1b77585947ad4d73ac445b0 100644 (file)
@@ -21,7 +21,7 @@ import {
   CleanCodeAttributeCategory,
   SoftwareImpactSeverity,
   SoftwareQuality,
-} from '../../../types/issues';
+} from '../../../types/clean-code-taxonomy';
 import { SecurityStandard } from '../../../types/security';
 import {
   parseQuery,
index 30ba17e814dc4215b419320adafad26220e82fc7..28779bd54fbfefded83492165fc1e47798a1f60e 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 import * as React from 'react';
-import { CleanCodeAttributeCategory } from '../../../types/issues';
+import { CleanCodeAttributeCategory } from '../../../types/clean-code-taxonomy';
 import { CommonProps, SimpleListStyleFacet } from './SimpleListStyleFacet';
 
 interface Props extends CommonProps {
index cf878fcdb9f7c89600c9b7464ac0937c01e0fb7b..4b9fba328839b31525a875a62059182d7ad085d7 100644 (file)
@@ -22,7 +22,7 @@ import * as React from 'react';
 import DocumentationTooltip from '../../../components/common/DocumentationTooltip';
 import SoftwareImpactSeverityIcon from '../../../components/icons/SoftwareImpactSeverityIcon';
 import { translate } from '../../../helpers/l10n';
-import { SoftwareImpactSeverity } from '../../../types/issues';
+import { SoftwareImpactSeverity } from '../../../types/clean-code-taxonomy';
 import { CommonProps, SimpleListStyleFacet } from './SimpleListStyleFacet';
 
 interface Props extends CommonProps {
index fc829f08cc92cab503dfa1784d24aa169573d288..2888116505eb2783c6076c64da5a833088447ea0 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 import * as React from 'react';
-import { SoftwareQuality } from '../../../types/issues';
+import { SoftwareQuality } from '../../../types/clean-code-taxonomy';
 import { CommonProps, SimpleListStyleFacet } from './SimpleListStyleFacet';
 
 interface Props extends CommonProps {
index 6a524e9ab450253662e1f90b88b879d8c2ec78bb..1a9aa8edd0e756fca1f9dadb026c9b10caaa8bde 100644 (file)
@@ -31,7 +31,7 @@ import {
   CleanCodeAttributeCategory,
   SoftwareImpactSeverity,
   SoftwareQuality,
-} from '../../types/issues';
+} from '../../types/clean-code-taxonomy';
 import { Component } from '../../types/types';
 import { NoticeType } from '../../types/users';
 import IssuesApp from './components/IssuesApp';
index 57b4fd49565fb2128c07fe90af6ada445b05825e..31220895075367f48914ef33939f89fc08e4af4e 100644 (file)
@@ -35,11 +35,10 @@ import { get, save } from '../../helpers/storage';
 import { isDefined } from '../../helpers/types';
 import {
   CleanCodeAttributeCategory,
-  Facet,
-  RawFacet,
   SoftwareImpactSeverity,
   SoftwareQuality,
-} from '../../types/issues';
+} from '../../types/clean-code-taxonomy';
+import { Facet, RawFacet } from '../../types/issues';
 import { MetricType } from '../../types/metrics';
 import { SecurityStandard } from '../../types/security';
 import { Dict, Issue, Paging, RawQuery } from '../../types/types';
index b86b19786625fba5b76d48691c2129158d9c0965..000e963df618bbe4c8a8426f3645cf33033b2849 100644 (file)
@@ -24,7 +24,7 @@ import {
 } from 'design-system';
 import * as React from 'react';
 import { translate } from '../../helpers/l10n';
-import { SoftwareImpactSeverity } from '../../types/issues';
+import { SoftwareImpactSeverity } from '../../types/clean-code-taxonomy';
 import { Dict } from '../../types/types';
 import { IconProps } from './Icon';
 
index 23860a76487a8b786894de1fdaf66d30b50cf385..0657d5a5c79e09c85a875057a6ba9955da1f2e93 100644 (file)
@@ -21,7 +21,7 @@ import classNames from 'classnames';
 import { Pill } from 'design-system';
 import React from 'react';
 import { translate } from '../../helpers/l10n';
-import { CleanCodeAttribute, CleanCodeAttributeCategory } from '../../types/issues';
+import { CleanCodeAttribute, CleanCodeAttributeCategory } from '../../types/clean-code-taxonomy';
 import DocumentationTooltip from '../common/DocumentationTooltip';
 
 export interface Props {
index 1f2ea70fba9702ddea08fc3961ecbceb3df7001a..cdacee48e61781f8b919e07cc0e7dfe1793f86f0 100644 (file)
@@ -22,7 +22,7 @@ import { Pill } from 'design-system';
 import React from 'react';
 import { FormattedMessage } from 'react-intl';
 import { translate } from '../../helpers/l10n';
-import { SoftwareImpactSeverity, SoftwareQuality } from '../../types/issues';
+import { SoftwareImpactSeverity, SoftwareQuality } from '../../types/clean-code-taxonomy';
 import DocumentationTooltip from '../common/DocumentationTooltip';
 import SoftwareImpactSeverityIcon from '../icons/SoftwareImpactSeverityIcon';
 
index 4b55fdf9281d2b07b84ec88b384d24b849fba914..b2363cbe26a3ad7f6bdcbaba0239c35207da25b7 100644 (file)
@@ -24,19 +24,15 @@ import { Exporter, Profile, ProfileChangelogEvent } from '../apps/quality-profil
 import { LogsLevels } from '../apps/system/utils';
 import { Location, Router } from '../components/hoc/withRouter';
 import { AppState } from '../types/appstate';
-import { RuleRepository } from '../types/coding-rules';
-import { EditionKey } from '../types/editions';
 import {
   CleanCodeAttribute,
   CleanCodeAttributeCategory,
-  IssueScope,
-  IssueSeverity,
-  IssueStatus,
-  IssueType,
-  RawIssue,
   SoftwareImpactSeverity,
   SoftwareQuality,
-} from '../types/issues';
+} from '../types/clean-code-taxonomy';
+import { RuleRepository } from '../types/coding-rules';
+import { EditionKey } from '../types/editions';
+import { IssueScope, IssueSeverity, IssueStatus, IssueType, RawIssue } from '../types/issues';
 import { Language } from '../types/languages';
 import { Notification } from '../types/notifications';
 import { DumpStatus, DumpTask } from '../types/project-dump';
@@ -593,6 +589,8 @@ export function mockRuleActivation(overrides: Partial<RuleActivation> = {}): Rul
 
 export function mockRuleDetails(overrides: Partial<RuleDetails> = {}): RuleDetails {
   return {
+    cleanCodeAttributeCategory: CleanCodeAttributeCategory.Adaptable,
+    cleanCodeAttribute: CleanCodeAttribute.Clear,
     key: 'squid:S1337',
     repo: 'squid',
     name: '".equals()" should not be used to test the values of "Atomic" classes',
@@ -608,6 +606,9 @@ export function mockRuleDetails(overrides: Partial<RuleDetails> = {}): RuleDetai
     severity: 'MAJOR',
     status: 'READY',
     isTemplate: false,
+    impacts: [
+      { softwareQuality: SoftwareQuality.Maintainability, severity: SoftwareImpactSeverity.High },
+    ],
     tags: [],
     sysTags: ['multi-threading'],
     lang: 'java',
diff --git a/server/sonar-web/src/main/js/types/clean-code-taxonomy.ts b/server/sonar-web/src/main/js/types/clean-code-taxonomy.ts
new file mode 100644 (file)
index 0000000..80e944c
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+export enum SoftwareImpactSeverity {
+  High = 'HIGH',
+  Medium = 'MEDIUM',
+  Low = 'LOW',
+}
+
+export enum CleanCodeAttributeCategory {
+  Consistent = 'CONSISTENT',
+  Intentional = 'INTENTIONAL',
+  Adaptable = 'ADAPTABLE',
+  Responsible = 'RESPONSIBLE',
+}
+
+export enum CleanCodeAttribute {
+  Clear = 'CLEAR',
+  Complete = 'COMPLETE',
+  Conventional = 'CONVENTIONAL',
+  Distinct = 'DISTINCT',
+  Efficient = 'EFFICIENT',
+  Focused = 'FOCUSED',
+  Formatted = 'FORMATTED',
+  Identifiable = 'IDENTIFIABLE',
+  Lawful = 'LAWFUL',
+  Logical = 'LOGICAL',
+  Modular = 'MODULAR',
+  Respectful = 'RESPECTFUL',
+  Tested = 'TESTED',
+  Trustworthy = 'TRUSTWORTHY',
+}
+
+export enum SoftwareQuality {
+  Security = 'SECURITY',
+  Reliability = 'RELIABILITY',
+  Maintainability = 'MAINTAINABILITY',
+}
index a3fca94b673629384dc659176d71e239162dc94c..116bdcf3c89d0b8a94b8730c82f8c6549ed233e4 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
+import {
+  CleanCodeAttribute,
+  CleanCodeAttributeCategory,
+  SoftwareImpactSeverity,
+  SoftwareQuality,
+} from './clean-code-taxonomy';
 import { Issue, Paging, TextRange } from './types';
 import { UserBase } from './users';
 
@@ -30,11 +36,6 @@ export enum IssueType {
 }
 
 // Keep this enum in the correct order (most severe to least severe).
-export enum SoftwareImpactSeverity {
-  High = 'HIGH',
-  Medium = 'MEDIUM',
-  Low = 'LOW',
-}
 
 export enum IssueSeverity {
   Blocker = 'BLOCKER',
@@ -44,36 +45,6 @@ export enum IssueSeverity {
   Info = 'INFO',
 }
 
-export enum CleanCodeAttributeCategory {
-  Consistent = 'CONSISTENT',
-  Intentional = 'INTENTIONAL',
-  Adaptable = 'ADAPTABLE',
-  Responsible = 'RESPONSIBLE',
-}
-
-export enum CleanCodeAttribute {
-  Clear = 'CLEAR',
-  Complete = 'COMPLETE',
-  Conventional = 'CONVENTIONAL',
-  Distinct = 'DISTINCT',
-  Efficient = 'EFFICIENT',
-  Focused = 'FOCUSED',
-  Formatted = 'FORMATTED',
-  Identifiable = 'IDENTIFIABLE',
-  Lawful = 'LAWFUL',
-  Logical = 'LOGICAL',
-  Modular = 'MODULAR',
-  Respectful = 'RESPECTFUL',
-  Tested = 'TESTED',
-  Trustworthy = 'TRUSTWORTHY',
-}
-
-export enum SoftwareQuality {
-  Security = 'SECURITY',
-  Reliability = 'RELIABILITY',
-  Maintainability = 'MAINTAINABILITY',
-}
-
 export enum IssueScope {
   Main = 'MAIN',
   Test = 'TEST',
index ee999308d9083a212dc1ad1d1b584b22e0b3b302..bab27408f09144000f1de17988052fe21c619c7d 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import { RuleDescriptionSection } from '../apps/coding-rules/rule';
-import { ComponentQualifier, Visibility } from './component';
 import {
   CleanCodeAttribute,
   CleanCodeAttributeCategory,
-  MessageFormatting,
   SoftwareImpactSeverity,
   SoftwareQuality,
-} from './issues';
+} from './clean-code-taxonomy';
+import { ComponentQualifier, Visibility } from './component';
+import { MessageFormatting } from './issues';
 import { NewCodeDefinitionType } from './new-code-definition';
 import { UserActive, UserBase } from './users';
 
@@ -533,6 +533,12 @@ export interface QualityGate {
 export type RawQuery = Dict<any>;
 
 export interface Rule {
+  cleanCodeAttributeCategory: CleanCodeAttributeCategory;
+  cleanCodeAttribute: CleanCodeAttribute;
+  impacts: Array<{
+    softwareQuality: SoftwareQuality;
+    severity: SoftwareImpactSeverity;
+  }>;
   isTemplate?: boolean;
   key: string;
   lang?: string;