From 4ba4bd1f56815d75c590fb96bf688e4bf8653ed8 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 26 Jul 2023 11:23:05 +0200 Subject: [PATCH] Enable more detekt rules and remove unused extension. --- .../core/extensions/BasicExtensions.kt | 4 -- tools/detekt/detekt.yml | 48 +++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/libraries/core/src/main/kotlin/io/element/android/libraries/core/extensions/BasicExtensions.kt b/libraries/core/src/main/kotlin/io/element/android/libraries/core/extensions/BasicExtensions.kt index db07432df0..343f5ce351 100644 --- a/libraries/core/src/main/kotlin/io/element/android/libraries/core/extensions/BasicExtensions.kt +++ b/libraries/core/src/main/kotlin/io/element/android/libraries/core/extensions/BasicExtensions.kt @@ -72,7 +72,3 @@ fun String.ellipsize(length: Int): String { return "${this.take(length)}…" } - -inline fun Any?.takeAs(): R? { - return takeIf { it is R } as R? -} diff --git a/tools/detekt/detekt.yml b/tools/detekt/detekt.yml index e65f3a3864..c9e8aa395b 100644 --- a/tools/detekt/detekt.yml +++ b/tools/detekt/detekt.yml @@ -8,6 +8,14 @@ style: includeElvis: true DataClassShouldBeImmutable: active: true + EqualsNullCall: + active: true + EqualsOnSignatureLine: + active: true + ExplicitCollectionElementAccessMethod: + active: true + ExplicitItLambdaParameter: + active: true MaxLineLength: # Default is 120 maxLineLength: 160 @@ -65,6 +73,34 @@ empty-blocks: potential-bugs: ImplicitDefaultLocale: active: true + CastNullableToNonNullableType: + active: true + CastToNullableType: + active: true + Deprecation: + active: true + DontDowncastCollectionTypes: + active: true + ElseCaseInsteadOfExhaustiveWhen: + active: true + ExitOutsideMain: + active: true + ImplicitUnitReturnType: + active: true + allowExplicitReturnType: false + MissingPackageDeclaration: + active: true + excludes: ['**/*.kts'] + NullCheckOnMutableProperty: + active: true + NullableToStringCall: + active: true + PropertyUsedBeforeDeclaration: + active: true + UnconditionalJumpStatementInLoop: + active: true + UnnecessaryNotNullCheck: + active: true exceptions: TooGenericExceptionCaught: @@ -77,6 +113,8 @@ exceptions: active: true InstanceOfCheckForException: active: true + ObjectExtendsThrowable: + active: true complexity: TooManyFunctions: @@ -102,10 +140,20 @@ naming: FunctionNaming: active: true ignoreAnnotated: ['Composable'] + LambdaParameterNaming: + active: true + NonBooleanPropertyPrefixedWithIs: + active: true + VariableMaxLength: + active: true performance: SpreadOperator: active: false + CouldBeSequence: + active: true + UnnecessaryPartOfBinaryExpression: + active: true # Note: all rules for `comments` are disabled by default, but I put them here to be aware of their existence comments: