!8748 api check命名校验--禁用词汇位置修改

Merge pull request !8748 from fanjiaojiao/master
This commit is contained in:
openharmony_ci 2024-01-15 01:59:32 +00:00 committed by Gitee
commit d69a17de03
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -64,7 +64,7 @@ function checkApiNamingWords(node, sourcefile, fileName, lowIdentifier) {
);
break;
} else {
const isIgnoreWord = checkIgnoreWord(lowercaseIgnoreWordArr, lowIdentifier);
const isIgnoreWord = checkIgnoreWord(lowercaseIgnoreWordArr, lowIdentifier, value.badWord);
if (isIgnoreWord === false) {
addAPICheckErrorLogs(node, sourcefile, fileName, ErrorType.NAMING_ERRORS, errorInfo, FileType.LOG_API,
ErrorLevel.MIDDLE
@ -74,14 +74,18 @@ function checkApiNamingWords(node, sourcefile, fileName, lowIdentifier) {
}
}
function checkIgnoreWord(lowercaseIgnoreWordArr, lowIdentifier) {
function checkIgnoreWord(lowercaseIgnoreWordArr, lowIdentifier, badWord) {
let isIgnoreWord = false;
const isNamingFoot = lowIdentifier.substring(lowIdentifier.length - badWord.length, lowIdentifier.length) === badWord;
for (let i = 0; i < lowercaseIgnoreWordArr.length; i++) {
if (lowercaseIgnoreWordArr[i] && lowIdentifier.indexOf(lowercaseIgnoreWordArr[i]) !== -1) {
isIgnoreWord = true;
break;
}
}
if (!isNamingFoot) {
isIgnoreWord = true;
}
return isIgnoreWord;
}