Skip to content

Commit

Permalink
satisfy some sonarcloud notes
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Jan 6, 2024
1 parent 15701d8 commit 5deb67c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions cpp_linter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def main():
args.step_summary,
args.file_annotations,
args.style,
args.format_review,
args.tidy_review,
)
end_log_group()

Expand Down
16 changes: 8 additions & 8 deletions cpp_linter/common_fs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from os import environ
from os.path import commonpath
from pathlib import PurePath, Path
from typing import List, Dict, Any, Union, Tuple
from typing import List, Dict, Any, Union, Tuple, Optional
from .loggers import logger, start_log_group

#: A path to generated cache artifacts. (only used when verbosity is in debug mode)
Expand Down Expand Up @@ -37,25 +37,25 @@ class FileObj:
def __init__(
self,
name: str,
additions: List[int] = [],
diff_chunks: List[List[int]] = [],
lines: List[HunkLine] = [],
additions: Optional[List[int]] = None,
diff_chunks: Optional[List[List[int]]] = None,
lines: Optional[List[HunkLine]] = None,
):
self.name: str = name #: The file name
self.additions: List[int] = additions
self.additions: List[int] = additions or []
"""A list of line numbers that contain added changes. This will be empty if
not focusing on lines changed only."""
self.diff_chunks: List[List[int]] = diff_chunks
self.diff_chunks: List[List[int]] = diff_chunks or []
"""A list of line numbers that define the beginning and ending of hunks in the
diff. This will be empty if not focusing on lines changed only."""
self.lines_added: List[List[int]] = FileObj._consolidate_list_to_ranges(
additions
additions or []
)
"""A list of line numbers that define the beginning and ending of ranges that
have added changes. This will be empty if not focusing on lines changed only.
"""
#: A list of information about each line present in the diff
self.lines = lines
self.lines = lines or []

@staticmethod
def _consolidate_list_to_ranges(numbers: List[int]) -> List[List[int]]:
Expand Down
4 changes: 2 additions & 2 deletions cpp_linter/rest_api/github_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def post_review(
logger.error("A GITHUB_TOKEN env var is required to post review comments")
if format_review:
self._post_tool_review(reviews_url, files, format_advice, "clang-format")
if format_review:
if tidy_review:
self._post_tool_review(reviews_url, files, tidy_advice, "clang-tidy")

Check warning on line 390 in cpp_linter/rest_api/github_api.py

View check run for this annotation

Codecov / codecov/patch

cpp_linter/rest_api/github_api.py#L382-L390

Added lines #L382 - L390 were not covered by tests

def _post_tool_review(
Expand All @@ -406,9 +406,9 @@ def _post_tool_review(
for file, advice in zip(files, tool_advice):
if advice.suggestion is None:
continue
total += 1
full_patch += advice.suggestion.text
for hunk in advice.suggestion.hunks:
total += 1
start_new_lines, end_new_lines = (

Check warning on line 412 in cpp_linter/rest_api/github_api.py

View check run for this annotation

Codecov / codecov/patch

cpp_linter/rest_api/github_api.py#L403-L412

Added lines #L403 - L412 were not covered by tests
GithubApiClient._get_line_position(
file, hunk.old_start + hunk.old_lines
Expand Down

0 comments on commit 5deb67c

Please sign in to comment.