Skip to content

Commit

Permalink
Improve extensions.doc format with admonitions (#5055)
Browse files Browse the repository at this point in the history
More information can be seen in the Docusaurus doc:
https://docusaurus.io/docs/next/markdown-features/admonitions
  • Loading branch information
schalkms committed Jul 9, 2022
1 parent 7cdd6ca commit 8903b2e
Showing 1 changed file with 13 additions and 4 deletions.
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.

0 comments on commit 8903b2e

Please sign in to comment.