From 5e120bce218b3a99c3647130c8ca1117471a5d64 Mon Sep 17 00:00:00 2001 From: jwx1102601 Date: Fri, 17 May 2024 16:49:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=80=82=E9=85=8Dcodecheck?= =?UTF-8?q?=E9=97=A8=E7=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jwx1102601 --- .../capi_parser/src/coreImpl/check/check.py | 14 ++++++++------ .../capi_parser/src/coreImpl/check/check_doc.py | 8 +++++--- .../capi_parser/src/coreImpl/check/check_name.py | 10 +++------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/build-tools/capi_parser/src/coreImpl/check/check.py b/build-tools/capi_parser/src/coreImpl/check/check.py index d1298f989..6359dfeb2 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check.py +++ b/build-tools/capi_parser/src/coreImpl/check/check.py @@ -80,7 +80,10 @@ def result_to_json(check_result): return json.dumps(check_result, default=lambda obj: obj.__dict__, indent=4) -def curr_entry(files_path, command: str, output): +def curr_entry(files_path, root_path, command: str, output): + # 如果根目录下没有 third_party 文件夹,则证明不是 sdk_c 仓库,不做检测 + if not os.path.exists(os.path.abspath(os.path.join(root_path, 'third_party/musl'))): + return file_list = get_files(files_path) if command == 'all': command_list = check_command_message @@ -88,7 +91,7 @@ def curr_entry(files_path, command: str, output): command_list = command.split(',') check_result_list = [] if len(file_list) > 0: - check_result_list = get_check_result_list(file_list, command_list) + check_result_list = get_check_result_list(file_list, root_path, command_list) result_list = [] if command != 'all': for result in check_result_list: @@ -99,11 +102,10 @@ def curr_entry(files_path, command: str, output): write_in_txt(result_list, output) -def get_check_result_list(file_list, command_list): +def get_check_result_list(file_list, root_path, command_list): check_result_list = [] - for file in file_list: - python_obj = parser_include_ast(os.path.dirname(file), [file]) - check_result_list.extend(process_all_json(python_obj, command_list)) + python_obj = parser_include_ast(root_path, file_list) + check_result_list.extend(process_all_json(python_obj, command_list)) return check_result_list diff --git a/build-tools/capi_parser/src/coreImpl/check/check_doc.py b/build-tools/capi_parser/src/coreImpl/check/check_doc.py index 550392f5e..606fffd50 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check_doc.py +++ b/build-tools/capi_parser/src/coreImpl/check/check_doc.py @@ -104,7 +104,8 @@ def process_tag_param(tag_info, file_doc_info: FileDocInfo, api_info) -> list: param = api_info['parm'][index] if tag_info['name'] != param['name']: main_buggy_code = get_main_buggy_code(api_info) - api_result_info = CheckOutPut(os.path.join(api_info['gn_path'], api_info['location']['location_path']), + api_result_info = CheckOutPut(os.path.abspath(os.path.join(api_info['gn_path'], + api_info['location']['location_path'])), api_info['location']['location_line'], CheckErrorMessage.API_DOC_FUNCTION_02.name, CheckErrorMessage.__getitem__(CheckErrorMessage.API_DOC_FUNCTION_02.name).value .replace('$$', tag_info['name']).replace('&&', param['name']), @@ -365,11 +366,12 @@ def process_file_doc_info(file_doc_info: FileDocInfo, file_info) -> list: def set_value_to_result(api_info, command): main_buggy_code = get_main_buggy_code(api_info) - return CheckOutPut(os.path.join(api_info['gn_path'], api_info['location']['location_path']), + return CheckOutPut(os.path.abspath(os.path.join(api_info['gn_path'], api_info['location']['location_path'])), api_info['location']['location_line'], command, CheckErrorMessage.__getitem__(command).value, main_buggy_code, api_info['location']['location_line']) def get_main_buggy_code(api_info): - main_buggy_code = '' if len(api_info['node_content']) == 0 else api_info['node_content']['content'] + main_buggy_code = os.path.basename(api_info['name']) if (len(api_info['node_content']) + == 0) else api_info['node_content']['content'] return main_buggy_code diff --git a/build-tools/capi_parser/src/coreImpl/check/check_name.py b/build-tools/capi_parser/src/coreImpl/check/check_name.py index 78e919417..b32636d43 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check_name.py +++ b/build-tools/capi_parser/src/coreImpl/check/check_name.py @@ -19,10 +19,6 @@ import re from typedef.check.check import (CheckOutPut, CheckErrorMessage) -typedefs = [CheckErrorMessage.API_NAME_UNIVERSAL_05.name, CheckErrorMessage.API_NAME_UNIVERSAL_03.name, - CheckErrorMessage.API_NAME_UNIVERSAL_07.name] - - def check_large_hump(api_info, kind, parent_kind): api_result_info_list = [] # 结构体 @@ -59,7 +55,7 @@ def check_function_name(api_info, kind, parent_kind): def set_value_to_result(api_info, command): - return CheckOutPut(os.path.join(api_info['gn_path'], api_info['location']['location_path']), + return CheckOutPut(os.path.abspath(os.path.join(api_info['gn_path'], api_info['location']['location_path'])), api_info['location']['location_line'], command, CheckErrorMessage.__getitem__(command).value, api_info['node_content']['content'], api_info['location']['location_line']) @@ -125,10 +121,10 @@ def check_all_uppercase_hump(api_info, kind, parent_kind): def check_file_name(file_info): api_result_info_list = [] - file_name = file_info['name'] + file_name = os.path.basename(file_info['name']) result = re.match(CheckName['FILE_NAME'].value, file_name) if result is None: - chck_output = CheckOutPut(os.path.join(file_info['gn_path'], file_info['name']), 0, + chck_output = CheckOutPut(os.path.abspath(os.path.join(file_info['gn_path'], file_info['name'])), 0, CheckErrorMessage.API_NAME_UNIVERSAL_14.name, CheckErrorMessage.API_NAME_UNIVERSAL_14.value, file_name, 0) api_result_info_list.append(chck_output) -- Gitee