From 6f96d612c67fbb6650be7f36767c62aac7af69cc Mon Sep 17 00:00:00 2001 From: zhongchao Date: Mon, 25 Sep 2023 19:02:30 +0800 Subject: [PATCH] [3.4.0-map-sdk] rules --- codequality/detekt.yml | 44 ++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/codequality/detekt.yml b/codequality/detekt.yml index 3a76561338..056a7d0ef4 100644 --- a/codequality/detekt.yml +++ b/codequality/detekt.yml @@ -417,15 +417,15 @@ potential-bugs: CastNullableToNonNullableType: #可空强转null active: false ignorePlatformTypes: true - CastToNullableType: + CastToNullableType: #将不安全的强制转换报告为可为null的类型。作为字符串?未填充,可能被误用为安全类型转换(如?字符串) active: false CharArrayToStringCall: active: false Deprecation: active: false - DontDowncastCollectionTypes: + DontDowncastCollectionTypes: #检查集合向下类型转换,建议方法转换({list as MutableList} convert : {list.toMutableList()}) active: false - DoubleMutabilityForCollection: + DoubleMutabilityForCollection: #MutableState可变var,不可变建议val active: true mutableTypes: - 'kotlin.collections.MutableList' @@ -436,19 +436,21 @@ potential-bugs: - 'java.util.HashSet' - 'java.util.LinkedHashMap' - 'java.util.HashMap' - ElseCaseInsteadOfExhaustiveWhen: + ElseCaseInsteadOfExhaustiveWhen: #当表达式包含else大小写时,即使它们有一组详尽的大小写,该规则也会报告 active: false ignoredSubjectTypes: [] - EqualsAlwaysReturnsTrueOrFalse: + EqualsAlwaysReturnsTrueOrFalse: #报告始终返回true或false的equals()方法。 active: true - EqualsWithHashCodeExist: + EqualsWithHashCodeExist: #当一个类重写equals()方法时,它也应该重写hashCode()方法 active: true - ExitOutsideMain: + ExitOutsideMain: #报告主函数之外使用System.exit()、Runtime.exit()、Runtime.holt()和Kotlin的exitProcess()时的使用情况 active: false - ExplicitGarbageCollectionCall: + ExplicitGarbageCollectionCall: #报告所有显式触发垃圾回收器的调用。代码应该独立于垃圾收集器工作,并且不应该要求在某些时间点触发GC。 active: true - HasPlatformType: + HasPlatformType: #必须在公共API中显式声明平台类型,以防止出现意外错误 active: true + + #此规则对使用@CheckReturnValue或@CheckResult注释的函数返回值但未以任何方式使用该值的实例发出警告Kotlin编译器通常不会对这种情况发出警告,所以这就是该规则背后的基本原理。 IgnoredReturnValue: active: true restrictToConfig: true @@ -465,31 +467,31 @@ potential-bugs: - 'kotlinx.coroutines.flow.*Flow' - 'java.util.stream.*Stream' ignoreFunctionCall: [] - ImplicitDefaultLocale: - active: true - ImplicitUnitReturnType: + ImplicitDefaultLocale: #格式化字符串或执行大小写转换时,更喜欢显式传递[java.util.Locale],而不是使用隐式默认值 + active: false + ImplicitUnitReturnType: #使用表达式语句的函数具有隐式返回类型 active: false allowExplicitReturnType: true - InvalidRange: + InvalidRange: #报告为空的范围 active: true - IteratorHasNextCallsNextMethod: + IteratorHasNextCallsNextMethod: #验证Iterator接口的实现。Iterator实现的hasNext()方法不应该有任何副作用 active: true - IteratorNotThrowingNoSuchElementException: + IteratorNotThrowingNoSuchElementException: #报告在next()方法的实现中不抛出NoSuchElementException的Iterator接口的实现。当没有更多的元素要返回时,迭代器应该抛出NoSuchElementException active: true - LateinitUsage: + LateinitUsage: #报告Late-init修饰符的用法。 active: false excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] ignoreOnClassesPattern: '' - MapGetWithNotNullAssertionOperator: + MapGetWithNotNullAssertionOperator: #使用非null断言运算符报告对map访问方法map[]或map.get()的调用!!。这可能会导致NullPointerException active: true - MissingPackageDeclaration: + MissingPackageDeclaration: #当缺少包声明时报告 active: false excludes: ['**/*.kts'] - NullCheckOnMutableProperty: + NullCheckOnMutableProperty: #规则已弃用,因为编译器默认执行此检查,当主题是枚举或密封类时,以及当表达式用作语句时,启用此规则可标记未检查是否覆盖所有事例的表达式 active: false - NullableToStringCall: + NullableToStringCall: #报告对可变属性的null检查,因为这些属性的值可以在执行if语句后更改,从而使null检查无效 active: false - PropertyUsedBeforeDeclaration: + PropertyUsedBeforeDeclaration: # active: false UnconditionalJumpStatementInLoop: active: false