!12226 错误吗检查

Merge pull request !12226 from lixudong/master
This commit is contained in:
openharmony_ci 2024-06-26 09:17:34 +00:00 committed by Gitee
commit c1402c527f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 135 additions and 5 deletions

View File

@ -121,7 +121,8 @@
"API_DOC_JSDOC_01": "Jsdoc needs to be added to the current API.",
"API_DOC_JSDOC_02": "JSDoc tag validity verification failed. Please confirm if the [since] tag is missing.JSDoc tag validity verification failed. Please confirm if the [syscap] tag is missing.",
"API_DOC_JSDOC_03": "JSDoc has chinese.",
"API_DOC_UNKNOW_DECORATOR_01": "The [XXXX] tag does not exist. Please use a valid JSDoc tag."
"API_DOC_UNKNOW_DECORATOR_01": "The [XXXX] tag does not exist. Please use a valid JSDoc tag.",
"API_ERROR_ERROR_CODE": "The generic error code does not contain the current error code."
},
"DEFINE": {
"API_DEFINE_UNALLOWABLE_01": "Illegal [any] keyword used in the API.",

View File

@ -45,6 +45,7 @@ import { TagInheritCheck } from './tag_inherit_check';
import { ChineseCheck } from "./check_chinese";
import { AnonymousFunctionCheck } from './check_anonymous_function';
export let currentFilePath: string = '';
import {CheckErrorCode} from "./check_error_code";
export class Check {
/**
@ -167,6 +168,8 @@ export class Check {
const namingCheckResult: ErrorTagFormat = ApiNamingCheck.namingCheck(singleApi);
// check jsdoc chinese
const chineseCheckResult: ErrorTagFormat = ChineseCheck.checkChinese(apiJsdoc);
// check error code
const errorCodeResult: ErrorTagFormat = CheckErrorCode.checkErrorCode(apiJsdoc);
// tags name check
const tagNamseCheckResult: ErrorTagFormat = TagNameCheck.tagNameCheck(apiJsdoc);
// tags inherit check
@ -259,6 +262,22 @@ export class Check {
compositiveLocalResult
);
}
if (!errorCodeResult.state) {
AddErrorLogs.addAPICheckErrorLogs(
ErrorID.ERROR_ERROR_CODE,
ErrorLevel.MIDDLE,
singleApi.getFilePath(),
singleApi.getPos(),
ErrorType.ERROR_ERROR_CODE,
LogType.LOG_JSDOC,
toNumber(apiJsdoc.since),
singleApi.getApiName(),
singleApi.getDefinedText(),
errorCodeResult.errorInfo,
compositiveResult,
compositiveLocalResult,
);
}
tagInheritCheckResult.forEach((InheritCheckResult: ErrorTagFormat) => {
if (!InheritCheckResult.state) {
AddErrorLogs.addAPICheckErrorLogs(

View File

@ -1,3 +1,18 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {ErrorMessage, ErrorTagFormat,} from '../../../typedef/checker/result_type';
import {CommonFunctions} from '../../../utils/checkUtils';
import {Comment} from "../../../typedef/parser/Comment";

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Comment} from "../../../typedef/parser/Comment";
import {ErrorMessage, ErrorTagFormat} from "../../../typedef/checker/result_type";
import {CommonFunctions} from "../../../utils/checkUtils";
export class CheckErrorCode {
static errorCodeList: number[] = [201, 202, 203, 301, 401, 501, 502, 801, 901];
static isArrayNotEmpty(arr: any): boolean {
return Array.isArray(arr) && arr.length > 0;
}
/**
* arr1中的每个数字是否在数组arr2中
* @param arr1
* @param arr2
*/
static hasNumberInArray(arr1: number[], arr2: number[]): boolean {
return arr1.every(num => arr2.includes(num));
}
static checkErrorCode(apiJsdoc: Comment.JsDocInfo): ErrorTagFormat {
const checkResult: ErrorTagFormat = {
state: true,
errorInfo: '',
};
const errorCodes = apiJsdoc.errorCodes.filter(number => number >= 100 && number < 1000);
;
if (this.isArrayNotEmpty(errorCodes)) {
if (!this.hasNumberInArray(errorCodes, this.errorCodeList)) {
checkResult.state = false;
checkResult.errorInfo = ErrorMessage.ERROR_ERROR_CODE;
}
}
return checkResult;
}
}

View File

@ -35,7 +35,8 @@ export enum ErrorType {
API_CHANGE_ERRORS = 'api change errors',
TS_SYNTAX_ERROR = 'TS syntax error',
NO_JSDOC = 'No jsdoc',
JSDOC_HAS_CHINESE = 'JSDOC_HAS_CHINESE'
JSDOC_HAS_CHINESE = 'JSDOC_HAS_CHINESE',
ERROR_ERROR_CODE = 'error_error_code'
}
/**
@ -58,7 +59,8 @@ export enum ErrorID {
API_CHANGE_ERRORS_ID = 12,
TS_SYNTAX_ERROR_ID = 13,
NO_JSDOC_ID = 14,
JSDOC_HAS_CHINESE = 15
JSDOC_HAS_CHINESE = 15,
ERROR_ERROR_CODE = 16
}
/**
@ -160,7 +162,7 @@ export enum ErrorMessage {
ERROR_NO_JSDOC = 'Jsdoc needs to be added to the current API.',
ERROR_NO_JSDOC_TAG = 'add tags to the Jsdoc.',
ERROR_HAS_CHINESE= 'Jsdoc has chinese.',
ERROR_ERROR_CODE = 'The generic error code does not contain the current error code.'
}
export const incompatibleApiDiffTypes: Map<ApiDiffType, ErrorMessage> = new Map([

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @kit ConnectivityKit
*/
/**
* @typedef StartBLEScanOptions
* @syscap SystemCapability.Communication.Bluetooth.Lite
* @since 6
*/
export interface StartBLEScanOptions {
/**
* Initializes the connected NFC tag.
*
* @throws { BusinessError } 209 - Capability not supported.
* @throws { BusinessError } 3200101 - Connected NFC tag running state is abnormal in service.
* @syscap SystemCapability.Communication.ConnectedTag
* @since 9
*/
initialize(): void;
}

View File

@ -1,2 +1,2 @@
# api absolute path
# api absolute path
Z:\root\interface\sdk-js\api\xxx.d.ts