Skip to content

Commit

Permalink
Linter Test 25
Browse files Browse the repository at this point in the history
  • Loading branch information
onurulgen committed Feb 12, 2024
1 parent 45df5d7 commit 85407f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
20 changes: 7 additions & 13 deletions .github/code_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,12 @@ def generate_output(is_note, file_path, file_line_start, file_line_end, descript
return new_line


def extract_info(line, prefix):
def extract_info(line):
"""
Extracts information from a given line containing file path, line number, and issue description.
Args:
- line (str): The input string containing file path, line number, and issue description.
- prefix (str): The prefix to remove from the start of the file path in the line.
- was_note (bool): Indicates if the previous issue was a note.
- output_string (str): The string containing previous output information.
Expand All @@ -373,9 +372,6 @@ def extract_info(line, prefix):
- file_line_end (int): The ending line number of the issue.
"""

# Clean up line
line = line.replace(prefix, "").lstrip("/")

# Get the line starting position /path/to/file:line and trim it
file_path_end_idx = line.index(":")
file_path = line[:file_path_end_idx]
Expand Down Expand Up @@ -429,13 +425,12 @@ def append_issue(is_note, per_issue_string, new_line, list_of_issues):
return per_issue_string


def create_comment_for_output(tool_output, prefix, files_changed_in_pr, output_to_console):
def create_comment_for_output(tool_output, files_changed_in_pr, output_to_console):
"""
Generates a comment for a GitHub pull request based on the tool output.
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 @@ -448,14 +443,14 @@ def create_comment_for_output(tool_output, prefix, files_changed_in_pr, output_t
was_note = False

for line in tool_output:
if line.startswith(prefix) and not is_excluded_dir(line):
if not is_excluded_dir(line):
(
file_path,
is_note,
file_line_start,
file_line_end,
issue_description,
) = extract_info(line, prefix)
) = extract_info(line)

# In case where we only output to console, skip the next part
if output_to_console:
Expand Down Expand Up @@ -515,6 +510,7 @@ def read_files_and_parse_results():

if parser.parse_args().fork_repository == "true":
# Make sure to use Head repository
global REPO_NAME
REPO_NAME = os.getenv("PR_REPO")

cppcheck_file_name = parser.parse_args().cppcheck
Expand All @@ -527,16 +523,14 @@ def read_files_and_parse_results():
common_ancestor = parser.parse_args().common
feature_branch = parser.parse_args().head

line_prefix = ""

debug_print(f"cppcheck result: \n {cppcheck_content} \n" f"line_prefix: {line_prefix} \n")
debug_print(f"cppcheck result: \n {cppcheck_content} \n")

files_changed_in_pr = {}
if not output_to_console and (ONLY_PR_CHANGES == "true"):
files_changed_in_pr = get_changed_files(common_ancestor, feature_branch)

cppcheck_comment, cppcheck_issues_found = create_comment_for_output(
cppcheck_content, line_prefix, files_changed_in_pr, output_to_console
cppcheck_content, files_changed_in_pr, output_to_console
)

if output_to_console and cppcheck_issues_found:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
- name: Install Python dependencies
run: pip3 install --upgrade setuptools urllib3 chardet pyOpenSSL pygithub

- name: Install CUDA Toolkit
uses: Jimver/[email protected]
with:
method: network
use-github-cache: false
use-local-cache: false
# - name: Install CUDA Toolkit
# uses: Jimver/[email protected]
# with:
# method: network
# use-github-cache: false
# use-local-cache: false

- name: Configure NiftyReg
run: |
Expand All @@ -33,8 +33,8 @@ jobs:
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_ALL_DEP=ON \
-DCHECK_GPU=OFF \
-DUSE_CUDA=ON \
-DUSE_OPENCL=ON \
-DUSE_CUDA=OFF \
-DUSE_OPENCL=OFF \
-DUSE_SSE=ON \
-DUSE_OPENMP=ON \
-DBUILD_TESTING=OFF \
Expand Down
2 changes: 1 addition & 1 deletion niftyreg_build_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
447
448

0 comments on commit 85407f8

Please sign in to comment.