From 394b91c45e338c7824ca5abd7b9dd2b4d0ca65d6 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Tue, 2 Jan 2024 03:38:23 -0800 Subject: [PATCH] fix some valid codacity concerns --- cpp_linter/rest_api/__init__.py | 7 +++++-- tests/capture_tools_output/test_database_path.py | 2 +- tests/capture_tools_output/test_tools_output.py | 14 +++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cpp_linter/rest_api/__init__.py b/cpp_linter/rest_api/__init__.py index 75e653dd..db97c785 100644 --- a/cpp_linter/rest_api/__init__.py +++ b/cpp_linter/rest_api/__init__.py @@ -11,6 +11,7 @@ class RestApiClient(ABC): def __init__(self) -> None: self.session = requests.Session() + def set_exit_code( self, checks_failed: int, @@ -121,8 +122,10 @@ def make_comment( comment += f"{tidy_comment}\n" 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( diff --git a/tests/capture_tools_output/test_database_path.py b/tests/capture_tools_output/test_database_path.py index da334cd3..236eaf04 100644 --- a/tests/capture_tools_output/test_database_path.py +++ b/tests/capture_tools_output/test_database_path.py @@ -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 diff --git a/tests/capture_tools_output/test_tools_output.py b/tests/capture_tools_output/test_tools_output.py index 02d90b83..2ab6fe90 100644 --- a/tests/capture_tools_output/test_tools_output.py +++ b/tests/capture_tools_output/test_tools_output.py @@ -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, @@ -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]