mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2025-02-01 14:02:33 +00:00
commit
c1402c527f
@ -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.",
|
||||
|
@ -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(
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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([
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
# api absolute path
|
||||
# api absolute path
|
||||
Z:\root\interface\sdk-js\api\xxx.d.ts
|
Loading…
x
Reference in New Issue
Block a user