donate-cpu-server.py: filtered out various outdated and undesired (diff) results from reports / cleanups (#5474)

This commit is contained in:
Oliver Stöneberg 2023-09-22 12:17:33 +02:00 committed by GitHub
parent b745d9ad6e
commit ba23b20264
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 46 additions and 28 deletions

View File

@ -26,7 +26,7 @@ from urllib.parse import urlparse
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/ # Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic # Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
# changes) # changes)
SERVER_VERSION = "1.3.44" SERVER_VERSION = "1.3.45"
OLD_VERSION = '2.12.0' OLD_VERSION = '2.12.0'
@ -601,11 +601,10 @@ def summaryReport(resultsPath: str, name: str, prefix: str, marker: str) -> str:
if line.startswith(marker): if line.startswith(marker):
inResults = True inResults = True
continue continue
if line.startswith('diff:'):
if inResults:
break
if not inResults: if not inResults:
continue continue
if line.startswith('diff:'):
break
if not line.endswith(']'): if not line.endswith(']'):
continue continue
if ': note: ' in line: if ': note: ' in line:
@ -656,15 +655,24 @@ def messageIdReport(resultPath: str, marker: str, messageId: str, query_params:
url = None url = None
inResults = False inResults = False
for line in open(filename, 'rt'): for line in open(filename, 'rt'):
if line.startswith('cppcheck: '):
if OLD_VERSION not in line:
# Package results seem to be too old, skip
break
else:
# Current package, parse on
continue
if line.startswith('ftp://'): if line.startswith('ftp://'):
url = line url = line
elif line.startswith(marker):
inResults = True
elif not inResults:
continue continue
elif inResults and line.startswith('diff:'): if line.startswith(marker):
inResults = True
continue
if not inResults:
continue
if line.startswith('diff:'):
break break
elif line.endswith(e): if line.endswith(e):
if url: if url:
text += url text += url
if pkgs is not None: if pkgs is not None:
@ -701,13 +709,15 @@ def messageIdTodayReport(resultPath: str, messageId: str, marker: str) -> str:
break break
if line.startswith('ftp://'): if line.startswith('ftp://'):
url = line url = line
elif line.startswith(marker):
inResults = True
elif not inResults:
continue continue
elif inResults and line.startswith('diff:'): if line.startswith(marker):
inResults = True
continue
if not inResults:
continue
if line.startswith('diff:'):
break break
elif line.endswith(e): if line.endswith(e):
if url: if url:
text += url text += url
url = None url = None
@ -909,18 +919,22 @@ def check_library_report(result_path: str, message_id: str) -> str:
metric = 'macros' metric = 'macros'
m_column = 'macro' m_column = 'macro'
metric_link = 'unknown_macro' metric_link = 'unknown_macro'
marker = HEAD_MARKER
elif message_id == 'valueFlowBailoutIncompleteVar': elif message_id == 'valueFlowBailoutIncompleteVar':
metric = 'variables' metric = 'variables'
m_column = 'Variable' m_column = 'Variable'
metric_link = 'incomplete_var' metric_link = 'incomplete_var'
marker = HEAD_MARKER
elif message_id == 'checkLibraryCheckType': elif message_id == 'checkLibraryCheckType':
metric = 'types' metric = 'types'
m_column = 'Type' m_column = 'Type'
metric_link = 'check_library' metric_link = 'check_library'
marker = INFO_MARKER
else: else:
metric = 'functions' metric = 'functions'
m_column = 'Function' m_column = 'Function'
metric_link = 'check_library' metric_link = 'check_library'
marker = INFO_MARKER
functions_shown_max = 5000 functions_shown_max = 5000
html = '<!DOCTYPE html>\n' html = '<!DOCTYPE html>\n'
@ -937,7 +951,7 @@ def check_library_report(result_path: str, message_id: str) -> str:
for filename in glob.glob(result_path + '/*'): for filename in glob.glob(result_path + '/*'):
if not os.path.isfile(filename) or filename.endswith('.diff'): if not os.path.isfile(filename) or filename.endswith('.diff'):
continue continue
info_messages = False in_results = False
for line in open(filename, 'rt'): for line in open(filename, 'rt'):
if line.startswith('cppcheck: '): if line.startswith('cppcheck: '):
if OLD_VERSION not in line: if OLD_VERSION not in line:
@ -946,14 +960,15 @@ def check_library_report(result_path: str, message_id: str) -> str:
else: else:
# Current package, parse on # Current package, parse on
continue continue
if message_id != 'valueFlowBailoutIncompleteVar' and message_id != 'unknownMacro': if line.startswith(marker):
if line == 'info messages:\n': in_results = True
info_messages = True continue
if not info_messages: if not in_results:
continue continue
if line.startswith('diff:'):
break
if line.endswith('[' + message_id + ']\n'): if line.endswith('[' + message_id + ']\n'):
if message_id == 'unknownMacro': if message_id == 'unknownMacro':
print(line)
marker = 'required. If ' marker = 'required. If '
function_name = line[(line.find(marker) + len(marker)):line.rfind('is a macro') - 1] function_name = line[(line.find(marker) + len(marker)):line.rfind('is a macro') - 1]
elif message_id == 'valueFlowBailoutIncompleteVar': elif message_id == 'valueFlowBailoutIncompleteVar':
@ -990,16 +1005,18 @@ def check_library_function_name(result_path: str, function_name: str, query_para
function_name = urllib.parse.unquote_plus(function_name) function_name = urllib.parse.unquote_plus(function_name)
if nonfunc_id: if nonfunc_id:
id = '[' + nonfunc_id id = '[' + nonfunc_id
marker = HEAD_MARKER
else: else:
if function_name.endswith('()'): if function_name.endswith('()'):
id = '[checkLibrary' id = '[checkLibrary'
else: else:
id = '[checkLibraryCheckType]' id = '[checkLibraryCheckType]'
marker = INFO_MARKER
output_lines_list = [] output_lines_list = []
for filename in glob.glob(result_path + '/*'): for filename in glob.glob(result_path + '/*'):
if not os.path.isfile(filename) or filename.endswith('.diff'): if not os.path.isfile(filename) or filename.endswith('.diff'):
continue continue
info_messages = False in_results = False
package_url = None package_url = None
cppcheck_options = None cppcheck_options = None
for line in open(filename, 'rt'): for line in open(filename, 'rt'):
@ -1016,12 +1033,13 @@ def check_library_function_name(result_path: str, function_name: str, query_para
if line.startswith('cppcheck-options:'): if line.startswith('cppcheck-options:'):
cppcheck_options = line cppcheck_options = line
continue continue
if not nonfunc_id: if line.startswith(marker):
if line == 'info messages:\n': in_results = True
info_messages = True continue
continue if line.startswith('diff:'):
if not info_messages: break
continue if not in_results:
continue
if id not in line: if id not in line:
continue continue
if not (' ' + function_name + ' ') in line: if not (' ' + function_name + ' ') in line: