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

Make the namings consistent for Detekt #38

Merged
merged 1 commit into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
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
38 changes: 36 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ dependencies {
}
```

NOTE: Currently [there seems to be an issue supporting ktlint over 0.46.0](https://github.com/JLLeitschuh/ktlint-gradle/pull/595).

### With spotless

If using [Spotless](https://github.com/diffplug/spotless), there is currently a workaround on how to do that described [in this issue](https://github.com/diffplug/spotless/issues/1220).
Expand Down Expand Up @@ -47,14 +49,46 @@ dependencies {
}
```

### Enabling rules

For the rules to be picked up, you will need to enable them in your `detekt.yml` file.

```yaml
TwitterCompose:
ContentEmitterReturningValues:
active: true
ModifierComposable:
active: true
ModifierMissing:
active: true
ModifierReused:
active: true
ModifierWithoutDefault:
active: true
MultipleEmitters:
active: true
MutableParams:
active: true
ComposableNaming:
active: true
ComposableParamOrder:
active: true
RememberMissing:
active: true
ViewModelForwarding:
active: true
ViewModelInjection:
active: true
```

### Disabling a specific rule

To disable a rule you have to follow the [instructions from the Detekt documentation](https://detekt.dev/docs/introduction/suppressing-rules), and use the id of the rule you want to disable.

For example, to disable `compose-naming-check`:
For example, to disable `ComposableNaming`:

```kotlin
@Suppress("compose-naming-check")
@Suppress("ComposableNaming")
@Composable
fun myNameIsWrong() { }
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ComposeContentEmitterReturningValuesCheck(config: Config) :
ComposeKtVisitor by ComposeContentEmitterReturningValues() {

override val issue: Issue = Issue(
id = "content-emitter-returning-values-check",
id = "ContentEmitterReturningValues",
severity = Severity.Defect,
description = ComposeContentEmitterReturningValues.ContentEmitterReturningValuesToo,
debt = Debt.TWENTY_MINS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ComposeModifierComposableCheck(config: Config) :
TwitterDetektRule(config),
ComposeKtVisitor by ComposeModifierComposable() {
override val issue: Issue = Issue(
id = "modifier-composable-check",
id = "ModifierComposable",
severity = Severity.Performance,
description = ComposeModifierComposable.ComposableModifier,
debt = Debt.TEN_MINS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ComposeModifierMissingCheck(config: Config) :
TwitterDetektRule(config),
ComposeKtVisitor by ComposeModifierMissing() {
override val issue: Issue = Issue(
id = "modifier-missing-check",
id = "ModifierMissing",
severity = Severity.Defect,
description = ComposeModifierMissing.MissingModifierContentComposable,
debt = Debt.TEN_MINS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ComposeModifierReusedCheck(config: Config) :
TwitterDetektRule(config),
ComposeKtVisitor by ComposeModifierReused() {
override val issue: Issue = Issue(
id = "modifier-reused-check",
id = "ModifierReused",
severity = Severity.Defect,
description = ComposeModifierReused.ModifierShouldBeUsedOnceOnly,
debt = Debt.TWENTY_MINS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ComposeModifierWithoutDefaultCheck(config: Config) :
override val autoCorrect: Boolean = true

override val issue: Issue = Issue(
id = "modifier-without-default-check",
id = "ModifierWithoutDefault",
severity = Severity.CodeSmell,
description = ComposeModifierWithoutDefault.MissingModifierDefaultParam,
debt = Debt.FIVE_MINS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ComposeMultipleContentEmittersCheck(config: Config) :
ComposeKtVisitor by ComposeMultipleContentEmitters() {

override val issue: Issue = Issue(
id = "multiple-emitters-check",
id = "MultipleEmitters",
severity = Severity.Defect,
description = ComposeMultipleContentEmitters.MultipleContentEmittersDetected,
debt = Debt.TWENTY_MINS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ComposeMutableParametersCheck(config: Config) :
TwitterDetektRule(config),
ComposeKtVisitor by ComposeMutableParameters() {
override val issue: Issue = Issue(
id = "mutable-params-check",
id = "MutableParams",
severity = Severity.Defect,
description = ComposeMutableParameters.MutableParameterInCompose,
debt = Debt.TWENTY_MINS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ComposeNamingCheck(config: Config) :
TwitterDetektRule(config),
ComposeKtVisitor by ComposeNaming() {
override val issue: Issue = Issue(
id = "naming-check",
id = "ComposableNaming",
severity = Severity.CodeSmell,
description = """
Composable functions that return Unit should start with an uppercase letter. They are considered declarative entities that can be either present or absent in a composition and therefore follow the naming rules for classes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ComposeParameterOrderCheck(config: Config) :
TwitterDetektRule(config),
ComposeKtVisitor by ComposeParameterOrder() {
override val issue: Issue = Issue(
id = "param-order-check",
id = "ComposableParamOrder",
severity = Severity.CodeSmell,
description = "Parameters in a composable function should be ordered following this pattern: " +
"params without defaults, modifiers, params with defaults and optionally, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ComposeRememberMissingCheck(config: Config) :
ComposeKtVisitor by ComposeRememberMissing() {

override val issue: Issue = Issue(
id = "remember-missing-check",
id = "RememberMissing",
severity = Severity.Defect,
description = """
Using mutableStateOf/derivedStateOf in a @Composable function without it being inside of a remember function.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ComposeViewModelForwardingCheck(config: Config) :
TwitterDetektRule(config),
ComposeKtVisitor by ComposeViewModelForwarding() {
override val issue: Issue = Issue(
id = "vm-forwarding-check",
id = "ViewModelForwarding",
severity = Severity.CodeSmell,
description = ComposeViewModelForwarding.AvoidViewModelForwarding,
debt = Debt.TWENTY_MINS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ComposeViewModelInjectionCheck(config: Config) :
ComposeKtVisitor by ComposeViewModelInjection() {

override val issue: Issue = Issue(
id = "vm-injection-check",
id = "ViewModelInjection",
severity = Severity.CodeSmell,
description = """
Implicit dependencies of composables should be made explicit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ class TwitterComposeRuleSetProvider : RuleSetProvider {
)

private companion object {
const val CustomRuleSetId = "twitter-compose"
const val CustomRuleSetId = "TwitterCompose"
}
}