diff --git a/settings.gradle.kts b/settings.gradle.kts index 914b2153e..e9fefbbd0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -58,9 +58,9 @@ dependencyResolutionManagement { } create("utilLibs") { - val detekt = version("detekt", "1.22.0") + val detekt = version("detekt", "1.23.0") val jcommander = version("jcommander", "1.81") - val ktlint = version("ktlint", "0.49.0") + val ktlint = version("ktlint", "0.49.1") library("detekt-api", "io.gitlab.arturbosch.detekt", "detekt-api").versionRef(detekt) library("detekt-cli", "io.gitlab.arturbosch.detekt", "detekt-cli").versionRef(detekt) diff --git a/sonar-kotlin-external-linters/src/main/resources/org/sonar/l10n/kotlin/rules/detekt/rules.json b/sonar-kotlin-external-linters/src/main/resources/org/sonar/l10n/kotlin/rules/detekt/rules.json index fb8a0b43b..c3b40def8 100644 --- a/sonar-kotlin-external-linters/src/main/resources/org/sonar/l10n/kotlin/rules/detekt/rules.json +++ b/sonar-kotlin-external-linters/src/main/resources/org/sonar/l10n/kotlin/rules/detekt/rules.json @@ -59,6 +59,30 @@ "severity": "MAJOR", "constantDebtMinutes": 5 }, + { + "key": "BracesOnIfStatements", + "name": "Braces On If Statements", + "description": "Braces do not comply with the specified policy", + "url": "https://detekt.github.io/detekt/style.html#bracesonifstatements", + "tags": [ + "style" + ], + "type": "CODE_SMELL", + "severity": "INFO", + "constantDebtMinutes": 5 + }, + { + "key": "BracesOnWhenStatements", + "name": "Braces On When Statements", + "description": "Braces do not comply with the specified policy", + "url": "https://detekt.github.io/detekt/style.html#bracesonwhenstatements", + "tags": [ + "style" + ], + "type": "CODE_SMELL", + "severity": "INFO", + "constantDebtMinutes": 5 + }, { "key": "CanBeNonNullable", "name": "Can Be Non Nullable", @@ -83,10 +107,22 @@ "severity": "INFO", "constantDebtMinutes": 5 }, + { + "key": "CastNullableToNonNullableType", + "name": "Cast Nullable To Non Nullable Type", + "description": "Nullable type to non-null type cast is found. Consider using two assertions, `null` assertions and type cast", + "url": "https://detekt.github.io/detekt/potential-bugs.html#castnullabletononnullabletype", + "tags": [ + "defect" + ], + "type": "CODE_SMELL", + "severity": "CRITICAL", + "constantDebtMinutes": 5 + }, { "key": "CastToNullableType", "name": "Cast To Nullable Type", - "description": "Disallow to cast to nullable types.", + "description": "Use safe cast instead of unsafe cast to nullable types.", "url": "https://detekt.github.io/detekt/potential-bugs.html#casttonullabletype", "tags": [ "defect" @@ -311,6 +347,18 @@ "severity": "MAJOR", "constantDebtMinutes": 5 }, + { + "key": "DoubleNegativeLambda", + "name": "Double Negative Lambda", + "description": "Double negative from a function name expressed in the negative (like `takeUnless`) with a lambda block that also contains negation. This is more readable when rewritten using a positive form of the function (like `takeIf`).", + "url": "https://detekt.github.io/detekt/style.html#doublenegativelambda", + "tags": [ + "style" + ], + "type": "CODE_SMELL", + "severity": "INFO", + "constantDebtMinutes": 5 + }, { "key": "DuplicateCaseInWhenExpression", "name": "Duplicate Case In When Expression", @@ -671,6 +719,18 @@ "severity": "CRITICAL", "constantDebtMinutes": 5 }, + { + "key": "ForbiddenAnnotation", + "name": "Forbidden Annotation", + "description": "Avoid using this annotation.", + "url": "https://detekt.github.io/detekt/style.html#forbiddenannotation", + "tags": [ + "style" + ], + "type": "CODE_SMELL", + "severity": "INFO", + "constantDebtMinutes": 5 + }, { "key": "ForbiddenClassName", "name": "Forbidden Class Name", @@ -1041,18 +1101,6 @@ "severity": "INFO", "constantDebtMinutes": 10 }, - { - "key": "MandatoryBracesIfStatements", - "name": "Mandatory Braces If Statements", - "description": "Multi-line if statement was found that does not have braces. These braces should be added to improve readability.", - "url": "https://detekt.github.io/detekt/style.html#mandatorybracesifstatements", - "tags": [ - "style" - ], - "type": "CODE_SMELL", - "severity": "INFO", - "constantDebtMinutes": 5 - }, { "key": "MandatoryBracesLoops", "name": "Mandatory Braces Loops", @@ -1344,7 +1392,7 @@ { "key": "NullableToStringCall", "name": "Nullable To String Call", - "description": "This call may return the string \u0026quot;null\u0026quot;", + "description": "`toString()` on nullable receiver may return the string \u0026quot;null\u0026quot;", "url": "https://detekt.github.io/detekt/potential-bugs.html#nullabletostringcall", "tags": [ "defect" @@ -1473,6 +1521,18 @@ "severity": "MAJOR", "constantDebtMinutes": 20 }, + { + "key": "PropertyUsedBeforeDeclaration", + "name": "Property Used Before Declaration", + "description": "Properties before declaration should not be used.", + "url": "https://detekt.github.io/detekt/potential-bugs.html#propertyusedbeforedeclaration", + "tags": [ + "defect" + ], + "type": "CODE_SMELL", + "severity": "CRITICAL", + "constantDebtMinutes": 5 + }, { "key": "ProtectedMemberInFinalClass", "name": "Protected Member In Final Class", @@ -1607,7 +1667,7 @@ { "key": "SerialVersionUIDInSerializableClass", "name": "Serial Version UIDIn Serializable Class", - "description": "A class which implements the Serializable interface does not define a correct serialVersionUID field. The serialVersionUID field should be a constant long value inside a companion object.", + "description": "A class which implements the Serializable interface does not define a correct serialVersionUID field. The serialVersionUID field should be a private constant long value inside a companion object.", "url": "https://detekt.github.io/detekt/style.html#serialversionuidinserializableclass", "tags": [ "warning" @@ -1663,6 +1723,29 @@ "severity": "MAJOR", "constantDebtMinutes": 5 }, + { + "key": "StringShouldBeRawString", + "name": "String Should Be Raw String", + "description": "The string can be converted to raw string.", + "url": "https://detekt.github.io/detekt/style.html#stringshouldberawstring", + "tags": [ + "style" + ], + "type": "CODE_SMELL", + "severity": "INFO", + "constantDebtMinutes": 5 + }, + { + "key": "SuspendFunSwallowedCancellation", + "name": "Suspend Fun Swallowed Cancellation", + "description": "`runCatching` does not propagate `CancellationException`, don\u0027t use it with `suspend` lambda blocks.", + "tags": [ + "minor" + ], + "type": "CODE_SMELL", + "severity": "MINOR", + "constantDebtMinutes": 10 + }, { "key": "SuspendFunWithCoroutineScopeReceiver", "name": "Suspend Fun With Coroutine Scope Receiver", @@ -1937,6 +2020,17 @@ "severity": "INFO", "constantDebtMinutes": 5 }, + { + "key": "UnnecessaryBracesAroundTrailingLambda", + "name": "Unnecessary Braces Around Trailing Lambda", + "description": "Braces around trailing lambda is unnecessary.", + "tags": [ + "style" + ], + "type": "CODE_SMELL", + "severity": "INFO", + "constantDebtMinutes": 5 + }, { "key": "UnnecessaryFilter", "name": "Unnecessary Filter", @@ -2129,6 +2223,18 @@ "severity": "INFO", "constantDebtMinutes": 5 }, + { + "key": "UnusedParameter", + "name": "Unused Parameter", + "description": "Function parameter is unused and should be removed.", + "url": "https://detekt.github.io/detekt/style.html#unusedparameter", + "tags": [ + "maintainability" + ], + "type": "CODE_SMELL", + "severity": "MAJOR", + "constantDebtMinutes": 5 + }, { "key": "UnusedPrivateClass", "name": "Unused Private Class", @@ -2144,7 +2250,7 @@ { "key": "UnusedPrivateMember", "name": "Unused Private Member", - "description": "Private member is unused and should be removed.", + "description": "Private function is unused and should be removed.", "url": "https://detekt.github.io/detekt/style.html#unusedprivatemember", "tags": [ "maintainability" @@ -2153,6 +2259,18 @@ "severity": "MAJOR", "constantDebtMinutes": 5 }, + { + "key": "UnusedPrivateProperty", + "name": "Unused Private Property", + "description": "Property is unused and should be removed.", + "url": "https://detekt.github.io/detekt/style.html#unusedprivateproperty", + "tags": [ + "maintainability" + ], + "type": "CODE_SMELL", + "severity": "MAJOR", + "constantDebtMinutes": 5 + }, { "key": "UnusedUnaryOperator", "name": "Unused Unary Operator", @@ -2273,10 +2391,22 @@ "severity": "INFO", "constantDebtMinutes": 5 }, + { + "key": "UseLet", + "name": "Use Let", + "description": "Use `?.let {}` instead of if/else with a null block when checking for nullable values", + "url": "https://detekt.github.io/detekt/style.html#uselet", + "tags": [ + "style" + ], + "type": "CODE_SMELL", + "severity": "INFO", + "constantDebtMinutes": 5 + }, { "key": "UseOrEmpty", "name": "Use Or Empty", - "description": "Use `orEmpty()` call instead of `?: emptyList()`", + "description": "Use `orEmpty()` call instead of `?:` with empty collection factory methods", "url": "https://detekt.github.io/detekt/style.html#useorempty", "tags": [ "style" diff --git a/sonar-kotlin-external-linters/src/main/resources/org/sonar/l10n/kotlin/rules/ktlint/rules.json b/sonar-kotlin-external-linters/src/main/resources/org/sonar/l10n/kotlin/rules/ktlint/rules.json index c1d699580..b89a76bc4 100644 --- a/sonar-kotlin-external-linters/src/main/resources/org/sonar/l10n/kotlin/rules/ktlint/rules.json +++ b/sonar-kotlin-external-linters/src/main/resources/org/sonar/l10n/kotlin/rules/ktlint/rules.json @@ -503,6 +503,18 @@ "severity": "MAJOR", "constantDebtMinutes": 0 }, + { + "key": "standard:no-single-line-block-comment", + "name": "No Single Line Block Comment", + "url": "https://ktlint.github.io/#rules", + "tags": [ + "ktlint", + "style" + ], + "type": "CODE_SMELL", + "severity": "MAJOR", + "constantDebtMinutes": 0 + }, { "key": "standard:no-trailing-spaces", "name": "No Trailing Spaces", @@ -1415,6 +1427,18 @@ "severity": "MAJOR", "constantDebtMinutes": 0 }, + { + "key": "standard:no-single-line-block-comment", + "name": "No Single Line Block Comment", + "url": "https://ktlint.github.io/#rules", + "tags": [ + "ktlint", + "style" + ], + "type": "CODE_SMELL", + "severity": "MAJOR", + "constantDebtMinutes": 0 + }, { "key": "standard:no-trailing-spaces", "name": "No Trailing Spaces", diff --git a/sonar-kotlin-external-linters/src/test/java/org/sonarsource/kotlin/externalreport/detekt/DetektRulesDefinitionTest.kt b/sonar-kotlin-external-linters/src/test/java/org/sonarsource/kotlin/externalreport/detekt/DetektRulesDefinitionTest.kt index a1efe746b..7ffbafc4e 100644 --- a/sonar-kotlin-external-linters/src/test/java/org/sonarsource/kotlin/externalreport/detekt/DetektRulesDefinitionTest.kt +++ b/sonar-kotlin-external-linters/src/test/java/org/sonarsource/kotlin/externalreport/detekt/DetektRulesDefinitionTest.kt @@ -36,7 +36,7 @@ internal class DetektRulesDefinitionTest { assertThat(repository!!.name()).isEqualTo("detekt") assertThat(repository.language()).isEqualTo("kotlin") assertThat(repository.isExternal).isTrue - assertThat(repository.rules().size).isEqualTo(204) + assertThat(repository.rules().size).isEqualTo(215) val classNaming = repository.rule("ClassNaming") assertThat(classNaming).isNotNull diff --git a/sonar-kotlin-external-linters/src/test/java/org/sonarsource/kotlin/externalreport/ktlint/KtlintRulesDefinitionTest.kt b/sonar-kotlin-external-linters/src/test/java/org/sonarsource/kotlin/externalreport/ktlint/KtlintRulesDefinitionTest.kt index da3f38901..ad9dbeea5 100644 --- a/sonar-kotlin-external-linters/src/test/java/org/sonarsource/kotlin/externalreport/ktlint/KtlintRulesDefinitionTest.kt +++ b/sonar-kotlin-external-linters/src/test/java/org/sonarsource/kotlin/externalreport/ktlint/KtlintRulesDefinitionTest.kt @@ -36,7 +36,7 @@ class KtlintRulesDefinitionTest { assertThat(repository.name()).isEqualTo("ktlint") assertThat(repository.language()).isEqualTo("kotlin") assertThat(repository.isExternal).isTrue - assertThat(repository.rules().size).isEqualTo(77) + assertThat(repository.rules().size).isEqualTo(78) val modifierOrder = repository.rule("standard:modifier-order")!! assertThat(modifierOrder).isNotNull assertThat(modifierOrder.name()).isEqualTo("Modifier Order")