Skip to content

Commit

Permalink
Link to source code in rule docs (#1144)
Browse files Browse the repository at this point in the history
Fixes #1115

Signed-off-by: Anders Eknert <[email protected]>
  • Loading branch information
anderseknert authored Sep 26, 2024
1 parent efd4420 commit 75db465
Show file tree
Hide file tree
Showing 85 changed files with 183 additions and 20 deletions.
1 change: 1 addition & 0 deletions docs/rules/bugs/annotation-without-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ rules:
## Related Resources
- OPA Docs: [Annotations](https://www.openpolicyagent.org/docs/latest/policy-language/#annotations)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/annotation-without-metadata/annotation_without_metadata.rego)
## Community
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/bugs/argument-always-wildcard.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ rules:
except-function-name-pattern: "^mock_"
```
## Related Resources
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/argument-always-wildcard/argument_always_wildcard.rego)
## Community
If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/bugs/constant-condition.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ rules:
level: error
```
## Related Resources
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/constant-condition/constant_condition.rego)
## Community
If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
Expand Down
1 change: 1 addition & 0 deletions docs/rules/bugs/deprecated-builtin.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ rules:
## Related Resources
- OPA Docs: [Strict Mode](https://www.openpolicyagent.org/docs/latest/policy-language/#strict-mode)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/deprecated-builtin/deprecated_builtin.rego)
## Community
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/bugs/duplicate-rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ rules:
level: error
```
## Related Resources
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/duplicate-rule/duplicate_rule.rego)
## Community
If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
Expand Down
1 change: 1 addition & 0 deletions docs/rules/bugs/if-empty-object.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ rules:
## Related Resources
- Regal Docs: [constant-condition](https://docs.styra.com/regal/rules/bugs/constant-condition)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/if-empty-object/if_empty_object.rego)
## Community
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/bugs/if-object-literal.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ rules:
level: error
```
## Related Resources
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/if-object-literal/if_object_literal.rego)
## Community
If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
Expand Down
1 change: 1 addition & 0 deletions docs/rules/bugs/impossible-not.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ rules:
## Related Resources
- Regal Docs: [constant-condition](https://docs.styra.com/regal/rules/bugs/constant-condition)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/impossible-not/impossible_not.rego)
## Community
Expand Down
1 change: 1 addition & 0 deletions docs/rules/bugs/inconsistent-args.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ rules:
## Related Resources
- Regal Docs: [equals-pattern-matching](https://docs.styra.com/regal/rules/idiomatic/equals-pattern-matching)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/inconsistent-args/inconsistent_args.rego)
## Community
Expand Down
3 changes: 2 additions & 1 deletion docs/rules/bugs/internal-entrypoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ rules:
## Related Resources
- Rego Style Guide: [Optionally, use leading underscore for rules intended for internal use](https://docs.styra.com/opa/rego-style-guide#optionally-use-leading-underscore-for-rules-intended-for-internal-use)
- Regal Docs: [no-defined-entrypoint](https://docs.styra.com/regal/rules/idiomatic/no-defined-entrypoint)
- Regal Docs: [no-defined-entrypoint](https://docs.styra.com/regal/rules/idiomatic/no-defined-entrypoint)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/internal-entrypoint/internal_entrypoint.rego)
## Community
Expand Down
1 change: 1 addition & 0 deletions docs/rules/bugs/invalid-metadata-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ rules:
- OPA Docs: [Annotations](https://www.openpolicyagent.org/docs/latest/policy-language/#annotations)
- OPA Docs: [Accessing Annotations](https://www.openpolicyagent.org/docs/latest/policy-language/#accessing-annotations)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/invalid-metadata-attribute/invalid_metadata_attribute.rego)
## Community
Expand Down
1 change: 1 addition & 0 deletions docs/rules/bugs/leaked-internal-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ rules:
## Related Resources
- Rego Style Guide: [Optionally, use leading underscore for rules intended for internal use](https://docs.styra.com/opa/rego-style-guide#optionally-use-leading-underscore-for-rules-intended-for-internal-use)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/leaked-internal-reference/leaked_internal_reference.rego)
## Community
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/bugs/not-equals-in-loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ rules:
level: error
```
## Related Resources
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/not-equals-in-loop/not_equals_in_loop.rego)
## Community
If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/bugs/redundant-existence-check.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ rules:
level: error
```
## Related Resources
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/redundant-existence-check/redundant_existence_check.rego)
## Community
If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
Expand Down
6 changes: 5 additions & 1 deletion docs/rules/bugs/rule-named-if.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ it isn't — consider using a better name for your rule!
This linter rule provides the following configuration options:

```yaml
rules:
rules:
bugs:
rule-named-if:
# one of "error", "warning", "ignore"
level: error
```
## Related Resources
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/rule-named-if/rule_named_if.rego)
## Community
If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
Expand Down
1 change: 1 addition & 0 deletions docs/rules/bugs/rule-shadows-builtin.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ rules:
- OPA Docs: [Built-in Functions](https://www.openpolicyagent.org/docs/latest/policy-reference/#built-in-functions)
- OPA Repo: [builtin_metadata.json](https://github.com/open-policy-agent/opa/blob/main/builtin_metadata.json)
- Regal Docs: [var-shadows-builtin](https://docs.styra.com/regal/rules/bugs/var-shadows-builtin)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/rule-shadows-builtin/rule_shadows_builtin.rego)
## Community
Expand Down
1 change: 1 addition & 0 deletions docs/rules/bugs/sprintf-arguments-mismatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ rules:
## Related Resources
- OPA Docs: [Built-in Functions: `sprintf`](https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-strings-sprintf)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/sprintf-arguments-mismatch/sprintf_arguments_mismatch.rego)

## Community

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/bugs/top-level-iteration.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ data.
This linter rule provides the following configuration options:

```yaml
rules:
rules:
bugs:
top-level-iteration:
# one of "error", "warning", "ignore"
level: error
```
## Related Resources
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/top-level-iteration/top_level_iteration.rego)
## Community
If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/bugs/unassigned-return-value.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ rules:
level: error
```
## Related Resources
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/unassigned-return-value/unassigned_return_value.rego)
## Community
If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
Expand Down
1 change: 1 addition & 0 deletions docs/rules/bugs/unused-output-variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ rules:
- Regal Docs: [prefer-some-in-iteration](https://docs.styra.com/regal/rules/style/prefer-some-in-iteration)
- OPA Docs: [Strict Mode](https://www.openpolicyagent.org/docs/latest/policy-language/#strict-mode)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/unused-output-variable/unused_output_variable.rego)
## Community
Expand Down
1 change: 1 addition & 0 deletions docs/rules/bugs/var-shadows-builtin.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ rules:
- OPA Docs: [Built-in Functions](https://www.openpolicyagent.org/docs/latest/policy-reference/#built-in-functions)
- OPA Repo: [builtin_metadata.json](https://github.com/open-policy-agent/opa/blob/main/builtin_metadata.json)
- Regal Docs: [rule-shadows-builtin](https://docs.styra.com/regal/rules/bugs/rule-shadows-builtin)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/var-shadows-builtin/var_shadows_builtin.rego)
## Community
Expand Down
7 changes: 4 additions & 3 deletions docs/rules/bugs/zero-arity-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ it will remove the parentheses from a zero-arity function definition for you.
This linter rule provides the following configuration options:

```yaml
rules:
rules:
bugs:
zero-arity-function:
# one of "error", "warning", "ignore"
Expand All @@ -49,8 +49,9 @@ rules:
## Related Resources
OPA Docs: [The OPA Document Model](https://www.openpolicyagent.org/docs/latest/philosophy/#the-opa-document-model)
OPA Issues: [Allow user-defined zero-argument functions in Rego](https://github.com/open-policy-agent/opa/issues/6315)
- OPA Docs: [The OPA Document Model](https://www.openpolicyagent.org/docs/latest/philosophy/#the-opa-document-model)
- OPA Issues: [Allow user-defined zero-argument functions in Rego](https://github.com/open-policy-agent/opa/issues/6315)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/bugs/zero-arity-function/zero_arity_function.rego)
## Community
Expand Down
1 change: 1 addition & 0 deletions docs/rules/custom/forbidden-function-call.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ rules:
- OPA Docs: [Capabilities](https://www.openpolicyagent.org/docs/latest/deployments/#capabilities)
- OPA Docs: [Built-in Functions](https://www.openpolicyagent.org/docs/latest/policy-reference/#built-in-functions)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/custom/forbidden-function-call/forbidden_function_call.rego)
## Community
Expand Down
1 change: 1 addition & 0 deletions docs/rules/custom/missing-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ rules:
- OPA Docs: [Metadata](https://www.openpolicyagent.org/docs/latest/policy-language/#metadata)
- OPA Docs: [Annotations](https://www.openpolicyagent.org/docs/latest/policy-language/#annotations)
- Rego Style Guide: [Use Metadata Annotations](https://docs.styra.com/opa/rego-style-guide#use-metadata-annotations)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/custom/missing-metadata/missing_metadata.rego)
## Community
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/custom/naming-convention.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ rules:
patterns. Additionally, you'll most often want to include anchors for the start and end of the string (`^` and `$`) in
your patterns, or else your pattern might accidentally match only parts of the name rather than the whole name.

## Related Resources

- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/custom/naming-convention/naming_convention.rego)

## Community

If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/custom/one-liner-rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ rules:
level: error
```
## Related Resources
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/custom/one-line-rule/one_line_rule.rego)
## Community
If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/custom/prefer-value-in-head.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ rules:
only-scalars: false
```
## Related Resources
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/custom/prefer-value-in-head/prefer_value_in_head.rego)
## Community
If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
Expand Down
1 change: 1 addition & 0 deletions docs/rules/idiomatic/ambiguous-scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ rules:
- OPA Docs: [Annotations](https://www.openpolicyagent.org/docs/latest/policy-language/#annotations)
- Regal Docs: [no-defined-entrypoint](https://docs.styra.com/regal/rules/idiomatic/no-defined-entrypoint)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/idiomatic/ambiguous-scope/ambiguous_scope.rego)
## Community
Expand Down
1 change: 1 addition & 0 deletions docs/rules/idiomatic/boolean-assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ rules:
- Styra Blog: [How to express OR in Rego](https://www.styra.com/blog/how-to-express-or-in-rego/)
- Regal Docs: [default-over-else](https://docs.styra.com/regal/rules/style/default-over-else)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/idiomatic/boolean-assignment/boolean_assignment.rego)
## Community
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/idiomatic/custom-has-key-construct.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ rules:
level: error
```
## Related Resources
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/idiomatic/custom-has-key-construct/custom_has_key_construct.rego)
## Community
If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/idiomatic/custom-in-construct.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ rules:
level: error
```
## Related Resources
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/idiomatic/custom-in-construct/custom_in_construct.rego)
## Community
If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
Expand Down
1 change: 1 addition & 0 deletions docs/rules/idiomatic/directory-package-mismatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ rules:
- Regal Docs: [test-outside-test-package](https://docs.styra.com/regal/rules/testing/test-outside-test-package)
- OPA Docs: [Bundles](https://www.openpolicyagent.org/docs/latest/management-bundles/)
- Styra Docs: [Styra DAS](https://docs.styra.com/das)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/idiomatic/directory-package-mismatch/directory_package_mismatch.rego)
## Community
Expand Down
1 change: 1 addition & 0 deletions docs/rules/idiomatic/equals-pattern-matching.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ rules:
## Related Resources
- Styra Blog: [How to express OR in Rego](https://www.styra.com/blog/how-to-express-or-in-rego/)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/idiomatic/equals-pattern-matching/equals_pattern_matching.rego)
## Community
Expand Down
1 change: 1 addition & 0 deletions docs/rules/idiomatic/no-defined-entrypoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ rules:
- OPA Docs: [Metadata](https://www.openpolicyagent.org/docs/latest/policy-language/#metadata)
- OPA Docs: [Entrypoint](https://www.openpolicyagent.org/docs/latest/policy-language/#entrypoint)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/idiomatic/no-defined-entrypoint/no_defined_entrypoint.rego)
## Community
Expand Down
1 change: 1 addition & 0 deletions docs/rules/idiomatic/non-raw-regex-pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ rules:
- Rego Style Guide: [Use raw strings for regex patterns](https://github.com/StyraInc/rego-style-guide#use-raw-strings-for-regex-patterns)
- OPA Docs: [Regex Functions Reference](https://www.openpolicyagent.org/docs/latest/policy-reference/#regex)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/idiomatic/non-raw-regex-pattern/non_raw_regex_pattern.rego)
## Community
Expand Down
1 change: 1 addition & 0 deletions docs/rules/idiomatic/prefer-set-or-object-rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ rules:
- OPA Docs: [Generating Objects](https://www.openpolicyagent.org/docs/latest/policy-language/#generating-objects)
- OPA Docs: [Comprehensions](https://www.openpolicyagent.org/docs/latest/policy-language/#comprehensions)
- Styra Blog: [Five Things You Didn't Know About OPA](https://www.styra.com/blog/five-things-you-didnt-know-about-opa/)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/idiomatic/prefer-set-or-object-rule/prefer_set_or_object_rule.rego)
## Community
Expand Down
3 changes: 2 additions & 1 deletion docs/rules/idiomatic/use-contains.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ automatically at any applicable location by the `opa fmt` tool.
This linter rule provides the following configuration options:

```yaml
rules:
rules:
idiomatic:
use-contains:
# one of "error", "warning", "ignore"
Expand All @@ -66,6 +66,7 @@ rules:
- Regal Docs: [use-if](https://docs.styra.com/regal/rules/idiomatic/use-if)
- OPA Docs: [Future Keywords](https://www.openpolicyagent.org/docs/latest/policy-language/#future-keywords)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/idiomatic/use-contains/use_contains.rego)
## Community
Expand Down
1 change: 1 addition & 0 deletions docs/rules/idiomatic/use-if.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ rules:
- Regal Docs: [use-contains](https://docs.styra.com/regal/rules/idiomatic/use-contains)
- OPA Docs: [Future Keywords](https://www.openpolicyagent.org/docs/latest/policy-language/#future-keywords)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/idiomatic/use-if/use_if.rego)
## Community
Expand Down
1 change: 1 addition & 0 deletions docs/rules/idiomatic/use-in-operator.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ rules:
## Related Resources
- Rego Style Guide: [Use `in` to check for membership](https://github.com/StyraInc/rego-style-guide#use-in-to-check-for-membership)
- GitHub: [Source Code](https://github.com/StyraInc/regal/blob/main/bundle/regal/rules/idiomatic/use-in-operator/use_in_operator.rego)

## Community

Expand Down
Loading

0 comments on commit 75db465

Please sign in to comment.