Skip to content

Commit

Permalink
[cmd] Relative doc url to absolute file path
Browse files Browse the repository at this point in the history
Convert relative `doc_url` value's to absolute file paths in the
`CodeChecker checkers` output. This way other tools can
open and view these documentation files easily.
  • Loading branch information
csordasmarton committed Mar 1, 2022
1 parent 9a944f8 commit dfbaedd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion analyzer/codechecker_analyzer/cmd/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import subprocess
import sys
from collections import defaultdict
from typing import Dict, Iterable, Tuple
from typing import Dict, Iterable, List, Tuple

from codechecker_report_converter import twodim

Expand Down Expand Up @@ -564,6 +564,21 @@ def checker_info_dict(c):
print(json.dumps([c[1] for c in checkers]))


def __post_process_result(result: List[Tuple]):
""" Postprocess the given result.
It will update the value of the doc_url label and create an absolute file
path if it is a relative path.
"""
data_files_dir_path = os.environ.get('CC_DATA_FILES_DIR', '')
www_dir_path = os.path.join(data_files_dir_path, 'www')
for res in result:
for idx, (name, value) in enumerate(res[4]):
if name == 'doc_url' and not value.startswith('http'):
res[4][idx] = (name, os.path.normpath(
os.path.join(www_dir_path, value.strip(os.sep))))


def __print_checkers(args: argparse.Namespace, cl: CheckerLabels):
"""
Print checkers according to the command line arguments to the standard
Expand Down Expand Up @@ -591,6 +606,8 @@ def __print_checkers(args: argparse.Namespace, cl: CheckerLabels):
else:
result.extend(checker_info[analyzer])

__post_process_result(result)

if args.output_format == 'custom':
if result:
__print_checkers_custom_format(result)
Expand Down

0 comments on commit dfbaedd

Please sign in to comment.