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

Improve extensions.doc format with admonitions #5055

Merged
merged 1 commit into from Jul 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions website/docs/introduction/extensions.md
Expand Up @@ -13,9 +13,13 @@ The associated **code samples** to this guide can be found in the package [detek
_detekt_ uses the `ServiceLoader` pattern to collect all instances of `RuleSetProvider` interfaces.
So it is possible to define rules/rule sets and enhance _detekt_ with your own flavor.

Attention: You need a `resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider` file which
:::caution Attention

You need a `resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider` file which
has as content the fully qualified name of your `RuleSetProvider` e.g. `io.gitlab.arturbosch.detekt.sample.extensions.SampleProvider`.

:::

You can use our [GitHub template](https://github.com/detekt/detekt-custom-rule-template) to have a basic scaffolding to
develop your own custom rules. Another option is to clone the provided [detekt/detekt-sample-extensions](https://github.com/detekt/detekt/tree/main/detekt-sample-extensions) project.

Expand Down Expand Up @@ -104,9 +108,13 @@ By specifying the rule set and rule ids, _detekt_ will use the sub configuration

```val threshold = valueOrDefault("threshold", THRESHOLD)```

Note: As of version 1.2.0 detekt now verifies if all configured properties actually exist in a configuration created by `--generate-config`.
:::note

As of version 1.2.0 detekt now verifies if all configured properties actually exist in a configuration created by `--generate-config`.
This means that by default detekt does not know about your new properties.
Therefore we need to mention them in the configuration under `config>excludes`:
Therefore we need to mention them in the configuration under `config>excludes`.

:::

```yaml
config:
Expand Down Expand Up @@ -156,6 +164,7 @@ class NumberOfLoopsProcessor : FileProcessListener {
}
}
```

To let detekt know about the new processor, we specify a `resources/META-INF/services/io.gitlab.arturbosch.detekt.api.FileProcessListener` file
with the full qualify name of our processor as the content: `io.gitlab.arturbosch.detekt.sample.extensions.processors.NumberOfLoopsProcessor`.

Expand Down Expand Up @@ -243,4 +252,4 @@ you created a pure kotlin module which has no Android dependencies. `apply plugi

In detekt you can write custom rules which can manipulate your code base.
For this a cli flag `--auto-correct` and the gradle plugin property `autoCorrect` exists.
Only write auto correcting code within the `Rule#withAutoCorrect()`-function.
Only write auto correcting code within the `Rule#withAutoCorrect()`-function.