-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made easy by now having the `text` attribute present in the AST. Thanks for that @charlieegan3! Fixed existing violations against this rule, which were almost exlusively in tests. Sprinkled a few ignore directives in the places where it wasn't possible to make rules any shorter. Fixes #236 Signed-off-by: Anders Eknert <anders@styra.com>
- Loading branch information
1 parent
716a574
commit de17845
Showing
17 changed files
with
306 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# METADATA | ||
# description: Max rule length exceeded | ||
package regal.rules.style["rule-length"] | ||
|
||
import future.keywords.contains | ||
import future.keywords.if | ||
import future.keywords.in | ||
|
||
import data.regal.ast | ||
import data.regal.config | ||
import data.regal.result | ||
|
||
cfg := config.for_rule("style", "rule-length") | ||
|
||
report contains violation if { | ||
some rule in input.rules | ||
lines := split(base64.decode(rule.location.text), "\n") | ||
|
||
count(lines) > cfg["max-rule-length"] | ||
|
||
not empty_body_exception(cfg, rule) | ||
|
||
violation := result.fail(rego.metadata.chain(), result.location(rule.head)) | ||
} | ||
|
||
empty_body_exception(conf, rule) if { | ||
conf["except-empty-body"] == true | ||
count(rule.body) == 1 | ||
rule.body[0].terms.type == "boolean" | ||
rule.body[0].terms.value == true | ||
} |
Oops, something went wrong.