Skip to content

Commit

Permalink
Fix error when env variable is used
Browse files Browse the repository at this point in the history
Use parse_config to get min and max; Conform to other checker
  • Loading branch information
JokeWaumans committed Nov 15, 2024
1 parent 11b7799 commit d1b3ff4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/mlx/warnings/regex_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,7 @@ def parse_config(self, config):
classification_key = classification.lower().replace("_", " ")
if classification_key in CoverityClassificationChecker.SEVERITY_MAP:
checker = CoverityClassificationChecker(classification=classification_key, verbose=self.verbose)
if maximum := checker_config.get("max", 0):
checker.maximum = int(maximum)
if minimum := checker_config.get("min", 0):
checker.minimum = int(minimum)
checker.parse_config(checker_config)
self.checkers[classification_key] = checker
else:
print(f"WARNING: Unrecognized classification {classification!r}")
Expand Down
8 changes: 8 additions & 0 deletions tests/test_coverity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from io import StringIO
import os
from unittest import TestCase
from pathlib import Path
import filecmp
Expand All @@ -13,9 +14,16 @@

class TestCoverityWarnings(TestCase):
def setUp(self):
os.environ['MIN_COV_WARNINGS'] = '0'
os.environ['MAX_COV_WARNINGS'] = '0'
self.warnings = WarningsPlugin(verbose=True)
self.warnings.activate_checker_name('coverity')

def tearDown(self):
for var in ('MIN_POLY_WARNINGS', 'MAX_POLY_WARNINGS'):
if var in os.environ:
del os.environ[var]

def test_no_warning_normal_text(self):
dut = 'This should not be treated as warning'
self.warnings.check(dut)
Expand Down
6 changes: 4 additions & 2 deletions tests/test_in/config_example_coverity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ coverity:
min: 0
max: -1
bug:
max: 0
pending:
min: 0
max: 0
pending:
min: $MIN_COV_WARNINGS
max: '$MAX_COV_WARNINGS'
false_positive:
min: 0
max: -1
sphinx:
enabled: false
Expand Down

0 comments on commit d1b3ff4

Please sign in to comment.