[#795] Detekt 1.22.0

* [#795] Detekt 1.22.0

* Fix rules/its findings
This commit is contained in:
Honza Rychnovsky 2022-12-19 08:08:25 +01:00 committed by GitHub
parent a77f3a629c
commit c3e41a68c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 35 deletions

View File

@ -9,6 +9,7 @@ import java.util.Locale
fun ZcashNetwork.Companion.fromResources(context: Context): ZcashNetwork {
val networkNameFromResources = context.getString(R.string.network_name).lowercase(Locale.ROOT)
@Suppress("UseRequire")
return if (networkNameFromResources == Testnet.networkName) {
Testnet
} else if (networkNameFromResources.lowercase(Locale.ROOT) == Mainnet.networkName) {

View File

@ -75,7 +75,7 @@ ANDROID_COMPILE_SDK_VERSION=33
ANDROID_NDK_VERSION=22.1.7171670
ANDROID_GRADLE_PLUGIN_VERSION=7.3.0
DETEKT_VERSION=1.21.0
DETEKT_VERSION=1.22.0
DOKKA_VERSION=1.7.20
EMULATOR_WTF_GRADLE_PLUGIN_VERSION=0.0.12
FLANK_VERSION=22.10.0

View File

@ -32,10 +32,10 @@ internal fun <T> SQLiteDatabase.queryAndMap(
cursorParser: CursorParser<T>
) = flow<T> {
// TODO [#703]: Support blobs for argument binding
// https://github.com/zcash/zcash-android-wallet-sdk/issues/703
// TODO [#703]: https://github.com/zcash/zcash-android-wallet-sdk/issues/703
val mappedSelectionArgs = selectionArgs?.onEach {
if (it is ByteArray) {
throw IllegalArgumentException("ByteArray is not supported")
require(it !is ByteArray) {
"ByteArray is not supported"
}
}?.map { it.toString() }?.toTypedArray()

View File

@ -24,16 +24,16 @@ data class BlockHeight internal constructor(val value: Long) : Comparable<BlockH
operator fun plus(other: BlockHeight) = BlockHeight(value + other.value)
operator fun plus(other: Int): BlockHeight {
if (other < 0) {
throw IllegalArgumentException("Cannot add negative value $other to BlockHeight")
require(other >= 0) {
"Cannot add negative value $other to BlockHeight"
}
return BlockHeight(value + other.toLong())
}
operator fun plus(other: Long): BlockHeight {
if (other < 0) {
throw IllegalArgumentException("Cannot add negative value $other to BlockHeight")
require(other >= 0) {
"Cannot add negative value $other to BlockHeight"
}
return BlockHeight(value + other)

View File

@ -10,6 +10,7 @@ build:
config:
validation: true
warningsAsErrors: false
checkExhaustiveness: false
# when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]'
excludes: ''
@ -78,15 +79,21 @@ comments:
searchInInnerClass: true
searchInInnerObject: true
searchInInnerInterface: true
searchInProtectedClass: false
UndocumentedPublicFunction:
active: false
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
searchProtectedFunction: false
UndocumentedPublicProperty:
active: false
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
searchProtectedProperty: false
complexity:
active: true
CognitiveComplexMethod:
active: false
threshold: 15
ComplexCondition:
active: true
threshold: 4
@ -95,7 +102,8 @@ complexity:
threshold: 10
includeStaticDeclarations: false
includePrivateDeclarations: false
ComplexMethod:
ignoreOverloaded: false
CyclomaticComplexMethod:
active: true
threshold: 15
ignoreSingleWhenExpression: false
@ -386,6 +394,8 @@ performance:
SpreadOperator:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
UnnecessaryPartOfBinaryExpression:
active: false
UnnecessaryTemporaryInstantiation:
active: true
@ -412,8 +422,6 @@ potential-bugs:
- 'java.util.HashSet'
- 'java.util.LinkedHashMap'
- 'java.util.HashMap'
DuplicateCaseInWhenExpression:
active: true
ElseCaseInsteadOfExhaustiveWhen:
active: false
EqualsAlwaysReturnsTrueOrFalse:
@ -428,12 +436,16 @@ potential-bugs:
active: true
IgnoredReturnValue:
active: true
restrictToAnnotatedMethods: true
restrictToConfig: true
returnValueAnnotations:
- '*.CheckResult'
- '*.CheckReturnValue'
ignoreReturnValueAnnotations:
- '*.CanIgnoreReturnValue'
returnValueTypes:
- 'kotlin.sequences.Sequence'
- 'kotlinx.coroutines.flow.*Flow'
- 'java.util.stream.*Stream'
ignoreFunctionCall: []
ImplicitDefaultLocale:
active: true
@ -455,17 +467,14 @@ potential-bugs:
MissingPackageDeclaration:
active: false
excludes: ['**/*.kts']
MissingWhenCase:
active: true
allowElseExpression: true
NullCheckOnMutableProperty:
active: false
NullableToStringCall:
active: false
RedundantElseInWhen:
active: true
UnconditionalJumpStatementInLoop:
active: false
UnnecessaryNotNullCheck:
active: false
UnnecessaryNotNullOperator:
active: true
UnnecessarySafeCall:
@ -488,6 +497,8 @@ potential-bugs:
style:
active: true
AlsoCouldBeApply:
active: false
CanBeNonNullable:
active: false
CascadingCallWrapping:
@ -499,7 +510,8 @@ style:
active: false
DataClassContainsFunctions:
active: false
conversionFunctionPrefix: 'to'
conversionFunctionPrefix:
- 'to'
DataClassShouldBeImmutable:
active: false
DestructuringDeclarationWithTooManyEntries:
@ -531,14 +543,10 @@ style:
ForbiddenMethodCall:
active: false
methods:
- 'kotlin.io.print'
- 'kotlin.io.println'
ForbiddenPublicDataClass:
active: true
excludes: ['**']
ignorePackages:
- '*.internal'
- '*.internal.*'
- reason: 'print does not allow you to configure the output stream. Use a logger instead.'
value: 'kotlin.io.print'
- reason: 'println does not allow you to configure the output stream. Use a logger instead.'
value: 'kotlin.io.println'
ForbiddenSuppress:
active: false
rules: []
@ -550,13 +558,7 @@ style:
active: true
ignoreOverridableFunction: true
ignoreActualFunction: true
excludedFunctions: ''
LibraryCodeMustSpecifyReturnType:
active: true
excludes: ['**']
LibraryEntitiesShouldNotBePublic:
active: true
excludes: ['**']
excludedFunctions: []
LoopWithTooManyJumpStatements:
active: true
maxJumpCount: 1
@ -591,12 +593,16 @@ style:
excludePackageStatements: true
excludeImportStatements: true
excludeCommentStatements: false
excludeRawStrings: true
MayBeConst:
active: true
ModifierOrder:
active: true
MultilineLambdaItParameter:
active: false
MultilineRawStringIndentation:
active: false
indentSize: 4
NestedClassesVisibility:
active: true
NewLineAtEndOfFile:
@ -626,7 +632,8 @@ style:
ReturnCount:
active: true
max: 2
excludedFunctions: 'equals'
excludedFunctions:
- 'equals'
excludeLabeled: false
excludeReturnFromLambda: true
excludeGuardClauses: false
@ -642,6 +649,8 @@ style:
excludeGuardClauses: false
TrailingWhitespace:
active: false
TrimMultilineRawString:
active: false
UnderscoresInNumericLiterals:
active: false
acceptableLength: 4
@ -664,6 +673,7 @@ style:
active: false
UnnecessaryParentheses:
active: false
allowForUnclearPrecedence: false
UntilInsteadOfRangeTo:
active: false
UnusedImports:
@ -698,6 +708,8 @@ style:
active: true
UseRequireNotNull:
active: true
UseSumOfInsteadOfFlatMapSize:
active: false
UselessCallOnNotNull:
active: true
UtilityClassWithPublicConstructor:
@ -707,6 +719,5 @@ style:
ignoreLateinitVar: false
WildcardImport:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
excludeImports:
- 'java.util.*'