| 919 | |
| 920 | |
| 921 | def check_library_report(result_path: str, message_id: str) -> str: |
| 922 | if message_id not in ('checkLibraryNoReturn', 'checkLibraryFunction', 'checkLibraryUseIgnore', 'checkLibraryCheckType', 'valueFlowBailoutIncompleteVar', 'unknownMacro'): |
| 923 | error_message = 'Invalid value ' + message_id + ' for message_id parameter.' |
| 924 | print_ts(error_message) |
| 925 | return error_message |
| 926 | |
| 927 | if message_id == 'unknownMacro': |
| 928 | metric = 'macros' |
| 929 | m_column = 'macro' |
| 930 | metric_link = 'unknown_macro' |
| 931 | start_marker = HEAD_MARKER |
| 932 | elif message_id == 'valueFlowBailoutIncompleteVar': |
| 933 | metric = 'variables' |
| 934 | m_column = 'Variable' |
| 935 | metric_link = 'incomplete_var' |
| 936 | start_marker = HEAD_MARKER |
| 937 | elif message_id == 'checkLibraryCheckType': |
| 938 | metric = 'types' |
| 939 | m_column = 'Type' |
| 940 | metric_link = 'check_library' |
| 941 | start_marker = INFO_MARKER |
| 942 | else: |
| 943 | metric = 'functions' |
| 944 | m_column = 'Function' |
| 945 | metric_link = 'check_library' |
| 946 | start_marker = INFO_MARKER |
| 947 | |
| 948 | functions_shown_max = 5000 |
| 949 | html = '<!DOCTYPE html>\n' |
| 950 | html += '<html><head><title>' + message_id + ' report</title></head><body>\n' |
| 951 | html += '<h1>' + message_id + ' report</h1>\n' |
| 952 | html += 'Top ' + str(functions_shown_max) + ' ' + metric + ' are shown.' |
| 953 | html += '<pre>\n' |
| 954 | column_widths = [10, 100] |
| 955 | html += '<b>' |
| 956 | html += 'Count'.rjust(column_widths[0]) + ' ' + m_column |
| 957 | html += '</b>\n' |
| 958 | |
| 959 | function_counts = {} |
| 960 | for filename in glob.glob(result_path + '/*'): |
| 961 | if not os.path.isfile(filename) or filename.endswith('.diff'): |
| 962 | continue |
| 963 | in_results = False |
| 964 | for line in open(filename, 'rt'): |
| 965 | if line.startswith('cppcheck: '): |
| 966 | if OLD_VERSION not in line: |
| 967 | # Package results seem to be too old, skip |
| 968 | break |
| 969 | # Current package, parse on |
| 970 | continue |
| 971 | if not in_results: |
| 972 | if line.startswith(start_marker): |
| 973 | in_results = True |
| 974 | continue |
| 975 | if line.startswith('diff:'): |
| 976 | break |
| 977 | if line.endswith('[' + message_id + ']\n'): |
| 978 | if message_id == 'unknownMacro': |