aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstanislavh <stanislav.honcharov@sonarsource.com>2023-08-18 11:00:01 +0200
committersonartech <sonartech@sonarsource.com>2023-08-22 20:03:05 +0000
commit4c947ce4e71c1ee79bee02b5b2820f4a5c78e746 (patch)
tree5c81c051cebcd0aaf081c65c710fca38882ddda1
parentc096cbf6f20dcfb5b5cee6405b7d01c5f0b33ade (diff)
downloadsonarqube-4c947ce4e71c1ee79bee02b5b2820f4a5c78e746.tar.gz
sonarqube-4c947ce4e71c1ee79bee02b5b2820f4a5c78e746.zip
SONAR-20197 Add taxonomy types to rules
-rw-r--r--server/sonar-web/src/main/js/api/mocks/CodingRulesServiceMock.ts3
-rw-r--r--server/sonar-web/src/main/js/api/mocks/IssuesServiceMock.ts8
-rw-r--r--server/sonar-web/src/main/js/api/mocks/data/issues.ts6
-rw-r--r--server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/AttributeCategoryFacet.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/SeverityFacet.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/SoftwareQualityFacet.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/test-utils.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/utils.ts5
-rw-r--r--server/sonar-web/src/main/js/components/icons/SoftwareImpactSeverityIcon.tsx2
-rw-r--r--server/sonar-web/src/main/js/components/shared/CleanCodeAttributePill.tsx2
-rw-r--r--server/sonar-web/src/main/js/components/shared/SoftwareImpactPill.tsx2
-rw-r--r--server/sonar-web/src/main/js/helpers/testMocks.ts17
-rw-r--r--server/sonar-web/src/main/js/types/clean-code-taxonomy.ts55
-rw-r--r--server/sonar-web/src/main/js/types/issues.ts41
-rw-r--r--server/sonar-web/src/main/js/types/types.ts12
16 files changed, 101 insertions, 62 deletions
diff --git a/server/sonar-web/src/main/js/api/mocks/CodingRulesServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/CodingRulesServiceMock.ts
index 74a3b51f0a1..df68b91786c 100644
--- a/server/sonar-web/src/main/js/api/mocks/CodingRulesServiceMock.ts
+++ b/server/sonar-web/src/main/js/api/mocks/CodingRulesServiceMock.ts
@@ -143,6 +143,9 @@ export default class CodingRulesServiceMock {
'sysTags',
'tags',
'type',
+ 'cleanCodeAttributeCategory',
+ 'cleanCodeAttribute',
+ 'impacts',
])
);
}
diff --git a/server/sonar-web/src/main/js/api/mocks/IssuesServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/IssuesServiceMock.ts
index bef870b1222..24b07b1d60c 100644
--- a/server/sonar-web/src/main/js/api/mocks/IssuesServiceMock.ts
+++ b/server/sonar-web/src/main/js/api/mocks/IssuesServiceMock.ts
@@ -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';
diff --git a/server/sonar-web/src/main/js/api/mocks/data/issues.ts b/server/sonar-web/src/main/js/api/mocks/data/issues.ts
index c4dd9c4ddd0..4731f055849 100644
--- a/server/sonar-web/src/main/js/api/mocks/data/issues.ts
+++ b/server/sonar-web/src/main/js/api/mocks/data/issues.ts
@@ -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 {
diff --git a/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts
index 6f9dd64af3e..15c4260b27c 100644
--- a/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts
+++ b/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts
@@ -21,7 +21,7 @@ import {
CleanCodeAttributeCategory,
SoftwareImpactSeverity,
SoftwareQuality,
-} from '../../../types/issues';
+} from '../../../types/clean-code-taxonomy';
import { SecurityStandard } from '../../../types/security';
import {
parseQuery,
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/AttributeCategoryFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/AttributeCategoryFacet.tsx
index 30ba17e814d..28779bd54fb 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/AttributeCategoryFacet.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/AttributeCategoryFacet.tsx
@@ -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 {
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/SeverityFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/SeverityFacet.tsx
index cf878fcdb9f..4b9fba32883 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/SeverityFacet.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/SeverityFacet.tsx
@@ -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 {
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/SoftwareQualityFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/SoftwareQualityFacet.tsx
index fc829f08cc9..2888116505e 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/SoftwareQualityFacet.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/SoftwareQualityFacet.tsx
@@ -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 {
diff --git a/server/sonar-web/src/main/js/apps/issues/test-utils.tsx b/server/sonar-web/src/main/js/apps/issues/test-utils.tsx
index 6a524e9ab45..1a9aa8edd0e 100644
--- a/server/sonar-web/src/main/js/apps/issues/test-utils.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/test-utils.tsx
@@ -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';
diff --git a/server/sonar-web/src/main/js/apps/issues/utils.ts b/server/sonar-web/src/main/js/apps/issues/utils.ts
index 57b4fd49565..31220895075 100644
--- a/server/sonar-web/src/main/js/apps/issues/utils.ts
+++ b/server/sonar-web/src/main/js/apps/issues/utils.ts
@@ -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';
diff --git a/server/sonar-web/src/main/js/components/icons/SoftwareImpactSeverityIcon.tsx b/server/sonar-web/src/main/js/components/icons/SoftwareImpactSeverityIcon.tsx
index b86b1978662..000e963df61 100644
--- a/server/sonar-web/src/main/js/components/icons/SoftwareImpactSeverityIcon.tsx
+++ b/server/sonar-web/src/main/js/components/icons/SoftwareImpactSeverityIcon.tsx
@@ -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';
diff --git a/server/sonar-web/src/main/js/components/shared/CleanCodeAttributePill.tsx b/server/sonar-web/src/main/js/components/shared/CleanCodeAttributePill.tsx
index 23860a76487..0657d5a5c79 100644
--- a/server/sonar-web/src/main/js/components/shared/CleanCodeAttributePill.tsx
+++ b/server/sonar-web/src/main/js/components/shared/CleanCodeAttributePill.tsx
@@ -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 {
diff --git a/server/sonar-web/src/main/js/components/shared/SoftwareImpactPill.tsx b/server/sonar-web/src/main/js/components/shared/SoftwareImpactPill.tsx
index 1f2ea70fba9..cdacee48e61 100644
--- a/server/sonar-web/src/main/js/components/shared/SoftwareImpactPill.tsx
+++ b/server/sonar-web/src/main/js/components/shared/SoftwareImpactPill.tsx
@@ -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';
diff --git a/server/sonar-web/src/main/js/helpers/testMocks.ts b/server/sonar-web/src/main/js/helpers/testMocks.ts
index 4b55fdf9281..b2363cbe26a 100644
--- a/server/sonar-web/src/main/js/helpers/testMocks.ts
+++ b/server/sonar-web/src/main/js/helpers/testMocks.ts
@@ -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
index 00000000000..80e944c5e1e
--- /dev/null
+++ b/server/sonar-web/src/main/js/types/clean-code-taxonomy.ts
@@ -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',
+}
diff --git a/server/sonar-web/src/main/js/types/issues.ts b/server/sonar-web/src/main/js/types/issues.ts
index a3fca94b673..116bdcf3c89 100644
--- a/server/sonar-web/src/main/js/types/issues.ts
+++ b/server/sonar-web/src/main/js/types/issues.ts
@@ -17,6 +17,12 @@
* 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',
diff --git a/server/sonar-web/src/main/js/types/types.ts b/server/sonar-web/src/main/js/types/types.ts
index ee999308d90..bab27408f09 100644
--- a/server/sonar-web/src/main/js/types/types.ts
+++ b/server/sonar-web/src/main/js/types/types.ts
@@ -18,14 +18,14 @@
* 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;