Skip to content

Commit 9016d3d

Browse files
authored
Minor fixes (#1965)
- Add missing docs on `names` config option for `naming-convention` rule - Fix case of [repeated computation](#1820) Signed-off-by: Anders Eknert <anders.eknert@apple.com>
1 parent 0a00617 commit 9016d3d

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

bundle/regal/rules/custom/one-liner-rule/one_liner_rule.rego

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ _rule_body_brackets(lines) if {
6060
}
6161

6262
_comment_in_body(rule_row, comments, lines) if {
63+
num_lines := count(lines)
64+
6365
some comment in comments
6466

6567
comment_row := to_number(util.substring_to(comment.location, 0, ":"))
6668

6769
comment_row > rule_row
68-
comment_row < rule_row + count(lines)
70+
comment_row < rule_row + num_lines
6971
}

docs/rules/custom/naming-convention.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,27 @@ rules:
3232
# one of "error", "warning", "ignore"
3333
level: error
3434
conventions:
35-
# allow only "private" rules and functions, i.e. those starting with
36-
# underscore, or rules named "deny" or "allow"
37-
- pattern: '^_[a-z]+$|^deny$|^allow$'
35+
# allow only "private" rules and functions, i.e. those starting with
36+
# underscore, or rules named "deny" or "allow"
37+
- pattern: "^_[a-z]+$|^deny$|^allow$"
3838
# one of "package", "rule", "function", "variable"
3939
targets:
4040
- rule
4141
- function
4242
# any number of naming rules may be added
4343
# package names must start with "acmecorp" or "system"
44-
- pattern: '^acmecorp|^system'
44+
- pattern: "^acmecorp|^system"
4545
targets:
4646
- package
47+
# a list of names may be provided in addition to a pattern
48+
# if both a pattern and a list of names are provided, identifiers
49+
# must match either the pattern or one of the names in the list
50+
- names:
51+
- i
52+
- j
53+
- k
54+
targets:
55+
- var
4756
```
4857
4958
**Note:** In order to avoid characters accidentally getting escaped, always use single quotes to encode your regex

0 commit comments

Comments
 (0)