Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#128]: Use prefix when working with python files #129

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/static_analysis_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def create_comment_for_output(tool_output, files_changed_in_pr, output_to_consol

Parameters:
tool_output (str): The tool output to parse.
prefix (str): The prefix to look for in order to identify issues.
files_changed_in_pr (dict): A dictionary containing the files that were
changed in the pull request and the lines that were modified.
output_to_console (bool): Whether or not to output the results to the console.
Expand All @@ -75,6 +74,8 @@ def create_comment_for_output(tool_output, files_changed_in_pr, output_to_consol
list_of_issues = []
per_issue_string = ""

utils.debug_print(f"PyLint output:\n{tool_output}\n")

for line in tool_output:
file_path = line["path"]
file_line_start = line["line"]
Expand Down Expand Up @@ -104,7 +105,11 @@ def create_comment_for_output(tool_output, files_changed_in_pr, output_to_consol
)

new_line = utils.generate_output(
False, ("", file_path), file_line_start, file_line_end, description
False,
(utils.WORK_DIR, file_path),
file_line_start,
file_line_end,
description,
)

if utils.check_for_char_limit(new_line):
Expand Down
6 changes: 3 additions & 3 deletions test/test_static_analysis_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import utils.helper_functions as utils

try:
project_path = f"{os.sep}".join(os.path.abspath(__file__).split(os.sep)[:-2])
sys.path.append(project_path)
PROJECT_PATH = f"{os.sep}".join(os.path.abspath(__file__).split(os.sep)[:-2])
sys.path.append(PROJECT_PATH)
except Exception as exception:
print(f"Can not add project path to system path! Exiting!\nERROR: {exception}")
raise SystemExit(1) from exception

os.environ["GITHUB_WORKSPACE"] = f"{project_path}/test/utils/dummy_project"
os.environ["GITHUB_WORKSPACE"] = f"{PROJECT_PATH}/test/utils/dummy_project"
os.environ["INPUT_VERBOSE"] = "True"
os.environ["INPUT_REPORT_PR_CHANGES_ONLY"] = "False"
os.environ["INPUT_REPO"] = "RepoName"
Expand Down
6 changes: 3 additions & 3 deletions test/test_static_analysis_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import sys

try:
project_path = f"{os.sep}".join(os.path.abspath(__file__).split(os.sep)[:-2])
sys.path.append(project_path)
PROJECT_PATH = f"{os.sep}".join(os.path.abspath(__file__).split(os.sep)[:-2])
sys.path.append(PROJECT_PATH)
except Exception as exception:
print(f"Can not add project path to system path! Exiting!\nERROR: {exception}")
raise SystemExit(1) from exception

os.environ["GITHUB_WORKSPACE"] = f"{project_path}/test/utils/dummy_project"
os.environ["GITHUB_WORKSPACE"] = f"{PROJECT_PATH}/test/utils/dummy_project"
os.environ["INPUT_VERBOSE"] = "True"
os.environ["INPUT_REPORT_PR_CHANGES_ONLY"] = "False"
os.environ["INPUT_REPO"] = "RepoName"
Expand Down
4 changes: 2 additions & 2 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import sys

try:
project_path = f"{os.sep}".join(os.path.abspath(__file__).split(os.sep)[:-2])
sys.path.append(project_path)
PROJECT_PATH = f"{os.sep}".join(os.path.abspath(__file__).split(os.sep)[:-2])
sys.path.append(PROJECT_PATH)
except Exception as exception:
print(f"Can not add project path to system path! Exiting!\nERROR: {exception}")
raise SystemExit(1) from exception
Expand Down
Loading