You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

issues.ts 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import {
  21. CleanCodeAttribute,
  22. CleanCodeAttributeCategory,
  23. SoftwareImpact,
  24. } from './clean-code-taxonomy';
  25. import { Issue, Paging, TextRange } from './types';
  26. import { UserBase } from './users';
  27. export const ASSIGNEE_ME = '__me__';
  28. export enum IssueType {
  29. CodeSmell = 'CODE_SMELL',
  30. Vulnerability = 'VULNERABILITY',
  31. Bug = 'BUG',
  32. SecurityHotspot = 'SECURITY_HOTSPOT',
  33. }
  34. // Keep this enum in the correct order (most severe to least severe).
  35. export enum IssueSeverity {
  36. Blocker = 'BLOCKER',
  37. Critical = 'CRITICAL',
  38. Major = 'MAJOR',
  39. Minor = 'MINOR',
  40. Info = 'INFO',
  41. }
  42. export enum IssueScope {
  43. Main = 'MAIN',
  44. Test = 'TEST',
  45. }
  46. export enum IssueResolution {
  47. Unresolved = '',
  48. FalsePositive = 'FALSE-POSITIVE',
  49. Fixed = 'FIXED',
  50. Removed = 'REMOVED',
  51. WontFix = 'WONTFIX',
  52. }
  53. export enum IssueDeprecatedStatus {
  54. Open = 'OPEN',
  55. Confirmed = 'CONFIRMED',
  56. Reopened = 'REOPENED',
  57. Resolved = 'RESOLVED',
  58. Closed = 'CLOSED',
  59. }
  60. export enum IssueStatus {
  61. Open = 'OPEN',
  62. Fixed = 'FIXED',
  63. Confirmed = 'CONFIRMED',
  64. Accepted = 'ACCEPTED',
  65. FalsePositive = 'FALSE_POSITIVE',
  66. }
  67. export enum IssueActions {
  68. SetType = 'set_type',
  69. SetTags = 'set_tags',
  70. SetSeverity = 'set_severity',
  71. Comment = 'comment',
  72. Assign = 'assign',
  73. }
  74. export enum IssueTransition {
  75. Accept = 'accept',
  76. Confirm = 'confirm',
  77. UnConfirm = 'unconfirm',
  78. Resolve = 'resolve',
  79. FalsePositive = 'falsepositive',
  80. WontFix = 'wontfix',
  81. Reopen = 'reopen',
  82. }
  83. interface Comment {
  84. createdAt: string;
  85. htmlText: string;
  86. key: string;
  87. login: string;
  88. markdown: string;
  89. updatable: boolean;
  90. }
  91. export interface MessageFormatting {
  92. start: number;
  93. end: number;
  94. type: MessageFormattingType;
  95. }
  96. export enum MessageFormattingType {
  97. CODE = 'CODE',
  98. }
  99. export interface RawFlowLocation {
  100. component: string;
  101. index?: number;
  102. msg?: string;
  103. msgFormattings?: MessageFormatting[];
  104. textRange: TextRange;
  105. }
  106. export interface RawIssue {
  107. actions: string[];
  108. transitions: IssueTransition[];
  109. tags?: string[];
  110. assignee?: string;
  111. author?: string;
  112. cleanCodeAttributeCategory: CleanCodeAttributeCategory;
  113. cleanCodeAttribute: CleanCodeAttribute;
  114. impacts: SoftwareImpact[];
  115. codeVariants?: string[];
  116. comments?: Comment[];
  117. creationDate: string;
  118. component: string;
  119. flows?: Array<{
  120. type?: string;
  121. description?: string;
  122. locations?: RawFlowLocation[];
  123. }>;
  124. key: string;
  125. line?: number;
  126. messageFormattings?: MessageFormatting[];
  127. project: string;
  128. rule: string;
  129. resolution?: string;
  130. message?: string;
  131. severity: string;
  132. status: string;
  133. issueStatus: IssueStatus;
  134. textRange?: TextRange;
  135. type: IssueType;
  136. scope: string;
  137. ruleDescriptionContextKey?: string;
  138. ruleStatus?: string;
  139. quickFixAvailable?: boolean;
  140. }
  141. export interface IssueResponse {
  142. components?: Array<{ key: string; name: string }>;
  143. issue: RawIssue;
  144. rules?: Array<{}>;
  145. users?: UserBase[];
  146. }
  147. export interface RawIssuesResponse {
  148. components: ReferencedComponent[];
  149. effortTotal: number;
  150. facets: RawFacet[];
  151. issues: RawIssue[];
  152. languages: ReferencedLanguage[];
  153. paging: Paging;
  154. rules?: Array<{}>;
  155. users?: UserBase[];
  156. }
  157. export interface ListIssuesResponse {
  158. components: ReferencedComponent[];
  159. issues: RawIssue[];
  160. paging: Paging;
  161. rules?: Array<{}>;
  162. }
  163. export interface FetchIssuesPromise {
  164. components?: ReferencedComponent[];
  165. effortTotal?: number;
  166. facets?: RawFacet[];
  167. issues: Issue[];
  168. languages?: ReferencedLanguage[];
  169. paging: Paging;
  170. rules: ReferencedRule[];
  171. users?: UserBase[];
  172. }
  173. export interface ListIssuesPromise {
  174. issues: Issue[];
  175. paging: Paging;
  176. rules: ReferencedRule[];
  177. }
  178. export interface ReferencedComponent {
  179. key: string;
  180. name: string;
  181. path?: string;
  182. enabled?: boolean;
  183. longName?: string;
  184. uuid: string;
  185. }
  186. export interface ReferencedLanguage {
  187. name: string;
  188. }
  189. export interface ReferencedRule {
  190. langName?: string;
  191. name: string;
  192. }
  193. export interface RawFacet {
  194. property: string;
  195. values: Array<{ val: string; count: number }>;
  196. }
  197. export interface Facet {
  198. [value: string]: number;
  199. }
  200. export enum FacetName {
  201. AssignedToMe = 'assigned_to_me',
  202. Assignees = 'assignees',
  203. Author = 'author',
  204. CodeVariants = 'codeVariants',
  205. CreatedAt = 'createdAt',
  206. Cwe = 'cwe',
  207. Directories = 'directories',
  208. Files = 'files',
  209. Languages = 'languages',
  210. OwaspTop10 = 'owaspTop10',
  211. Projects = 'projects',
  212. Reporters = 'reporters',
  213. Resolutions = 'resolutions',
  214. Rules = 'rules',
  215. Severities = 'severities',
  216. Statuses = 'statuses',
  217. Tags = 'tags',
  218. Types = 'types',
  219. }