codecheck问题修改

Signed-off-by: wangcaoyu <wangcaoyu@huawei.com>
This commit is contained in:
wangcaoyu 2024-11-15 16:10:49 +08:00
parent d0d4a37420
commit 1e3e9744ad
11 changed files with 27 additions and 23 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -59,7 +59,7 @@ export class Check {
ApiChangeCheck.checkApiChange(prId);
files.forEach((filePath: string, index: number) => {
currentFilePath = filePath;
if (process.env.NODE_ENV !== "development" && filePath.indexOf('build-tools') !== -1) {
if (process.env.NODE_ENV !== 'development' && filePath.indexOf('build-tools') !== -1) {
return;
}
console.log(`scaning file in no ${++index}!`);

View File

@ -255,7 +255,7 @@ export class LegalityCheck {
* systemapi and atomicservice cannot exist at the same time
* @param apiJsdoc
*/
static checkSystemapiAtomicservice(apiJsdoc: Comment.JsDocInfo, apiLegalityCheckResult: ErrorTagFormat[]) {
static checkSystemapiAtomicservice(apiJsdoc: Comment.JsDocInfo, apiLegalityCheckResult: ErrorTagFormat[]): void {
const apiSystemapiAtomicservice: ErrorTagFormat = {
state: true,
errorInfo: '',
@ -263,12 +263,12 @@ export class LegalityCheck {
const tagsName: string[] = [];
apiJsdoc.tags?.forEach((tag: Comment.CommentTag) => {
tagsName.push(tag.tag);
})
});
const hasSystemapi: boolean = tagsName.includes('systemapi');
const hasAtomicservice: boolean = tagsName.includes('atomicservice');
if (hasSystemapi && hasAtomicservice) {
apiSystemapiAtomicservice.state=false;
apiSystemapiAtomicservice.errorInfo=ErrorMessage.ERROR_ERROR_SYSTEMAPI_ATOMICSERVICE;
apiSystemapiAtomicservice.state = false;
apiSystemapiAtomicservice.errorInfo = ErrorMessage.ERROR_ERROR_SYSTEMAPI_ATOMICSERVICE;
}
apiLegalityCheckResult.push(apiSystemapiAtomicservice);
}

View File

@ -417,7 +417,8 @@ export class TagValueCheck {
const throws401DescriptionOneIndexof: number = specialThrowsDescription.indexOf(throwsTagDescriptionArr[1]);
const throws401DescriptionTwoIndexof: number = specialThrowsDescription.indexOf(throwsTagDescriptionArr[2]);
const throws401DescriptionThreeIndexof: number = specialThrowsDescription.indexOf(throwsTagDescriptionArr[3]);
const hasDescriptionContent: boolean = throws401DescriptionOneIndexof !== -1 || throws401DescriptionTwoIndexof !== -1 || throws401DescriptionThreeIndexof !== -1;
const hasDescriptionContent: boolean = throws401DescriptionOneIndexof !== -1 ||
throws401DescriptionTwoIndexof !== -1 || throws401DescriptionThreeIndexof !== -1;
const descriptionReg = new RegExp(`${throwsTagDescriptionArr[0]}|${throwsTagDescriptionArr[1]}|${throwsTagDescriptionArr[2]}|${throwsTagDescriptionArr[3]}|<br>`, 'g');
const hasElseString: boolean = /[A-Za-z]+/.test(specialThrowsDescription.replace(descriptionReg, ''));
if (throws401DescriptionStartIndexof === -1 || throws401DescriptionStartIndexof > 1 || !hasDescriptionContent ||

View File

@ -1226,7 +1226,7 @@ export namespace DiffProcessorHelper {
return false;
}
let newApiInfos: BasicApiInfo[] | PropertyInfo[] = []
let newApiInfos: BasicApiInfo[] | PropertyInfo[] = [];
if (newApiInfo.getApiType() === ApiType.TYPE_ALIAS) {
newApiInfos = (newApiInfo as TypeAliasInfo).getTypeLiteralApiInfos();
} else if (newApiInfo.getApiType() === ApiType.INTERFACE) {

View File

@ -312,7 +312,7 @@ export class DiffHelper {
newMethodInfoMap: Map<string, ApiInfo>,
diffInfos: BasicDiffInfo[],
isCheck?: boolean
) {
): void {
for (const newApiInfo of newMethodInfoMap.values()) {
const newJsDocInfo: Comment.JsDocInfo | undefined = newApiInfo.getPenultimateJsDocInfo();
for (const oldApiInfo of oldMethodInfoMap.values()) {
@ -528,7 +528,7 @@ export class DiffHelper {
static setApiInfoMap(apiInfoMap: Map<string, ApiInfo>, apiInfos: ApiInfo[]): void {
apiInfos.forEach((apiInfo: ApiInfo) => {
const key: string = `${apiInfo.getDefinedText()}#${apiInfo.getJsDocText()}#${JSON.stringify(apiInfo.getDecorators())}`
const key: string = `${apiInfo.getDefinedText()}#${apiInfo.getJsDocText()}#${JSON.stringify(apiInfo.getDecorators())}`;
apiInfoMap.set(key, apiInfo);
});
}

View File

@ -570,7 +570,7 @@ export class NodeProcessorHelper {
*/
static getCurrentEnumValue(enumInfo: BasicApiInfo): string {
if (!(enumInfo instanceof EnumInfo)) {
return "";
return '';
}
const length: number = enumInfo.getChildApis().length;
if (length === 0) {
@ -799,7 +799,7 @@ export class NodeProcessorHelper {
paramInfo: ParamInfo,
isParam: boolean = true
): void {
let typeNodeName: string = "";
let typeNodeName: string = '';
const typeArguments: ts.NodeArray<ts.TypeNode> | undefined = typeNode.typeArguments;
typeArguments?.forEach((typeArgument: ts.TypeNode) => {
NodeProcessorHelper.processFunctionTypeNode(typeArgument, methodInfo, paramInfo, isParam);
@ -838,12 +838,13 @@ export class NodeProcessorHelper {
const baseApiInfo: ApiInfo[] = currentMap.get(StringConstant.SELF) as ApiInfo[];
const apiInfo: ApiInfo = baseApiInfo[0];
NodeProcessorHelper.typeReferenceFileMap.set(typeNodeName, apiInfo);
if (apiInfo) {
if (isParam) {
paramInfo.addTypeLocations(apiInfo);
} else {
methodInfo.addTypeLocations(apiInfo);
}
if (!apiInfo) {
return;
}
if (isParam) {
paramInfo.addTypeLocations(apiInfo);
} else {
methodInfo.addTypeLocations(apiInfo);
}
}
} catch (error) {

View File

@ -31,7 +31,7 @@ import * as ResultsInfo from '../../typedef/parser/ResultsInfo';
*/
export class Parser {
static needLib: boolean = false;
static cleanParserParamSDK() {
static cleanParserParamSDK(): void {
parserParam.setFileDir('');
parserParam.setSdkPath('');
}

View File

@ -899,7 +899,7 @@ export class ParamInfo {
this.objLocations = objLocations;
}
setMethodApiInfo(methodApiInfo: MethodInfo | undefined) {
setMethodApiInfo(methodApiInfo: MethodInfo | undefined): void {
this.methodApiInfo = methodApiInfo;
}
@ -1035,7 +1035,9 @@ export class ParserParam {
};
this.compilerHost = ts.createCompilerHost(compilerOption);
// 设置别名
this.compilerHost.resolveModuleNames = (moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ts.ResolvedProjectReference | undefined, compilerOptions: ts.CompilerOptions) => {
this.compilerHost.resolveModuleNames = (moduleNames: string[], containingFile: string,
reusedNames: string[] | undefined, redirectedReference: ts.ResolvedProjectReference | undefined,
compilerOptions: ts.CompilerOptions) => {
return moduleNames.map(moduleName => {
if (process.env.IS_OH === 'true') {
return ts.resolveModuleName(moduleName, containingFile, compilerOptions, this.compilerHost).resolvedModule;

View File

@ -410,7 +410,7 @@ export let apiCheckResult: ApiResultMessage[] = [];
export let hierarchicalRelationsSet: Set<string> = new Set();
export function cleanApiCheckResult() {
export function cleanApiCheckResult(): void {
apiCheckResult = [];
compositiveResult = [];
hierarchicalRelationsSet = new Set();