From 936141f614706b01d80f38dd2bdda2fdb0207548 Mon Sep 17 00:00:00 2001 From: jce Date: Mon, 16 Dec 2024 14:41:22 +0100 Subject: [PATCH 1/4] correct docstring --- src/mlx/warnings/junit_checker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mlx/warnings/junit_checker.py b/src/mlx/warnings/junit_checker.py index 80a7c94..76be340 100644 --- a/src/mlx/warnings/junit_checker.py +++ b/src/mlx/warnings/junit_checker.py @@ -57,8 +57,8 @@ def _check_testcase(self, testcase): """Handles the check of a test case element by checking if the result is a failure/error. If it is to be excluded by a configured regex, 1 is returned. - Otherwise, when in verbose/output mode, the suite name and test case name are printed/written along with the - failure/error message. + Otherwise, when in verbose/output mode, the suite name and test case name are printed/written + In output mode, the failure/error message is written additionally. Args: testcase (junitparser.TestCase): Test case element to check for failure or error From 6dc425d4a99b908dfb030d86b81f2f02dfdde85d Mon Sep 17 00:00:00 2001 From: jce Date: Mon, 16 Dec 2024 14:42:52 +0100 Subject: [PATCH 2/4] remove unused var 'padding' --- src/mlx/warnings/polyspace_checker.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mlx/warnings/polyspace_checker.py b/src/mlx/warnings/polyspace_checker.py index b188e24..f6708d3 100644 --- a/src/mlx/warnings/polyspace_checker.py +++ b/src/mlx/warnings/polyspace_checker.py @@ -125,7 +125,6 @@ def parse_config(self, config): {\n : ,\n min: ,\n max: \n} """ self.checkers = [] - padding = 0 for family_value, data in config.items(): if family_value == "enabled": continue @@ -144,7 +143,6 @@ def parse_config(self, config): continue column_name = key.lower() check_value = value.lower() - padding = max(padding, len(f"{family_value}: {column_name}: {check_value}")) checker = PolyspaceFamilyChecker(family_value, column_name, check_value, *self.logging_args) checker.parse_config(check) self.checkers.append(checker) From ad66c25e221d716a15c5cead5c70fc4c63b978c2 Mon Sep 17 00:00:00 2001 From: jce Date: Mon, 16 Dec 2024 14:45:17 +0100 Subject: [PATCH 3/4] remove 'subchecker' attr by relying on 'name' attr --- src/mlx/warnings/polyspace_checker.py | 1 - src/mlx/warnings/regex_checker.py | 1 - src/mlx/warnings/robot_checker.py | 1 - src/mlx/warnings/warnings_checker.py | 7 +++++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mlx/warnings/polyspace_checker.py b/src/mlx/warnings/polyspace_checker.py index f6708d3..25024a0 100644 --- a/src/mlx/warnings/polyspace_checker.py +++ b/src/mlx/warnings/polyspace_checker.py @@ -163,7 +163,6 @@ def parse_config(self, config): class PolyspaceFamilyChecker(WarningsChecker): name = "polyspace_sub" - subchecker = True code_quality_severity = { "impact: high": "critical", "impact: medium": "major", diff --git a/src/mlx/warnings/regex_checker.py b/src/mlx/warnings/regex_checker.py index c772fc5..0fa4cf2 100644 --- a/src/mlx/warnings/regex_checker.py +++ b/src/mlx/warnings/regex_checker.py @@ -170,7 +170,6 @@ def parse_config(self, config): class CoverityClassificationChecker(WarningsChecker): name = "coverity_sub" - subchecker = True logging_fmt = "{checker.name_repr}: {checker.classification:<14} | {message}" SEVERITY_MAP = { "false positive": "info", diff --git a/src/mlx/warnings/robot_checker.py b/src/mlx/warnings/robot_checker.py index 4847fb2..93146fd 100644 --- a/src/mlx/warnings/robot_checker.py +++ b/src/mlx/warnings/robot_checker.py @@ -92,7 +92,6 @@ def parse_config(self, config): class RobotSuiteChecker(JUnitChecker): name = "robot_sub" - subchecker = True logging_fmt = "{checker.name_repr}: {checker.suite_name_repr:<20} {message}" def __init__(self, suite_name, *logging_args, check_suite_name=False): diff --git a/src/mlx/warnings/warnings_checker.py b/src/mlx/warnings/warnings_checker.py index 51e0063..edc33b8 100644 --- a/src/mlx/warnings/warnings_checker.py +++ b/src/mlx/warnings/warnings_checker.py @@ -39,7 +39,6 @@ def filter(self, record: logging.LogRecord) -> bool: class WarningsChecker: name = "checker" - subchecker = False logging_fmt = "{checker.name_repr}: {message}" def __init__(self, verbose, output): @@ -92,6 +91,10 @@ def __init__(self, verbose, output): def name_repr(self): return self.name.replace("_sub", "").capitalize() + @property + def is_main_checker(self): + return not self.name.endswith("_sub") + @property def cq_findings(self): """List[dict]: list of code quality findings""" @@ -209,7 +212,7 @@ def _return_error_code(self): if error_code == 0: error_code = 1 string_to_print = f"number of warnings ({self.count}) is {error_reason}." - if not self.subchecker: + if not self.is_main_checker: string_to_print += f" Returning error code {error_code}." self.logger.warning(string_to_print) return error_code From d1a3c3a5803329b69dec1fae7fb468c90fbb55c8 Mon Sep 17 00:00:00 2001 From: jce Date: Mon, 16 Dec 2024 14:50:04 +0100 Subject: [PATCH 4/4] fix logic and naming --- src/mlx/warnings/warnings_checker.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mlx/warnings/warnings_checker.py b/src/mlx/warnings/warnings_checker.py index edc33b8..bb075b6 100644 --- a/src/mlx/warnings/warnings_checker.py +++ b/src/mlx/warnings/warnings_checker.py @@ -92,8 +92,8 @@ def name_repr(self): return self.name.replace("_sub", "").capitalize() @property - def is_main_checker(self): - return not self.name.endswith("_sub") + def is_sub_checker(self): + return self.name.endswith("_sub") @property def cq_findings(self): @@ -212,7 +212,7 @@ def _return_error_code(self): if error_code == 0: error_code = 1 string_to_print = f"number of warnings ({self.count}) is {error_reason}." - if not self.is_main_checker: + if not self.is_sub_checker: string_to_print += f" Returning error code {error_code}." self.logger.warning(string_to_print) return error_code