Skip to content

Commit

Permalink
[feat] Accept non-existing file paths in report-converter
Browse files Browse the repository at this point in the history
Some analyzer tools (e.g. sanitizers) give an output that contains
relative source file paths. When report-converter is executed from a
directory where these absolute paths are not valid, then reports are
simply not generated. If all reports contain such a relative path, then
this message is given by report-converter:

No 'lsan' results can be found in '...'

This message is obviously false.

This patch allows non-existing file paths in the analyzer outputs. Using
further CodeChecker commands (store, parse, etc.) will emit an error
message on these paths anyway, but at least we get rid of the
incomprehensible error message above.

Fixes #4280
  • Loading branch information
bruntib committed Jul 8, 2024
1 parent 3d1a1ab commit b23b256
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,12 @@ def parse_stack_trace_line(self, line: str) -> Optional[BugPathEvent]:
return None

file_path = file_match.group('path')
if file_path and os.path.exists(file_path):
col = file_match.group('column')
return BugPathEvent(
line.rstrip(),
get_or_create_file(
os.path.abspath(file_path), self._file_cache),
int(file_match.group('line')),
int(col) if col else 0)

return None
col = file_match.group('column')
return BugPathEvent(
line.rstrip(),
get_or_create_file(os.path.abspath(file_path), self._file_cache),
int(file_match.group('line')),
int(col) if col else 0)

def create_report(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ def __get_report_hash_context_free(report: Report) -> List[str]:

if line_content == '' and \
not os.path.isfile(report.file.original_path):
LOG.error("Failed to include source line in the report hash.")
LOG.error('%s does not exists!', report.file.original_path)
LOG.warning(
"Failed to include source line in the report hash. "
'%s does not exist!', report.file.original_path)

return [
report.file.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_line(file_path: str, line_no: int, errors: str = 'ignore') -> str:
with open(file_path, mode='r', encoding='utf-8', errors=errors) as f:
return get_linef(f, line_no)
except IOError:
LOG.error("Failed to open file %s", file_path)
LOG.warning("Failed to open file %s", file_path)
return ''


Expand Down

0 comments on commit b23b256

Please sign in to comment.