Skip to content

Commit

Permalink
fix some valid codacity concerns
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Jan 2, 2024
1 parent 1052cd9 commit 394b91c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
7 changes: 5 additions & 2 deletions cpp_linter/rest_api/__init__.py
Expand Up @@ -11,6 +11,7 @@
class RestApiClient(ABC):
def __init__(self) -> None:
self.session = requests.Session()

def set_exit_code(
self,
checks_failed: int,
Expand Down Expand Up @@ -121,8 +122,10 @@ def make_comment(
comment += f"{tidy_comment}\n</details>"
else:
comment += ":heavy_check_mark:\nNo problems need attention."
comment += "\n\nHave any feedback or feature suggestions? "
"[Share it here.](https://github.com/cpp-linter/cpp-linter-action/issues)"
comment += (
"\n\nHave any feedback or feature suggestions? [Share it here.]"
+ "(https://github.com/cpp-linter/cpp-linter-action/issues)"
)
return (comment, format_checks_failed, tidy_checks_failed)

def post_feedback(
Expand Down
2 changes: 1 addition & 1 deletion tests/capture_tools_output/test_database_path.py
Expand Up @@ -45,7 +45,7 @@ def test_db_detection(
demo_src = "../demo/demo.cpp"
files = [FileObj(demo_src, [], [])]

(format_advice, tidy_advice) = capture_clang_tools_output(
_ = capture_clang_tools_output(
files,
version=os.getenv("CLANG_VERSION", "12"),
checks="", # let clang-tidy use a .clang-tidy config file
Expand Down
14 changes: 7 additions & 7 deletions tests/capture_tools_output/test_tools_output.py
Expand Up @@ -440,18 +440,18 @@ def test_parse_diff(


@pytest.mark.parametrize(
"input",
"user_input",
[["-std=c++17", "-Wall"], ["-std=c++17 -Wall"]],
ids=["separate", "unified"],
)
def test_tidy_extra_args(caplog: pytest.LogCaptureFixture, input: List[str]):
def test_tidy_extra_args(caplog: pytest.LogCaptureFixture, user_input: List[str]):
"""Just make sure --extra-arg is passed to clang-tidy properly"""
cli_in = []
for a in input:
for a in user_input:
cli_in.append(f'--extra-arg="{a}"')
caplog.set_level(logging.INFO, logger=logger.name)
args = cli_arg_parser.parse_args(cli_in)
assert len(input) == len(args.extra_arg)
assert len(user_input) == len(args.extra_arg)
_, _ = capture_clang_tools_output(
files=[FileObj("test/demo/demo.cpp", [], [])],
version=CLANG_VERSION,
Expand All @@ -467,7 +467,7 @@ def test_tidy_extra_args(caplog: pytest.LogCaptureFixture, input: List[str]):
if r.levelno == logging.INFO and r.message.startswith("Running")
]
assert messages
if len(input) == 1 and " " in input[0]:
input = input[0].split()
for a in input:
if len(user_input) == 1 and " " in user_input[0]:
user_input = user_input[0].split()
for a in user_input:
assert f'--extra-arg="{a}"' in messages[0]

0 comments on commit 394b91c

Please sign in to comment.