Skip to content

Commit

Permalink
Revert docs, exclude rule, mark deprecated with ~~
Browse files Browse the repository at this point in the history
- Revert docs for 1.21.0
- Exclude ElseCaseInsteadOfExhaustiveWhen rule
- Mark deprecated with Strikethrough font.
  • Loading branch information
VitalyVPinchuk committed Sep 21, 2022
1 parent 2344934 commit 31702d6
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 14 deletions.
2 changes: 2 additions & 0 deletions config/detekt/detekt.yml
Expand Up @@ -124,6 +124,8 @@ potential-bugs:
active: true
DoubleMutabilityForCollection:
active: false
ElseCaseInsteadOfExhaustiveWhen:
active: true
ExitOutsideMain:
active: false
HasPlatformType:
Expand Down
2 changes: 2 additions & 0 deletions detekt-core/src/main/resources/default-detekt-config.yml
Expand Up @@ -419,6 +419,8 @@ potential-bugs:
- 'java.util.HashSet'
- 'java.util.LinkedHashMap'
- 'java.util.HashMap'
ElseCaseInsteadOfExhaustiveWhen:
active: false
EqualsAlwaysReturnsTrueOrFalse:
active: true
EqualsWithHashCodeExist:
Expand Down
1 change: 0 additions & 1 deletion detekt-core/src/main/resources/deprecation.properties
@@ -1,7 +1,6 @@
complexity>LongParameterList>threshold=Use `functionThreshold` and `constructorThreshold` instead
empty-blocks>EmptyFunctionBlock>ignoreOverriddenFunctions=Use `ignoreOverridden` instead
potential-bugs>DuplicateCaseInWhenExpression=Rule deprecated as compiler performs this check by default
potential-bugs>ElseCaseInsteadOfExhaustiveWhen=Rule deprecated as compiler performs this check by default
potential-bugs>IgnoredReturnValue>restrictToAnnotatedMethods=Use `restrictToConfig` instead
potential-bugs>LateinitUsage>excludeAnnotatedProperties=Use `ignoreAnnotated` instead
potential-bugs>MissingWhenCase=Rule deprecated as compiler performs this check by default
Expand Down
Expand Up @@ -3,6 +3,7 @@ package io.gitlab.arturbosch.detekt.generator.printer
import io.github.detekt.utils.MarkdownContent
import io.github.detekt.utils.bold
import io.github.detekt.utils.codeBlock
import io.github.detekt.utils.crossOut
import io.github.detekt.utils.h3
import io.github.detekt.utils.h4
import io.github.detekt.utils.markdown
Expand All @@ -14,7 +15,12 @@ internal object RulePrinter : DocumentationPrinter<Rule> {

override fun print(item: Rule): String {
return markdown {
h3 { item.name }
if (item.isDeprecated()) {
h3 { crossOut { item.name } }
paragraph { escapeHtml(item.deprecationMessage!!) }
} else {
h3 { item.name }
}

if (item.description.isNotEmpty()) {
paragraph { escapeHtml(item.description) }
Expand Down
4 changes: 3 additions & 1 deletion detekt-generator/src/test/resources/RuleSet.md
Expand Up @@ -76,7 +76,9 @@ fun stuff(): Unit {}
fun stuff() {}
```

### DuplicateCaseInWhenExpression
### ~~DuplicateCaseInWhenExpression~~

is deprecated

Duplicated `case` statements in a `when` expression detected.

Expand Down
Expand Up @@ -50,7 +50,6 @@ import org.jetbrains.kotlin.types.typeUtil.isBooleanOrNullableBoolean
* </compliant>
*/
@RequiresTypeResolution
@Deprecated("Rule deprecated as compiler performs this check by default")
class ElseCaseInsteadOfExhaustiveWhen(config: Config = Config.empty) : Rule(config) {

override val issue: Issue = Issue(
Expand Down
Expand Up @@ -21,7 +21,7 @@ class PotentialBugProvider : DefaultRuleSetProvider {
DontDowncastCollectionTypes(config),
DoubleMutabilityForCollection(config),
@Suppress("DEPRECATION") DuplicateCaseInWhenExpression(config),
@Suppress("DEPRECATION") ElseCaseInsteadOfExhaustiveWhen(config),
ElseCaseInsteadOfExhaustiveWhen(config),
EqualsAlwaysReturnsTrueOrFalse(config),
EqualsWithHashCodeExist(config),
ExitOutsideMain(config),
Expand Down
Expand Up @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test

@KotlinCoreEnvironmentTest
class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment) {
private val subject = @Suppress("DEPRECATION") ElseCaseInsteadOfExhaustiveWhen()
private val subject = ElseCaseInsteadOfExhaustiveWhen()

@Nested
inner class Enum {
Expand Down
8 changes: 0 additions & 8 deletions website/versioned_docs/version-1.21.0/rules/potential-bugs.md
Expand Up @@ -156,8 +156,6 @@ var myMap = mapOf("answer" to 42)

### DuplicateCaseInWhenExpression

**Deprecated**: The rule is deprecated as compiler performs this check by default.

Flags duplicate `case` statements in `when` expressions.

If a `when` expression contains the same `case` statement multiple times they should be merged. Otherwise, it might be
Expand Down Expand Up @@ -188,8 +186,6 @@ when (i) {

### ElseCaseInsteadOfExhaustiveWhen

**Deprecated**: The rule is deprecated as compiler performs this check by default.

This rule reports `when` expressions that contain an `else` case even though they have an exhaustive set of cases.

This occurs when the subject of the `when` expression is either an enum class, sealed class or of type boolean.
Expand Down Expand Up @@ -667,8 +663,6 @@ Reports when the package declaration is missing.

### MissingWhenCase

**Deprecated**: The rule is deprecated as compiler performs this check by default.

Turn on this rule to flag `when` expressions that do not check that all cases are covered when the subject is an enum
or sealed class and the `when` expression is used as a statement.

Expand Down Expand Up @@ -801,8 +795,6 @@ fun bar(a: Any?): String {

### RedundantElseInWhen

**Deprecated**: The rule is deprecated as compiler performs this check by default.

Turn on this rule to flag `when` expressions that contain a redundant `else` case. This occurs when it can be
verified that all cases are already covered when checking cases on an enum or sealed class.

Expand Down

0 comments on commit 31702d6

Please sign in to comment.