fix:api_check门禁报错修复

Signed-off-by: fanjiaojiao <fanjiaojiao@huawei.com>
This commit is contained in:
fanjiaojiao 2023-05-15 15:24:26 +08:00
parent ea097eae85
commit 22fc0b2eb8
5 changed files with 23 additions and 23 deletions

View File

@ -17,7 +17,7 @@
### permission文件配置
在api_check_plugin/config文件夹下创建名为“config.json”的文件用于存放permission配置文件。打开链接中的仓库打开systemres/main/config.json文件将文件内容复制到刚创建的api_check_plugin/config/config.json中
在api_check_plugin/config文件夹下存在名为“config.json”的文件用于存放permission配置文件。打开链接中的仓库打开systemres/main/config.json文件将文件内容复制到api_check_plugin/config/config.json中(覆盖原内容)
[utils_system_resources: Providing system resources such as fonts | 字体等系统资源 (gitee.com)](https://gitee.com/openharmony/utils_system_resources)

View File

@ -0,0 +1,5 @@
{
"module": {
"definePermissions": []
}
}

View File

@ -20,7 +20,7 @@ const urlSuffix = '/systemres/main/config.json';
exports.checkJSDoc = function (node, sourceFile, fileName) {
const checkLegality = require('./src/check_legality');
return checkLegality.checkJsDocOfCurrentNode(node, sourceFile, undefined, fileName);
return checkLegality.checkJsDocOfCurrentNode(node, sourceFile, fileName);
};
exports.initEnv = function (version) {

View File

@ -84,8 +84,7 @@ function checkAllNode(node, sourcefile, fileName) {
checkPermission(node, sourcefile, fileName);
if (commentNodeWhiteList.includes(node.kind)) {
const permissionConfigPath = require('../config/config.json');
checkJSDoc(node, sourcefile, permissionConfigPath, fileName);
checkJSDoc(node, sourcefile, fileName);
}
}

View File

@ -54,26 +54,26 @@ function checkJsDocLegality(node, comments, checkInfoMap) {
// 'param'
legalityCheck(node, comments, [ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature, ts.SyntaxKind.Constructor], ['param'], true, checkInfoMap,
(currentNode, checkResult) => {
if (!new Set([ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
(currentNode, checkResult) => {
if (!new Set([ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.Constructor]).has(currentNode.kind)) {
return true;
return true;
}
return currentNode.parameters && currentNode.parameters.length > 0;
}
return currentNode.parameters && currentNode.parameters.length > 0;
}
);
// 'returns'
legalityCheck(node, comments, [ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature], ['returns'], true, checkInfoMap,
(currentNode, checkResult) => {
if (!checkResult && !new Set([ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
(currentNode, checkResult) => {
if (!checkResult && !new Set([ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature]).has(currentNode.kind)) {
return false;
}
return !(!checkResult && !new Set([ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature]).has(currentNode.kind)) && (currentNode.type
return false;
}
return !(!checkResult && !new Set([ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature]).has(currentNode.kind)) && (currentNode.type
&& currentNode.type.kind !== ts.SyntaxKind.VoidKeyword);
}
}
);
// 'useinstead'
legalityCheck(node, comments, commentNodeWhiteList, ['useinstead'], true, checkInfoMap,
@ -244,11 +244,7 @@ function checkTagValue(tag, index, node, fileName, errorLogs) {
}
}
function checkJsDocOfCurrentNode(node, sourcefile, permissionConfigPath, fileName) {
let { permissionFile } = require('./utils');
if (permissionConfigPath && fs.existsSync(permissionConfigPath)) {
permissionFile = permissionConfigPath;
}
function checkJsDocOfCurrentNode(node, sourcefile, fileName) {
const checkInfoArray = [];
const comments = parseJsDoc(node);
const checkInfoMap = checkJsDocLegality(node, comments, {});
@ -281,8 +277,8 @@ function checkJsDocOfCurrentNode(node, sourcefile, permissionConfigPath, fileNam
}
exports.checkJsDocOfCurrentNode = checkJsDocOfCurrentNode;
function checkJSDoc(node, sourcefile, permissionConfigPath, fileName) {
const verificationResult = checkJsDocOfCurrentNode(node, sourcefile, permissionConfigPath, fileName);
function checkJSDoc(node, sourcefile, fileName) {
const verificationResult = checkJsDocOfCurrentNode(node, sourcefile, fileName);
let isMissingTagWhitetFile = true;
let isIllegalTagWhitetFile = true;