From ab1dc3b8048938d679e369185534ccfeaeef034f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20Mar=C3=ADa=20Mart=C3=ADnez=20G=C3=B3mez?= Date: Fri, 17 Jul 2020 14:01:07 +0200 Subject: [PATCH] Fix rule linter Prevent the linter to raise an exception if `examples` is `None`, as it for example currently happens in: `capa-rules/nursery/hash-data-using-murmur2.yml` We could also remove the `examples` tag in those cases, but the linter shouldn't break in any case. --- scripts/lint.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/lint.py b/scripts/lint.py index 3a017d0f..ada15a9d 100644 --- a/scripts/lint.py +++ b/scripts/lint.py @@ -136,10 +136,12 @@ class MissingExampleOffset(Lint): def check_rule(self, ctx, rule): if rule.meta.get("scope") in ("function", "basic block"): - for example in rule.meta.get("examples", []): - if example and ":" not in example: - logger.debug("example: %s", example) - return True + examples = rule.meta.get("examples") + if isinstance(examples, list): + for example in examples: + if example and ":" not in example: + logger.debug("example: %s", example) + return True class ExampleFileDNE(Lint):