1/* 2 * Copyright (c) 2024 - 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15import { AIFix, FunctionFix, RuleFix } from './Fix'; 16 17export const engine = { 18 engineName: '' 19}; 20 21export class Defects { 22 reportLine: number; 23 reportColumn: number; 24 problem: string = ''; 25 description: string = ''; 26 severity: number = -1; // 0:info, 1:warning, 2:error 27 ruleId: string = '@perforce/<checker-name>'; 28 mergeKey: string = ''; // 文件路径%行号%开始列号%结束列号%规则%规则描述 29 ruleDocPath: string = 'doc/<checker-name>.md'; 30 disabled: boolean = true; 31 checked: boolean = false; 32 fixable: boolean = false; // 是否可以修复 33 fixKey: string = ''; // 行号%开始列号%结束列号%规则id 34 showIgnoreIcon: boolean = true; 35 engineName: string = engine.engineName; 36 37 constructor(reportLine: number, reportColumn: number, endColumn: number, problem: string, description: string, severity: number, ruleId: string, 38 filePath: string, ruleDocPath: string, disabled: boolean, checked: boolean, fixable: boolean, showIgnoreIcon: boolean = true) { 39 this.reportLine = reportLine; 40 this.reportColumn = reportColumn; 41 this.problem = problem; 42 this.description = description; 43 this.severity = severity; 44 this.ruleId = ruleId; 45 this.fixKey = this.reportLine + '%' + this.reportColumn + '%' + endColumn + '%' + this.ruleId; 46 this.mergeKey = filePath + '%' + this.fixKey + '%' + this.description; 47 this.ruleDocPath = ruleDocPath; 48 this.disabled = disabled; 49 this.checked = checked; 50 this.fixable = fixable; 51 this.showIgnoreIcon = showIgnoreIcon; 52 } 53} 54 55export class IssueReport { 56 defect: Defects; 57 fix: RuleFix | FunctionFix | AIFix | undefined; 58 59 constructor(defect: Defects, fix: RuleFix | FunctionFix | AIFix | undefined) { 60 this.defect = defect; 61 this.fix = fix; 62 } 63} 64 65export interface FileIssues { 66 filePath: string; 67 issues: IssueReport[]; 68} 69 70export interface FileReports { 71 filePath: string; 72 defects: Defects[]; 73 output?: string; 74}