generated from detekt/detekt-custom-rule-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from AJIEKCX/v0.1.0/release
Prepare MavenCentral publication
- Loading branch information
Showing
16 changed files
with
194 additions
and
94 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Publish to MavenCentral | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '21' | ||
distribution: 'temurin' | ||
- name: Build and publish with Gradle | ||
uses: gradle/gradle-build-action@3 | ||
with: | ||
arguments: --no-daemon -i jreleaserConfig build test publish | ||
env: | ||
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} | ||
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} | ||
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME }} | ||
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.JRELEASER_MAVENCENTRAL_SONATYPE_TOKEN }} | ||
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} | ||
|
||
- name: Release with gradle | ||
uses: gradle/gradle-build-action@3 | ||
with: | ||
arguments: --no-daemon -i jreleaserFullRelease | ||
env: | ||
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} | ||
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} | ||
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME }} | ||
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.JRELEASER_MAVENCENTRAL_SONATYPE_TOKEN }} | ||
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
/.gradle | ||
/build | ||
/local.properties | ||
.kotlin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,48 @@ | ||
# detekt custom rule template | ||
# Decompose Detekt Rules | ||
[](https://central.sonatype.com/namespace/io.github.ajiekcx.detekt) | ||
[](http://www.apache.org/licenses/LICENSE-2.0) | ||
|
||
This repository is a template. You can use it to generate your own repository to write and share your custom rules. | ||
[Decompose](https://github.com/arkivanov/Decompose) is a Kotlin Multiplatform library for breaking down your code into tree-structured lifecycle-aware business logic components (aka BLoC), with routing functionality and pluggable UI. | ||
The Decompose Detekt Rules are a set of custom detekt rules that help you avoid critical mistakes when working with Decompose. | ||
|
||
## How to use it | ||
## Quick start | ||
|
||
1. Create a new repository using this one as a template. [Click here][create_template] | ||
2. Edit MyRule to fit your use case | ||
3. Share your rule! You can upload your rule to [Maven Central][maven_central] if you want. If you don't want to do all | ||
the steps that Maven Central requires you can just share your rule using [jitpack][jitpack]. | ||
4. Extra: you can remove all this README and explain what your rule does and how to configure it. | ||
Specify the dependency on this set of rules using `detektPlugins`: | ||
|
||
## Documentation | ||
```kotlin | ||
detektPlugins("io.github.ajiekcx.detekt:decompose-detekt-rules:0.1.0") | ||
``` | ||
|
||
You can find the documentation about how to write [custom rules here][custom_rule_documentation]. | ||
## Rules | ||
|
||
## Note | ||
### DecomposeComponentContextRule | ||
|
||
- Remember that, by default, all rules are disabled. To configure your rules edit the file in | ||
`src/main/resources/config/config.yml`. | ||
- Once you have your rules ready you can publish them on the [detekt's marketplace][detekt_marketplace] to improve the discoverability. To do so create a PR editing [this file][detekt_marketplace_edit]. | ||
A common mistake is to create a Decompose `ComponentContext` inside a Composable function scope. For example: | ||
```kotlin | ||
class MainActivity: ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
[create_template]: https://github.com/detekt/detekt-custom-rule-template/generate | ||
setContent { | ||
// DON'T DO THIS | ||
val context = defaultComponentContext() | ||
} | ||
} | ||
} | ||
``` | ||
|
||
[maven_central]: https://search.maven.org/ | ||
If recomposition occurs without Activity recreation, you will get the following exception: | ||
``` | ||
java.lang.IllegalArgumentException: SavedStateProvider with the given key is already registered | ||
``` | ||
|
||
[custom_rule_documentation]: https://detekt.github.io/detekt/extensions.html | ||
Avoid using the `defaultComponentContext` function inside Composable functions. | ||
|
||
[jitpack]: https://jitpack.io/ | ||
## Enabling rules | ||
|
||
[detekt_marketplace]: https://detekt.dev/marketplace | ||
[detekt_marketplace_edit]: https://github.com/detekt/detekt/blob/main/website/src/data/marketplace.js | ||
By default, all rules are enabled, but you can configure them in your `detekt.yml` configuration file: | ||
```yaml | ||
DecomposeRuleSet: | ||
DecomposeComponentContextRule: | ||
active: true | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
kotlin.code.style=official | ||
|
||
GROUP=io.github.ajiekcx.detekt | ||
VERSION_NAME=0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[versions] | ||
kotlin = "2.0.21" | ||
detekt = "1.23.7" | ||
kotest = "5.9.1" | ||
jupiter = "5.11.4" | ||
jreleaser = "1.16.0" | ||
|
||
[plugins] | ||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } | ||
jreleaser = { id = "org.jreleaser", version.ref = "jreleaser" } | ||
|
||
[libraries] | ||
detekt-api = { module = "io.gitlab.arturbosch.detekt:detekt-api", version.ref = "detekt" } | ||
detekt-test = { module = "io.gitlab.arturbosch.detekt:detekt-test", version.ref = "detekt" } | ||
kotest = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" } | ||
jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "jupiter" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...e/detekt/DecomposeComponentContextRule.kt → ...x/detekt/DecomposeComponentContextRule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...xample/detekt/DecomposeRuleSetProvider.kt → ...jiekcx/detekt/DecomposeRuleSetProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/org/example/detekt/Utils.kt → .../kotlin/io/github/ajiekcx/detekt/Utils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
org.example.detekt.DecomposeRuleSetProvider | ||
io.github.ajiekcx.detekt.DecomposeRuleSetProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
DecomposeRuleSetProvider: | ||
DecomposeRuleSet: | ||
DecomposeComponentContextRule: | ||
active: true |
2 changes: 1 addition & 1 deletion
2
...tekt/DecomposeComponentContextRuleTest.kt → ...tekt/DecomposeComponentContextRuleTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters