# double-negative

**Summary**: Avoid double negatives

**Category**: Style

**Avoid**

```
package negativefine if not not_finewith_friends if not without_friendsnot_fine := input.fine != truewithout_friends if count(input.friends) == 0
```

**Prefer**

```
package negativefine if input.fine == truewith_friends if count(input.friends) > 0
```

## Rationale

While rules using double negatives — like `not no_funds` — occasionally make sense, it is often worth considering whether the rule could be rewritten without the negative. For example, `not no_funds` could be rewritten as `funds` or `has_funds`, or `funds_available`.

Access control policy often includes rules using some form of double negatives, like `allow if not deny`. That's considered OK, and the `double-negative` rule is limited to check for a limited list of words:

*   `not cannot_`
*   `not no_`
*   `not non_`
*   `not not_`,

## Configuration Options

This linter rule provides the following configuration options:

```
rules:  style:    double-negative:      # one of "error", "warning", "ignore"      level: error
```

## Related Resources

*   GitHub: [Source Code](https://github.com/open-policy-agent/regal/blob/main/bundle/regal/rules/style/double-negative/double_negative.rego)