MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / check_library_report

Function check_library_report

tools/donate-cpu-server.py:921–1006  ·  view source on GitHub ↗
(result_path: str, message_id: str)

Source from the content-addressed store, hash-verified

919
920
921def 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':

Callers 1

runMethod · 0.85

Calls 4

print_tsFunction · 0.85
strFunction · 0.85
findMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected