• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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 */
15
16import ts from 'typescript';
17import { ApiDiffType } from '../../typedef/diff/ApiInfoDiff';
18
19/**
20 * error message type
21 * @enum { string }
22 */
23export enum ErrorType {
24  UNKNOW_DECORATOR = 'unknow decorator',
25  MISSPELL_WORDS = 'misspell words',
26  NAMING_ERRORS = 'naming errors',
27  UNKNOW_PERMISSION = 'unknow permission',
28  UNKNOW_SYSCAP = 'unknow syscap',
29  UNKNOW_DEPRECATED = 'unknow deprecated',
30  WRONG_ORDER = 'wrong order',
31  WRONG_VALUE = 'wrong value',
32  WRONG_SCENE = 'wrong scene',
33  PARAMETER_ERRORS = 'wrong parameter',
34  API_PAIR_ERRORS = 'limited api pair errors',
35  FORBIDDEN_WORDS = 'forbidden word',
36  API_CHANGE_ERRORS = 'api change errors',
37  TS_SYNTAX_ERROR = 'TS syntax error',
38  NO_JSDOC = 'No jsdoc',
39  JSDOC_HAS_CHINESE = 'JSDOC_HAS_CHINESE',
40  ERROR_ERROR_CODE = 'error_error_code'
41}
42
43/**
44 * error message id
45 * @enum { number }
46 */
47export enum ErrorID {
48  UNKNOW_DECORATOR_ID = 0,
49  MISSPELL_WORDS_ID = 1,
50  NAMING_ERRORS_ID = 2,
51  UNKNOW_PERMISSION_ID = 3,
52  UNKNOW_SYSCAP_ID = 4,
53  UNKNOW_DEPRECATED_ID = 5,
54  WRONG_ORDER_ID = 6,
55  WRONG_VALUE_ID = 7,
56  WRONG_SCENE_ID = 8,
57  PARAMETER_ERRORS_ID = 9,
58  API_PAIR_ERRORS_ID = 10,
59  FORBIDDEN_WORDS_ID = 11,
60  API_CHANGE_ERRORS_ID = 12,
61  TS_SYNTAX_ERROR_ID = 13,
62  NO_JSDOC_ID = 14,
63  JSDOC_HAS_CHINESE = 15,
64  ERROR_ERROR_CODE = 16
65}
66
67/**
68 * error type
69 * @enum { string }
70 */
71export enum LogType {
72  LOG_API = 'Api',
73  LOG_JSDOC = 'JsDoc',
74  LOG_FILE = 'File',
75}
76
77/**
78 * error message level
79 * @enum { number }
80 */
81export enum ErrorLevel {
82  HIGH = 3,
83  MIDDLE = 2,
84  LOW = 1,
85}
86
87export enum ParticularErrorCode {
88  ERROR_CODE_201 = '201',
89  ERROR_CODE_202 = '202',
90  ERROR_CODE_401 = '401',
91  ERROR_PERMISSION = 'permission',
92  ERROR_SYSTEMAPI = 'systemapi'
93}
94
95/**
96 * error message infomation
97 * @enum { string }
98 */
99export enum ErrorMessage {
100  ERROR_INFO_VALUE_EXTENDS = 'The [extends] tag value is incorrect. Please check if the tag value matches the inherited class name.',
101  ERROR_INFO_VALUE_IMPLEMENTS = 'The [implements] tag value is incorrect. Please check if the tag value matches the inherited class name.',
102  ERROR_INFO_VALUE_ENUM = 'The [enum] tag type is incorrect. Please check if the tag type is { string } or { number }.',
103  ERROR_INFO_VALUE_SINCE = 'The [since] tag value is incorrect. Please check if the tag value is a numerical value.',
104  ERROR_INFO_RETURNS = 'The [returns] tag was used incorrectly. The returns tag should not be used when the return type is void.',
105  ERROR_INFO_VALUE_RETURNS = 'The [returns] tag type is incorrect. Please check if the tag type is consistent with the return type.',
106  ERROR_INFO_VALUE_USEINSTEAD = 'The [useinstead] tag value is incorrect. Please check the usage method.',
107  ERROR_INFO_VALUE_TYPE = 'The [type] tag type is incorrect. Please check if the type matches the attribute type.',
108  ERROR_INFO_VALUE_DEFAULT = 'The [default] tag value is incorrect. Please supplement the default value.',
109  ERROR_INFO_VALUE_PERMISSION = 'The [permission] tag value is incorrect. Please check if the permission field has been configured or update the configuration file.',
110  ERROR_INFO_VALUE_DEPRECATED = 'The [deprecated] tag value is incorrect. Please check the usage method.',
111  ERROR_INFO_VALUE_SYSCAP = 'The [syscap] tag value is incorrect. Please check if the syscap field is configured.',
112  ERROR_INFO_VALUE_NAMESPACE = 'The [namespace] tag value is incorrect. Please check if it matches the namespace name.',
113  ERROR_INFO_VALUE_INTERFACE = 'The [interface] label value is incorrect. Please check if it matches the interface name.',
114  ERROR_INFO_VALUE_TYPEDEF = 'The [typedef] tag value is incorrect. Please check if it matches the interface name or type content.',
115  ERROR_INFO_VALUE_STRUCT = 'The [struct] tag value is incorrect. Please check if it matches the struct name.',
116  ERROR_INFO_TYPE_PARAM = 'The type of the [$$] [param] tag is incorrect. Please check if it matches the type of the [$$] parameter.',
117  ERROR_INFO_VALUE_PARAM = 'The value of the [$$] [param] tag is incorrect. Please check if it matches the [$$] parameter name.',
118  ERROR_INFO_VALUE1_THROWS = 'The type of the [$$] [throws] tag is incorrect. Please fill in [BusinessError].',
119  ERROR_INFO_VALUE2_THROWS = 'The type of the [$$] [throws] tag is incorrect. Please check if the tag value is a numerical value.',
120  ERROR_INFO_INHERIT = 'It was detected that there is an inheritable label [$$] in the current file, but there are child nodes without this label.',
121  ERROR_INFO_FOLLOW = 'It was detected that there is a following label [$$] in the current file, but the parent nodes without this label.',
122  ERROR_ORDER = 'JSDoc label order error, please adjust the order of [$$] labels.',
123  ERROR_LABELNAME = 'The [$$] tag does not exist. Please use a valid JSDoc tag.',
124  ERROR_LOST_LABEL = 'JSDoc tag validity verification failed. Please confirm if the [$$] tag is missing.',
125  ERROR_USE = 'JSDoc label validity verification failed. The [$$] label is not allowed. Please check the label usage method.',
126  ERROR_MORELABEL = 'JSDoc tag validity verification failed.There are [$$] redundant [$$]. Please check if the tag should be deleted.',
127  ERROR_REPEATLABEL = 'The validity verification of the JSDoc tag failed. The [$$] tag is not allowed to be reused, please delete the extra tags.',
128  ERROR_USE_INTERFACE = 'The validity verification of the JSDoc tag failed. The [interface] tag and [typedef] tag are not allowed to be used simultaneously. Please confirm the interface class.',
129  ERROR_EVENT_NAME_STRING = 'The event name should be string.',
130  ERROR_EVENT_NAME_NULL = 'The event name cannot be Null value.',
131  ERROR_EVENT_NAME_SMALL_HUMP = 'The event name should be named by small hump. (Received ["$$"]).',
132  ERROR_EVENT_CALLBACK_OPTIONAL = 'The callback parameter of off function should be optional.',
133  ERROR_EVENT_CALLBACK_MISSING = 'The off functions of one single event should have at least one callback parameter, and the callback parameter should be the last parameter.',
134  ERROR_EVENT_ON_AND_OFF_PAIR = 'The on and off event subscription methods do not appear in pair.',
135  ERROR_EVENT_WITHOUT_PARAMETER = 'The event subscription methods should has at least one parameter.',
136  ILLEGAL_USE_ANY = 'Illegal [$$] keyword used in the API.',
137  ERROR_CHANGES_VERSION = 'Please check if the changed API version number is 10.',
138  ERROR_WORD = 'Error words in [$$]: {$$}. please confirm whether it needs to be corrected to a common word.',
139  ERROR_NAMING = 'Prohibited word in [$$]:{$$}.The word allowed is [$$].',
140  ERROR_SCENARIO = 'Prohibited word in [$$]:{$$} in the [$$] file.',
141  ERROR_UPPERCASE_NAME = 'This name [$$] should be named by all uppercase.',
142  ERROR_LARGE_HUMP_NAME = 'This name [$$] should be named by large hump.',
143  ERROR_SMALL_HUMP_NAME = 'This name [$$] should be named by small hump.',
144  ERROR_SMALL_HUMP_NAME_FILE = 'This API file should be named by small hump.',
145  ERROR_LARGE_HUMP_NAME_FILE = 'This API file should be named by large hump.',
146  ERROR_ANONYMOUS_FUNCTION = 'Anonymous functions or anonymous object that are not allowed are used in this api.',
147  ERROR_NO_JSDOC = 'Jsdoc needs to be added to the current API.',
148  ERROR_NO_JSDOC_TAG = 'add  tags to the Jsdoc.',
149  ERROR_HAS_CHINESE = 'Jsdoc has chinese.',
150  ERROR_ERROR_CODE = 'The generic error code does not contain the current error code.',
151  ERROR_CHANGES_JSDOC_LEVEL = 'Forbid changes: Cannot change from public API to system API.',
152  ERROR_CHANGES_JSDOC_PERMISSION_RANGE = 'Forbid changes: Cannot reduce or permission or increase and permission.',
153  ERROR_CHANGES_JSDOC_PERMISSION_VALUE = 'Forbid changes: Cannot change permission value,cannot judge the range change.',
154  ERROR_CHANGES_JSDOC_ERROR_CODE_ADD = 'Forbid changes: The number of error codes cannot be increased from 0 to multiple error codes.',
155  ERROR_CHANGES_JSDOC_ERROR_CODE_VALUE = 'Forbid changes: Cannot change the error code value.',
156  ERROR_CHANGES_JSDOC_CARD = 'Forbid changes: The card application cannot be changed from supported to not supported.',
157  ERROR_CHANGES_JSDOC_CROSS_PLATFORM = 'Forbid changes: Crossplatform cannot be changed from supported to not supported.',
158  ERROR_CHANGES_JSDOC_API_DELETE = 'Forbid changes: API cannot be deleted.',
159  ERROR_CHANGES_JSDOC_FA_TO_STAGE = 'Forbid changes: Cannot change from FAModelOnly to StageModelOnly.',
160  ERROR_CHANGES_JSDOC_STAGE_TO_FA = 'Forbid changes: Cannot change from StageModelOnly to FAModelOnly.',
161  ERROR_CHANGES_JSDOC_NA_TO_STAGE = 'Forbid changes: Cannot change from nothing to StageModelOnly.',
162  ERROR_CHANGES_JSDOC_NA_TO_FA = 'Forbid changes: Cannot change from nothing to FAModelOnly.',
163  ERROR_CHANGES_JSDOC_ATOMICSERVICE_TO_NA = 'Forbid changes: Cannot change from atomicservice to NA.',
164  ERROR_CHANGES_FUNCTION_RETURN_TYPE_ADD = 'Forbid changes: The function return value type cannot be extended.',
165  ERROR_CHANGES_FUNCTION_RETURN_TYPE_REDUCE = 'Forbid changes: The function return value type cannot be reduced.',
166  ERROR_CHANGES_FUNCTION_RETURN_TYPE_CHANGE = 'Forbid changes: Cannot change function return value type.',
167  ERROR_CHANGES_FUNCTION_PARAM_POS_CHANGE = 'Forbid changes: Cannot change function param position.',
168  ERROR_CHANGES_FUNCTION_PARAM_REQUIRED_ADD = 'Forbid changes: Cannot add function required param.',
169  ERROR_CHANGES_FUNCTION_PARAM_REDUCE = 'Forbid changes: Cannot delete function param.',
170  ERROR_CHANGES_FUNCTION_PARAM_TO_REQUIRED = 'Forbid changes: Cannot change form unrequired param to required param.',
171  ERROR_CHANGES_FUNCTION_PARAM_TYPE = 'Forbid changes: Cannot change function param type.',
172  ERROR_CHANGES_FUNCTION_PARAM_TYPE_REDUCE = 'Forbid changes: The function param type range is cannot be reduced.',
173  ERROR_CHANGES_PROPERTY_READONLY_TO_REQUIRED = 'Forbid changes: Read-only properties cannot be changed from optional to required.',
174  ERROR_CHANGES_PROPERTY_WRITABLE_TO_UNREQUIRED = 'Forbid changes: Writable properties cannot be changed from required to optional.',
175  ERROR_CHANGES_PROPERTY_WRITABLE_TO_REQUIRED = 'Forbid changes: Writable properties cannot be changed from optional to required.',
176  ERROR_CHANGES_PROPERTY_TYPE_CHANGE = 'Forbid changes: Cannot change property type.',
177  ERROR_CHANGES_PROPERTY_READONLY_ADD = 'Forbid changes: Cannot Expand the range of readonly property types.',
178  ERROR_CHANGES_PROPERTY_WRITABLE_ADD = 'Forbid changes: Cannot Expand the range of writable property types.',
179  ERROR_CHANGES_PROPERTY_WRITABLE_REDUCE = 'Forbid changes: Cannot reduce the range of writable property types.',
180  ERROR_CHANGES_DELETE_DECORATOR = 'Forbid changes: Decorator cannot be deleted.',
181  ERROR_CHANGES_CONSTANT_VALUE = 'Forbid changes: Cannot change constant value.',
182  ERROR_CHANGES_TYPE_ALIAS_VALUE = 'Forbid changes: Cannot change custom type value.',
183  ERROR_CHANGES_TYPE_ALIAS_ADD = 'Forbid changes: Cannot expand the range of custom type.',
184  ERROR_CHANGES_TYPE_ALIAS_REDUCE = 'Forbid changes: Cannot reduce the range of custom type.',
185  ERROR_CHANGES_ENUM_MEMBER_VALUE = 'Forbid changes: Cannot change Enumeration assignment.',
186  ERROR_CHANGES_JSDOC_CHANGE = 'Forbid changes: Historical JSDoc cannot be changed.',
187  ERROR_CHANGES_JSDOC_NUMBER = 'Forbid changes: API changes must add a new section of JSDoc.',
188  ERROR_CHANGES_SYSCAP_NA_TO_HAVE = 'Forbid changes: Cannot change from NA to syscap.',
189  ERROR_CHANGES_SYSCAP_HAVE_TO_NA = 'Forbid changes: Cannot change from syscap to NA.',
190  ERROR_CHANGES_SYSCAP_A_TO_B = 'Forbid changes: Cannot change syscap value.',
191}
192
193export const incompatibleApiDiffTypes: Map<ApiDiffType, ErrorMessage> = new Map(
194  [
195    [ApiDiffType.HISTORICAL_JSDOC_CHANGE, ErrorMessage.ERROR_CHANGES_JSDOC_CHANGE],
196    [ApiDiffType.HISTORICAL_API_CHANGE, ErrorMessage.ERROR_CHANGES_JSDOC_NUMBER],
197    // 1.访问级别变更
198    [ApiDiffType.PUBLIC_TO_SYSTEM, ErrorMessage.ERROR_CHANGES_JSDOC_LEVEL],
199    // 2.权限变更
200    [ApiDiffType.PERMISSION_NA_TO_HAVE, ErrorMessage.ERROR_CHANGES_JSDOC_PERMISSION_VALUE],
201    [ApiDiffType.PERMISSION_RANGE_SMALLER, ErrorMessage.ERROR_CHANGES_JSDOC_PERMISSION_RANGE],
202    [ApiDiffType.PERMISSION_RANGE_CHANGE, ErrorMessage.ERROR_CHANGES_JSDOC_PERMISSION_VALUE],
203    // 3.错误码变更
204    [ApiDiffType.ERROR_CODE_NA_TO_HAVE, ErrorMessage.ERROR_CHANGES_JSDOC_ERROR_CODE_ADD],
205    [ApiDiffType.ERROR_CODE_CHANGE, ErrorMessage.ERROR_CHANGES_JSDOC_ERROR_CODE_VALUE],
206    // 4.是否支持卡片应用
207    [ApiDiffType.CARD_TO_NA, ErrorMessage.ERROR_CHANGES_JSDOC_CARD],
208    // 5.是否支持跨平台
209    [ApiDiffType.CROSS_PLATFORM_TO_NA, ErrorMessage.ERROR_CHANGES_JSDOC_CROSS_PLATFORM],
210    // 7.api删除
211    [ApiDiffType.REDUCE, ErrorMessage.ERROR_CHANGES_JSDOC_API_DELETE],
212    // 8.模型使用限制变更
213    [ApiDiffType.FA_TO_STAGE, ErrorMessage.ERROR_CHANGES_JSDOC_FA_TO_STAGE],
214    [ApiDiffType.STAGE_TO_FA, ErrorMessage.ERROR_CHANGES_JSDOC_STAGE_TO_FA],
215    [ApiDiffType.NA_TO_STAGE, ErrorMessage.ERROR_CHANGES_JSDOC_NA_TO_STAGE],
216    [ApiDiffType.NA_TO_FA, ErrorMessage.ERROR_CHANGES_JSDOC_NA_TO_FA],
217    // 10.函数变更
218    [ApiDiffType.FUNCTION_RETURN_TYPE_ADD, ErrorMessage.ERROR_CHANGES_FUNCTION_RETURN_TYPE_ADD],
219    [ApiDiffType.FUNCTION_RETURN_TYPE_REDUCE, ErrorMessage.ERROR_CHANGES_FUNCTION_RETURN_TYPE_REDUCE],
220    [ApiDiffType.FUNCTION_RETURN_TYPE_CHANGE, ErrorMessage.ERROR_CHANGES_FUNCTION_RETURN_TYPE_CHANGE],
221    [ApiDiffType.FUNCTION_PARAM_POS_CHANGE, ErrorMessage.ERROR_CHANGES_FUNCTION_PARAM_POS_CHANGE],
222    [ApiDiffType.FUNCTION_PARAM_REQUIRED_ADD, ErrorMessage.ERROR_CHANGES_FUNCTION_PARAM_REQUIRED_ADD],
223    [ApiDiffType.FUNCTION_PARAM_REDUCE, ErrorMessage.ERROR_CHANGES_FUNCTION_PARAM_REDUCE],
224    [ApiDiffType.FUNCTION_PARAM_TO_REQUIRED, ErrorMessage.ERROR_CHANGES_FUNCTION_PARAM_TO_REQUIRED],
225    [ApiDiffType.FUNCTION_PARAM_TYPE_CHANGE, ErrorMessage.ERROR_CHANGES_FUNCTION_PARAM_TYPE],
226    [ApiDiffType.FUNCTION_PARAM_TYPE_REDUCE, ErrorMessage.ERROR_CHANGES_FUNCTION_PARAM_TYPE_REDUCE],
227    // 12.属性变更
228    [ApiDiffType.PROPERTY_READONLY_TO_REQUIRED, ErrorMessage.ERROR_CHANGES_PROPERTY_READONLY_TO_REQUIRED],
229    [ApiDiffType.PROPERTY_WRITABLE_TO_UNREQUIRED, ErrorMessage.ERROR_CHANGES_PROPERTY_WRITABLE_TO_UNREQUIRED],
230    [ApiDiffType.PROPERTY_WRITABLE_TO_REQUIRED, ErrorMessage.ERROR_CHANGES_PROPERTY_WRITABLE_TO_REQUIRED],
231    [ApiDiffType.PROPERTY_TYPE_CHANGE, ErrorMessage.ERROR_CHANGES_PROPERTY_TYPE_CHANGE],
232    [ApiDiffType.PROPERTY_READONLY_ADD, ErrorMessage.ERROR_CHANGES_PROPERTY_READONLY_ADD],
233    [ApiDiffType.PROPERTY_WRITABLE_ADD, ErrorMessage.ERROR_CHANGES_PROPERTY_WRITABLE_ADD],
234    [ApiDiffType.PROPERTY_WRITABLE_REDUCE, ErrorMessage.ERROR_CHANGES_PROPERTY_WRITABLE_REDUCE],
235    [ApiDiffType.DELETE_DECORATOR, ErrorMessage.ERROR_CHANGES_DELETE_DECORATOR],
236    // 13.常量变更
237    [ApiDiffType.CONSTANT_VALUE_CHANGE, ErrorMessage.ERROR_CHANGES_CONSTANT_VALUE],
238    // 14.自定义类型变更
239    [ApiDiffType.TYPE_ALIAS_CHANGE, ErrorMessage.ERROR_CHANGES_TYPE_ALIAS_VALUE],
240    [ApiDiffType.TYPE_ALIAS_ADD, ErrorMessage.ERROR_CHANGES_TYPE_ALIAS_ADD],
241    [ApiDiffType.TYPE_ALIAS_REDUCE, ErrorMessage.ERROR_CHANGES_TYPE_ALIAS_REDUCE],
242    // 15.枚举类型变更
243    [ApiDiffType.ENUM_MEMBER_VALUE_CHANGE, ErrorMessage.ERROR_CHANGES_ENUM_MEMBER_VALUE],
244    // 16.是否拥有元服务能力
245    [ApiDiffType.ATOMIC_SERVICE_HAVE_TO_NA, ErrorMessage.ERROR_CHANGES_JSDOC_ATOMICSERVICE_TO_NA],
246    // 17.syscap变更
247    [ApiDiffType.SYSCAP_NA_TO_HAVE, ErrorMessage.ERROR_CHANGES_SYSCAP_NA_TO_HAVE],
248    [ApiDiffType.SYSCAP_HAVE_TO_NA, ErrorMessage.ERROR_CHANGES_SYSCAP_HAVE_TO_NA],
249    [ApiDiffType.SYSCAP_A_TO_B, ErrorMessage.ERROR_CHANGES_SYSCAP_A_TO_B],
250  ]
251);
252
253/**
254 * online error message format
255 */
256export class ApiResultSimpleInfo {
257  id: number = -1;
258  level: number = -1;
259  filePath: string = '';
260  location: string = '';
261  message: string = '';
262  type: string = '';
263  apiText: string = '';
264  apiName: string = '';
265  apiType: string = '';
266  hierarchicalRelations: string = '';
267  parentModuleName: string | undefined = '';
268
269  setID(id: number): ApiResultSimpleInfo {
270    this.id = id;
271    return this;
272  }
273
274  getID(): number {
275    return this.id;
276  }
277
278  setLevel(level: number): ApiResultSimpleInfo {
279    this.level = level;
280    return this;
281  }
282
283  getLevel(): number {
284    return this.level;
285  }
286
287  setLocation(location: string): ApiResultSimpleInfo {
288    this.location = location;
289    return this;
290  }
291
292  getLocation(): string {
293    return this.location;
294  }
295
296  setFilePath(fileFilePath: string): ApiResultSimpleInfo {
297    this.filePath = fileFilePath;
298    return this;
299  }
300
301  getFilePath(): string {
302    return this.filePath;
303  }
304
305  setMessage(message: string): ApiResultSimpleInfo {
306    this.message = message;
307    return this;
308  }
309
310  getMessage(): string {
311    return this.message;
312  }
313
314  setType(type: string): ApiResultSimpleInfo {
315    this.type = type;
316    return this;
317  }
318
319  getType(): string {
320    return this.type;
321  }
322
323  setApiText(apiText: string): ApiResultSimpleInfo {
324    this.apiText = apiText;
325    return this;
326  }
327
328  getApiText(): string {
329    return this.apiText;
330  }
331
332
333  setApiName(apiName: string): ApiResultSimpleInfo {
334    this.apiName = apiName;
335    return this;
336  }
337
338  getApiName(): string {
339    return this.apiName;
340  }
341
342  setApiType(apiType: string): ApiResultSimpleInfo {
343    this.apiType = apiType;
344    return this;
345  }
346
347  getApiType(): string {
348    return this.apiType;
349  }
350
351  setHierarchicalRelations(hierarchicalRelations: string): ApiResultSimpleInfo {
352    this.hierarchicalRelations = hierarchicalRelations;
353    return this;
354  }
355
356  getHierarchicalRelations(): string {
357    return this.hierarchicalRelations;
358  }
359
360  setParentModuleName(parentModuleName: string | undefined): ApiResultSimpleInfo {
361    this.parentModuleName = parentModuleName;
362    return this;
363  }
364
365  getParentModuleName(): string | undefined {
366    return this.parentModuleName;
367  }
368}
369
370/**
371 * local excel table error message format
372 */
373export class ApiResultInfo {
374  errorType: string = '';
375  location: string = '';
376  apiType: string = '';
377  message: string = '';
378  version: number = -1;
379  level: number = -1;
380  apiName: string = '';
381  apiFullText: string = '';
382  baseName: string = '';
383  hierarchicalRelations: string = '';
384  parentModuleName: string | undefined = '';
385  defectType: string = '';
386
387  setErrorType(errorType: string): ApiResultInfo {
388    this.errorType = errorType;
389    return this;
390  }
391
392  getErrorType(): string {
393    return this.errorType;
394  }
395
396  setLocation(location: string): ApiResultInfo {
397    this.location = location;
398    return this;
399  }
400
401  getLocation(): string {
402    return this.location;
403  }
404  setApiType(apiType: string): ApiResultInfo {
405    this.apiType = apiType;
406    return this;
407  }
408
409  getApiType(): string {
410    return this.apiType;
411  }
412
413  setMessage(message: string): ApiResultInfo {
414    this.message = message;
415    return this;
416  }
417
418  getMessage(): string {
419    return this.message;
420  }
421
422  setVersion(version: number): ApiResultInfo {
423    this.version = version;
424    return this;
425  }
426
427  getVersion(): number {
428    return this.version;
429  }
430
431  setLevel(level: number): ApiResultInfo {
432    this.level = level;
433    return this;
434  }
435
436  getLevel(): number {
437    return this.level;
438  }
439
440  setApiName(apiName: string): ApiResultInfo {
441    this.apiName = apiName;
442    return this;
443  }
444
445  getApiName(): string {
446    return this.apiName;
447  }
448
449  setApiFullText(apiFullText: string): ApiResultInfo {
450    this.apiFullText = apiFullText;
451    return this;
452  }
453
454  getApiFullText(): string {
455    return this.apiFullText;
456  }
457  setBaseName(baseName: string): ApiResultInfo {
458    this.baseName = baseName;
459    return this;
460  }
461
462  getBaseName(): string {
463    return this.baseName;
464  }
465
466  setHierarchicalRelations(hierarchicalRelations: string): ApiResultInfo {
467    this.hierarchicalRelations = hierarchicalRelations;
468    return this;
469  }
470
471  getHierarchicalRelations(): string {
472    return this.hierarchicalRelations;
473  }
474
475  setParentModuleName(parentModuleName: string | undefined): ApiResultInfo {
476    this.parentModuleName = parentModuleName;
477    return this;
478  }
479
480  getParentModuleName(): string | undefined {
481    return this.parentModuleName;
482  }
483
484  setDefectType(defectType: string): ApiResultInfo {
485    this.defectType = defectType;
486    return this;
487  }
488
489  getDefectType(): string {
490    return this.defectType;
491  }
492}
493
494/**
495 * error message format
496 */
497export interface ErrorTagFormat {
498  state: boolean;
499  errorInfo: string;
500}
501
502/**
503 * permission message format
504 */
505export interface PermissionData {
506  name: string;
507  grantMode: string;
508  since: number;
509  deprecated: string;
510  availableLevel: string;
511  provisionEnable: boolean;
512  distributedSceneEnable: boolean;
513  label: string;
514  description: string;
515}
516
517/**
518 * naming dictionary format
519 */
520export interface NameDictionaryType {
521  badWord: string;
522  suggestion: string;
523  ignore: string[];
524}
525
526/**
527 * naming dictionary format for file
528 */
529export interface NameScenarioType {
530  word: string;
531  files: string[];
532}
533
534/**
535 * error message format
536 */
537export class ApiResultMessage {
538  analyzerName: string = 'apiengine';
539  buggyFilePath: string = '';
540  codeContextStaerLine: string = '';
541  defectLevel: number = -1;
542  defectType: string = '';
543  description: string = '';
544  language: string = 'typescript';
545  mainBuggyCode: string = '';
546  mainBuggyLine: string = '';
547  extendInfo: ApiBaseInfo = new ApiBaseInfo();
548
549  setLocation(codeContextStaerLine: string): ApiResultMessage {
550    this.codeContextStaerLine = codeContextStaerLine;
551    return this;
552  }
553
554  getLocation(): string {
555    return this.codeContextStaerLine;
556  }
557
558  setLevel(defectLevel: number): ApiResultMessage {
559    this.defectLevel = defectLevel;
560    return this;
561  }
562
563  getLevel(): number {
564    return this.defectLevel;
565  }
566
567  setType(defectType: string): ApiResultMessage {
568    this.defectType = defectType;
569    return this;
570  }
571
572  getType(): string {
573    return this.defectType;
574  }
575
576  setFilePath(fileFilePath: string): ApiResultMessage {
577    this.buggyFilePath = fileFilePath;
578    return this;
579  }
580
581  getFilePath(): string {
582    return this.buggyFilePath;
583  }
584
585  setMessage(description: string): ApiResultMessage {
586    this.description = description;
587    return this;
588  }
589
590  getMessage(): string {
591    return this.description;
592  }
593  setMainBuggyCode(mainBuggyCode: string): ApiResultMessage {
594    this.mainBuggyCode = mainBuggyCode;
595    return this;
596  }
597
598  getMainBuggyCode(): string {
599    return this.mainBuggyCode;
600  }
601
602  setMainBuggyLine(mainBuggyLine: string): ApiResultMessage {
603    this.mainBuggyLine = mainBuggyLine;
604    return this;
605  }
606
607  getMainBuggyLine(): string {
608    return this.mainBuggyLine;
609  }
610
611  setExtendInfo(extendInfo: ApiBaseInfo): ApiResultMessage {
612    this.extendInfo = extendInfo;
613    return this;
614  }
615
616  getExtendInfo(): ApiBaseInfo {
617    return this.extendInfo;
618  }
619}
620
621/**
622 * error message format
623 */
624export class ApiCheckInfo {
625  errorID: number = -1;
626  errorLevel: number = -1;
627  filePath: string = '';
628  apiPostion: ts.LineAndCharacter = { line: -1, character: -1 };
629  errorType: string = '';
630  logType: string = '';
631  sinceNumber: number = -1;
632  apiName: string = '';
633  apiType: string = '';
634  apiText: string = '';
635  errorInfo: string = '';
636  hierarchicalRelations: string = '';
637  parentModuleName: string | undefined = '';
638
639  setErrorID(errorID: number): ApiCheckInfo {
640    this.errorID = errorID;
641    return this;
642  }
643
644  getErrorID(): number {
645    return this.errorID;
646  }
647
648  setErrorLevel(errorLevel: number): ApiCheckInfo {
649    this.errorLevel = errorLevel;
650    return this;
651  }
652
653  getErrorLevel(): number {
654    return this.errorLevel;
655  }
656
657  setFilePath(filePath: string): ApiCheckInfo {
658    this.filePath = filePath;
659    return this;
660  }
661
662  getFilePath(): string {
663    return this.filePath;
664  }
665
666  setApiPostion(apiPostion: ts.LineAndCharacter): ApiCheckInfo {
667    this.apiPostion = apiPostion;
668    return this;
669  }
670
671  getApiPostion(): ts.LineAndCharacter {
672    return this.apiPostion;
673  }
674
675  setErrorType(errorType: string): ApiCheckInfo {
676    this.errorType = errorType;
677    return this;
678  }
679
680  getErrorType(): string {
681    return this.errorType;
682  }
683
684  setLogType(logType: string): ApiCheckInfo {
685    this.logType = logType;
686    return this;
687  }
688
689  getLogType(): string {
690    return this.logType;
691  }
692
693  setSinceNumber(sinceNumber: number): ApiCheckInfo {
694    this.sinceNumber = sinceNumber;
695    return this;
696  }
697
698  getSinceNumber(): number {
699    return this.sinceNumber;
700  }
701
702  setApiName(apiName: string): ApiCheckInfo {
703    this.apiName = apiName;
704    return this;
705  }
706
707  getApiName(): string {
708    return this.apiName;
709  }
710
711  setApiType(apiType: string): ApiCheckInfo {
712    this.apiType = apiType;
713    return this;
714  }
715
716  getApiType(): string {
717    return this.apiType;
718  }
719
720  setApiText(apiText: string): ApiCheckInfo {
721    this.apiText = apiText;
722    return this;
723  }
724
725  getApiText(): string {
726    return this.apiText;
727  }
728
729  setErrorInfo(errorInfo: string): ApiCheckInfo {
730    this.errorInfo = errorInfo;
731    return this;
732  }
733
734  getErrorInfo(): string {
735    return this.errorInfo;
736  }
737
738  setHierarchicalRelations(hierarchicalRelations: string): ApiCheckInfo {
739    this.hierarchicalRelations = hierarchicalRelations;
740    return this;
741  }
742
743  getHierarchicalRelations(): string {
744    return this.hierarchicalRelations;
745  }
746
747  setParentModuleName(parentModuleName: string | undefined): ApiCheckInfo {
748    this.parentModuleName = parentModuleName;
749    return this;
750  }
751
752  getParentModuleName(): string | undefined {
753    return this.parentModuleName;
754  }
755}
756
757export class ApiBaseInfo {
758  apiName: string = '';
759  apiType: string = '';
760  hierarchicalRelations: string = '';
761  parentModuleName: string | undefined = '';
762
763  setApiName(apiName: string): ApiBaseInfo {
764    this.apiName = apiName;
765    return this;
766  }
767
768  getApiName(): string {
769    return this.apiName;
770  }
771  setApiType(apiType: string): ApiBaseInfo {
772    this.apiType = apiType;
773    return this;
774  }
775
776  getApiType(): string {
777    return this.apiType;
778  }
779  setHierarchicalRelations(hierarchicalRelations: string): ApiBaseInfo {
780    this.hierarchicalRelations = hierarchicalRelations;
781    return this;
782  }
783
784  getHierarchicalRelations(): string {
785    return this.hierarchicalRelations;
786  }
787  setParentModuleName(parentModuleName: string | undefined): ApiBaseInfo {
788    this.parentModuleName = parentModuleName;
789    return this;
790  }
791
792  getParentModuleName(): string | undefined {
793    return this.parentModuleName;
794  }
795
796}
797
798export class ErrorBaseInfo {
799  errorID: number = -1;
800  errorLevel: number = -1;
801  errorType: string = '';
802  logType: string = '';
803  errorInfo: string = '';
804
805  setErrorID(errorID: number): ErrorBaseInfo {
806    this.errorID = errorID;
807    return this;
808  }
809
810  getErrorID(): number {
811    return this.errorID;
812  }
813
814  setErrorLevel(errorLevel: number): ErrorBaseInfo {
815    this.errorLevel = errorLevel;
816    return this;
817  }
818
819  getErrorLevel(): number {
820    return this.errorLevel;
821  }
822
823
824  setErrorType(errorType: string): ErrorBaseInfo {
825    this.errorType = errorType;
826    return this;
827  }
828
829  getErrorType(): string {
830    return this.errorType;
831  }
832
833  setLogType(logType: string): ErrorBaseInfo {
834    this.logType = logType;
835    return this;
836  }
837
838  getLogType(): string {
839    return this.logType;
840  }
841
842  setErrorInfo(errorInfo: string): ErrorBaseInfo {
843    this.errorInfo = errorInfo;
844    return this;
845  }
846
847  getErrorInfo(): string {
848    return this.errorInfo;
849  }
850}