rules: range: simplify logic

This commit is contained in:
William Ballenthin
2020-06-30 00:46:19 -06:00
parent 9aba2eb3a5
commit ebff65adc4

View File

@@ -155,12 +155,8 @@ class Range(Statement):
def evaluate(self, ctx):
count = len(ctx.get(self.child, []))
if self.min == 0:
if count == 0:
return Result(True, self, [])
elif self.child not in ctx:
# self.min > 0 so there needs to be more than zero matches
return Result(False, self, [])
if self.min == 0 and count == 0:
return Result(True, self, [])
return Result(self.min <= count <= self.max, self, [], locations=ctx[self.child])