Skip to content

Commit

Permalink
Process all non-classification keys first
Browse files Browse the repository at this point in the history
  • Loading branch information
JokeWaumans committed Sep 24, 2024
1 parent bc518be commit c5b72ed
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/mlx/warnings/regex_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,15 @@ def parse_config(self, config):
Args:
config (dict): Content of configuration file
"""
for key in config:
if key == "enabled":
continue
if key == "cq_description_template":
self.cq_description_template = Template(config['cq_description_template'])
continue
if key == "cq_default_path":
self.cq_default_path = config['cq_default_path']
continue
if key == "exclude":
self.add_patterns(config.get("exclude"), self.exclude_patterns)
continue
if (classification := key) in ["unclassified", "pending", "false_positive", "intentional", "bug"]:
config.pop("enabled")
if value := config.pop("cq_description_template", None):
self.cq_description_template = Template(value)
if value := config.pop("cq_default_path", None):
self.cq_default_path = value
if value:= config.pop("exclude", None):
self.add_patterns(value, self.exclude_patterns)
for classification in config:
if classification in ["unclassified", "pending", "false_positive", "intentional", "bug"]:
classification_lower = classification.lower().replace("_", " ")
checker = CoverityClassificationChecker(classification=classification_lower, verbose=self.verbose)
if isinstance((maximum := config[classification].get("max", 0)), (int, str)):
Expand All @@ -200,7 +196,7 @@ def parse_config(self, config):
checker.cq_findings = self.cq_findings # share object with sub-checkers
self.checkers[classification_lower] = checker
else:
print(f"WARNING: Unrecognized classification {key!r}")
print(f"WARNING: Unrecognized classification {classification!r}")

for checker in self.checkers.values():
checker.cq_enabled = self.cq_enabled
Expand Down

0 comments on commit c5b72ed

Please sign in to comment.