Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move "Exceptions" to after "Rationale" #245

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/rules/imports/avoid-importing-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ allow if {
}
```

**Exceptions**
## Rationale

Using an import for `input` is not necessary, as both `input` and `data` are globally available.

## Exceptions

Using an alias for `input` can sometimes be useful, e.g. when using `input` is known to represent something specific,
like a Terraform plan. Aliasing of specific input attributes should however be avoided in favor of local assignments.
Expand All @@ -58,16 +62,12 @@ allow if {
}
```

## Rationale

Using an import for `input` is not necessary, as both `input` and `data` are globally available.

## Configuration Options

This linter rule provides the following configuration options:

```yaml
rules:
rules:
imports:
avoid-importing-input:
# one of "error", "warning", "ignore"
Expand Down
12 changes: 6 additions & 6 deletions docs/rules/style/avoid-get-and-list-prefix.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ developers contains user if {
}
```

**Exceptions**

Using `is_`, or `has_` for boolean helper functions, like `is_admin(user)` may be easier to comprehend than
`admin(user)`.

## Rationale

Since Rego evaluation is generally free of side effects, any rule or function is essentially a "getter". Adding a
`get_` prefix to a rule or function (like `get_resources`) thus adds little of value compared to just naming it
`resources`. Additionally, the type and return value of the rule should serve to tell whether a rule might return a
single value (i.e. a complete rule) or a collection (a partial rule).

## Exceptions

Using `is_`, or `has_` for boolean helper functions, like `is_admin(user)` may be easier to comprehend than
`admin(user)`.

## Configuration Options

This linter rule provides the following configuration options:

```yaml
rules:
rules:
style:
avoid-get-and-list-prefix:
# one of "error", "warning", "ignore"
Expand Down
14 changes: 7 additions & 7 deletions docs/rules/style/prefer-snake-case.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ import future.keywords.in
user_is_admin if "admin" in input.user.roles
```

**Exceptions**
## Rationale

The built-in functions use `snake_case` for naming — follow that convention for your own rules, functions, and
variables, unless you have a really good reason not to.

## Exceptions

In many cases, you might not control the format of the `input` data — if the domain of a policy (e.g. Envoy)
mandates a different style, making an exception might seem reasonable. Adapting policy format after `input` is however
prone to inconsistencies, as you'll likely end up mixing different styles in the same policy (due to imports of common
code, etc).

## Rationale

The built-in functions use `snake_case` for naming — follow that convention for your own rules, functions, and
variables, unless you have a really good reason not to.

## Configuration Options

This linter rule provides the following configuration options:

```yaml
rules:
rules:
style:
prefer-snake-case:
# one of "error", "warning", "ignore"
Expand Down