!13272 新增interface接口禁止新增必选属性校验

Merge pull request !13272 from fanjiaojiao/master
This commit is contained in:
openharmony_ci 2024-08-13 07:50:34 +00:00 committed by Gitee
commit 0ef3a14978
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 19 additions and 10 deletions

View File

@ -636,6 +636,11 @@ const ruleArr = ['API_DOC_ATOMICSERVICE_01',
'API_CHANGE_INCOMPATIBLE_34',
'API_CHANGE_INCOMPATIBLE_35',
'API_CHANGE_INCOMPATIBLE_36',
'API_CHANGE_INCOMPATIBLE_37',
'API_CHANGE_INCOMPATIBLE_38',
'API_CHANGE_INCOMPATIBLE_39',
'API_CHANGE_INCOMPATIBLE_40',
'API_CHANGE_INCOMPATIBLE_41',
'API_DOC_JSDOC_04'
];
exports.ruleArr = ruleArr;

File diff suppressed because one or more lines are too long

View File

@ -193,6 +193,7 @@
"API_CHANGE_INCOMPATIBLE_37": "Forbid changes: Cannot change from atomicservice to NA.",
"API_CHANGE_INCOMPATIBLE_38": "Forbid changes: Cannot change from NA to syscap.",
"API_CHANGE_INCOMPATIBLE_39": "Forbid changes: Cannot change from syscap to NA.",
"API_CHANGE_INCOMPATIBLE_40": "Forbid changes: Cannot change syscap value."
"API_CHANGE_INCOMPATIBLE_40": "Forbid changes: Cannot change syscap value.",
"API_CHANGE_INCOMPATIBLE_41":"Forbid changes: Cannot add new property to interface API."
}
}

View File

@ -93,7 +93,7 @@ export class ApiChangeCheck {
} else {
const dtsName = path.basename(diffInfo.getNewDtsName());
let apiInfoDiff: ApiCheckInfo = new ApiCheckInfo();
const hierarchicalRelations: string[] = diffInfo.getOldHierarchicalRelations();
const hierarchicalRelations: string[] = diffInfo.getNewHierarchicalRelations();
const parentModuleName: string = hierarchicalRelations[hierarchicalRelations.length - 1];
apiInfoDiff
.setErrorID(ErrorID.API_CHANGE_ERRORS_ID)
@ -107,7 +107,7 @@ export class ApiChangeCheck {
.setApiType(diffInfo.getApiType())
.setApiText(diffInfo.getNewApiDefinedText())
.setErrorInfo(errorInfo as string)
.setHierarchicalRelations(diffInfo.getOldHierarchicalRelations().join('|'))
.setHierarchicalRelations(diffInfo.getNewHierarchicalRelations().join('|'))
.setParentModuleName(parentModuleName);
AddErrorLogs.addAPICheckErrorLogs(apiInfoDiff, compositiveResult, compositiveLocalResult);
}

View File

@ -192,6 +192,7 @@ export enum ErrorMessage {
ERROR_CHANGES_SYSCAP_NA_TO_HAVE = 'Forbid changes: Cannot change from NA to syscap.',
ERROR_CHANGES_SYSCAP_HAVE_TO_NA = 'Forbid changes: Cannot change from syscap to NA.',
ERROR_CHANGES_SYSCAP_A_TO_B = 'Forbid changes: Cannot change syscap value.',
ERROR_CHANGES_ADD_PROPERTY = 'Forbid changes: Cannot add new property to interface API.',
}
export const incompatibleApiDiffTypes: Map<ApiDiffType, ErrorMessage> = new Map(
@ -251,6 +252,8 @@ export const incompatibleApiDiffTypes: Map<ApiDiffType, ErrorMessage> = new Map(
[ApiDiffType.SYSCAP_NA_TO_HAVE, ErrorMessage.ERROR_CHANGES_SYSCAP_NA_TO_HAVE],
[ApiDiffType.SYSCAP_HAVE_TO_NA, ErrorMessage.ERROR_CHANGES_SYSCAP_HAVE_TO_NA],
[ApiDiffType.SYSCAP_A_TO_B, ErrorMessage.ERROR_CHANGES_SYSCAP_A_TO_B],
// 18.interface不允许新增属性
[ApiDiffType.ADD, ErrorMessage.ERROR_CHANGES_ADD_PROPERTY]
]
);