diff --git a/bip39-lib/src/jvmMain/kotlin/cash/z/ecc/android/bip39/Mnemonics.kt b/bip39-lib/src/jvmMain/kotlin/cash/z/ecc/android/bip39/Mnemonics.kt index 5ed93e1..32aa9ab 100644 --- a/bip39-lib/src/jvmMain/kotlin/cash/z/ecc/android/bip39/Mnemonics.kt +++ b/bip39-lib/src/jvmMain/kotlin/cash/z/ecc/android/bip39/Mnemonics.kt @@ -141,9 +141,11 @@ object Mnemonics { * Get the original entropy that was used to create this MnemonicCode. This call will fail * if the words have an invalid length or checksum. * + * @InvalidWordException If any word isn't in the word list * @throws WordCountException when the word count is zero or not a multiple of 3. * @throws ChecksumException if the checksum does not match the expected value. */ + @Suppress("ThrowsCount", "NestedBlockDepth") fun toEntropy(): ByteArray { wordCount.let { if (it <= 0 || it % 3 > 0) throw WordCountException(wordCount) } diff --git a/bip39-lib/src/jvmMain/kotlin/cash/z/ecc/android/bip39/WordList.kt b/bip39-lib/src/jvmMain/kotlin/cash/z/ecc/android/bip39/WordList.kt index 7b5a5c2..5d483f4 100644 --- a/bip39-lib/src/jvmMain/kotlin/cash/z/ecc/android/bip39/WordList.kt +++ b/bip39-lib/src/jvmMain/kotlin/cash/z/ecc/android/bip39/WordList.kt @@ -50,6 +50,7 @@ class WordList internal constructor(val languageCode: String) { * * @return a list of words matching the given language code. */ + @Suppress("LongMethod") private fun fetchWords(languageCode: String): List { validate(languageCode) return """ diff --git a/buildscript-gradle.lockfile b/buildscript-gradle.lockfile index 1f6a4ac..271d253 100644 --- a/buildscript-gradle.lockfile +++ b/buildscript-gradle.lockfile @@ -15,9 +15,8 @@ com.thoughtworks.xstream:xstream:1.4.17=classpath de.undercouch:gradle-download-task:4.1.1=classpath io.github.detekt.sarif4k:sarif4k:0.0.1=classpath io.github.x-stream:mxparser:1.2.1=classpath -io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.20.0=classpath -io.gitlab.arturbosch.detekt:detekt-utils:1.20.0=classpath -io.gitlab.arturbosch.detekt:io.gitlab.arturbosch.detekt.gradle.plugin:1.20.0=classpath +io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.21.0=classpath +io.gitlab.arturbosch.detekt:io.gitlab.arturbosch.detekt.gradle.plugin:1.21.0=classpath net.java.dev.jna:jna:5.6.0=classpath org.checkerframework:checker-qual:2.11.1=classpath org.jetbrains.intellij.deps:trove4j:1.0.20200330=classpath diff --git a/gradle.lockfile b/gradle.lockfile index 3819c8b..acd8d88 100644 --- a/gradle.lockfile +++ b/gradle.lockfile @@ -17,30 +17,32 @@ com.pinterest.ktlint:ktlint-ruleset-standard:0.46.1=ktlint com.pinterest.ktlint:ktlint-ruleset-test:0.46.1=ktlint com.pinterest:ktlint:0.46.1=ktlint info.picocli:picocli:4.6.3=ktlint +io.github.davidburstrom.contester:contester-breakpoint:0.2.0=detekt io.github.detekt.sarif4k:sarif4k:0.0.1=detekt,ktlint io.github.microutils:kotlin-logging-jvm:2.1.21=ktlint -io.gitlab.arturbosch.detekt:detekt-api:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-cli:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-core:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-metrics:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-parser:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-psi-utils:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-report-html:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-report-sarif:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-report-txt:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-report-xml:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-rules-complexity:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-rules-coroutines:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-rules-documentation:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-rules-empty:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-rules-errorprone:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-rules-exceptions:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-rules-naming:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-rules-performance:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-rules-style:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-rules:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-tooling:1.20.0=detekt -io.gitlab.arturbosch.detekt:detekt-utils:1.20.0=detekt +io.gitlab.arturbosch.detekt:detekt-api:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-cli:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-core:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-metrics:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-parser:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-psi-utils:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-report-html:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-report-md:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-report-sarif:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-report-txt:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-report-xml:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-rules-complexity:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-rules-coroutines:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-rules-documentation:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-rules-empty:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-rules-errorprone:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-rules-exceptions:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-rules-naming:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-rules-performance:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-rules-style:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-rules:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-tooling:1.21.0=detekt +io.gitlab.arturbosch.detekt:detekt-utils:1.21.0=detekt net.java.dev.jna:jna:5.6.0=detekt,ktlint org.ec4j.core:ec4j-core:0.3.0=ktlint org.freemarker:freemarker:2.3.30=IntellijKoverConfig @@ -52,19 +54,19 @@ org.jetbrains.intellij.deps:coverage-report:1.0.15=IntellijKoverConfig org.jetbrains.intellij.deps:intellij-coverage-agent:1.0.668=IntellijKoverConfig org.jetbrains.intellij.deps:intellij-coverage-reporter:1.0.668=IntellijKoverConfig org.jetbrains.intellij.deps:trove4j:1.0.20200330=detekt,ktlint -org.jetbrains.kotlin:kotlin-compiler-embeddable:1.6.20=detekt +org.jetbrains.kotlin:kotlin-compiler-embeddable:1.6.21=detekt org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.0=ktlint -org.jetbrains.kotlin:kotlin-daemon-embeddable:1.6.20=detekt +org.jetbrains.kotlin:kotlin-daemon-embeddable:1.6.21=detekt org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.0=ktlint -org.jetbrains.kotlin:kotlin-reflect:1.6.20=detekt +org.jetbrains.kotlin:kotlin-reflect:1.6.21=detekt org.jetbrains.kotlin:kotlin-reflect:1.7.0=ktlint -org.jetbrains.kotlin:kotlin-script-runtime:1.6.20=detekt +org.jetbrains.kotlin:kotlin-script-runtime:1.6.21=detekt org.jetbrains.kotlin:kotlin-script-runtime:1.7.0=ktlint -org.jetbrains.kotlin:kotlin-stdlib-common:1.6.20=detekt +org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21=detekt org.jetbrains.kotlin:kotlin-stdlib-common:1.7.0=ktlint org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.0=ktlint org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.0=ktlint -org.jetbrains.kotlin:kotlin-stdlib:1.6.20=detekt +org.jetbrains.kotlin:kotlin-stdlib:1.6.21=detekt org.jetbrains.kotlin:kotlin-stdlib:1.7.0=ktlint org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.5=detekt org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.1.0=detekt,ktlint diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 95ef7be..c342f56 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ moshi-core = { module = "com.squareup.moshi:moshi", version.ref = "moshi" } moshi-kotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi" } [plugins] -detekt = "io.gitlab.arturbosch.detekt:1.20.0" +detekt = "io.gitlab.arturbosch.detekt:1.21.0" dokka = "org.jetbrains.dokka:1.7.10" kover = "org.jetbrains.kotlinx.kover:0.5.1" versions = "com.github.ben-manes.versions:0.42.0" \ No newline at end of file diff --git a/tools/detekt.yml b/tools/detekt.yml index dd92c93..5734002 100644 --- a/tools/detekt.yml +++ b/tools/detekt.yml @@ -46,6 +46,7 @@ output-reports: # - 'TxtOutputReport' # - 'XmlOutputReport' # - 'HtmlOutputReport' + # - 'MdOutputReport' comments: active: true @@ -62,6 +63,9 @@ comments: EndOfSentenceFormat: active: false endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)' + KDocReferencesNonPublicProperty: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] OutdatedDocumentation: active: false matchTypeParameters: true @@ -133,6 +137,15 @@ complexity: NestedBlockDepth: active: true threshold: 4 + NestedScopeFunctions: + active: false + threshold: 1 + functions: + - 'kotlin.apply' + - 'kotlin.run' + - 'kotlin.with' + - 'kotlin.let' + - 'kotlin.also' ReplaceSafeCallChainWithRun: active: false StringLiteralDuplication: @@ -159,19 +172,19 @@ coroutines: GlobalCoroutineUsage: active: false InjectDispatcher: - active: false + active: true dispatcherNames: - 'IO' - 'Default' - 'Unconfined' RedundantSuspendModifier: - active: false + active: true SleepInsteadOfDelay: - active: false + active: true SuspendFunWithCoroutineScopeReceiver: active: false SuspendFunWithFlowReturnType: - active: false + active: true empty-blocks: active: true @@ -218,7 +231,7 @@ exceptions: - 'hashCode' - 'toString' InstanceOfCheckForException: - active: false + active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] NotImplementedDeclaration: active: false @@ -283,58 +296,46 @@ naming: active: true BooleanPropertyNaming: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] allowedPattern: '^(is|has|are)' ignoreOverridden: true ClassNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] classPattern: '[A-Z][a-zA-Z0-9]*' ConstructorParameterNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] parameterPattern: '[a-z][A-Za-z0-9]*' privateParameterPattern: '[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' ignoreOverridden: true EnumNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] enumEntryPattern: '[A-Z][_a-zA-Z0-9]*' ForbiddenClassName: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] forbiddenName: [] FunctionMaxLength: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] maximumFunctionNameLength: 30 FunctionMinLength: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] minimumFunctionNameLength: 3 FunctionNaming: active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - functionPattern: '([a-z][a-zA-Z0-9]*)|(`.*`)' + functionPattern: '[a-z][a-zA-Z0-9]*' excludeClassPattern: '$^' ignoreOverridden: true - ignoreAnnotated: - - 'Composable' FunctionParameterNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] parameterPattern: '[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' ignoreOverridden: true InvalidPackageDeclaration: - active: false - excludes: ['**/*.kts'] + active: true rootPackage: '' requireRootInDeclaration: false LambdaParameterNaming: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] parameterPattern: '[a-z][A-Za-z0-9]*|_' MatchingDeclarationName: active: true @@ -343,37 +344,30 @@ naming: active: true ignoreOverridden: true NoNameShadowing: - active: false + active: true NonBooleanPropertyPrefixedWithIs: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] ObjectPropertyNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] constantPattern: '[A-Za-z][_A-Za-z0-9]*' propertyPattern: '[A-Za-z][_A-Za-z0-9]*' privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*' PackageNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*' TopLevelPropertyNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] constantPattern: '[A-Z][_A-Z0-9]*' propertyPattern: '[A-Za-z][_A-Za-z0-9]*' privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*' VariableMaxLength: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] maximumVariableNameLength: 64 VariableMinLength: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] minimumVariableNameLength: 1 VariableNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] variablePattern: '[a-z][A-Za-z0-9]*' privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' @@ -383,6 +377,9 @@ performance: active: true ArrayPrimitive: active: true + CouldBeSequence: + active: false + threshold: 3 ForEachOnRange: active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] @@ -395,7 +392,7 @@ performance: potential-bugs: active: true AvoidReferentialEquality: - active: false + active: true forbiddenTypePatterns: - 'kotlin.String' CastToNullableType: @@ -405,7 +402,7 @@ potential-bugs: DontDowncastCollectionTypes: active: false DoubleMutabilityForCollection: - active: false + active: true mutableTypes: - 'kotlin.collections.MutableList' - 'kotlin.collections.MutableMap' @@ -428,9 +425,9 @@ potential-bugs: ExplicitGarbageCollectionCall: active: true HasPlatformType: - active: false + active: true IgnoredReturnValue: - active: false + active: true restrictToAnnotatedMethods: true returnValueAnnotations: - '*.CheckResult' @@ -454,7 +451,7 @@ potential-bugs: excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] ignoreOnClassesPattern: '' MapGetWithNotNullAssertionOperator: - active: false + active: true MissingPackageDeclaration: active: false excludes: ['**/*.kts'] @@ -474,7 +471,7 @@ potential-bugs: UnnecessarySafeCall: active: true UnreachableCatchBlock: - active: false + active: true UnreachableCode: active: true UnsafeCallOnNullableType: @@ -483,9 +480,9 @@ potential-bugs: UnsafeCast: active: true UnusedUnaryOperator: - active: false + active: true UselessPostfixExpression: - active: false + active: true WrongEqualsTypeParameter: active: true @@ -493,6 +490,9 @@ style: active: true CanBeNonNullable: active: false + CascadingCallWrapping: + active: false + includeElvis: true ClassOrdering: active: false CollapsibleIfStatements: @@ -503,7 +503,7 @@ style: DataClassShouldBeImmutable: active: false DestructuringDeclarationWithTooManyEntries: - active: false + active: true maxDestructuringEntries: 3 EqualsNullCall: active: true @@ -512,7 +512,7 @@ style: ExplicitCollectionElementAccessMethod: active: false ExplicitItLambdaParameter: - active: false + active: true ExpressionBodySyntax: active: false includeLineWrapping: false @@ -539,8 +539,11 @@ style: ignorePackages: - '*.internal' - '*.internal.*' - ForbiddenVoid: + ForbiddenSuppress: active: false + rules: [] + ForbiddenVoid: + active: true ignoreOverridden: false ignoreUsageInGenerics: false FunctionOnlyReturningConstant: @@ -559,7 +562,7 @@ style: maxJumpCount: 1 MagicNumber: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**', '**/*.kts'] ignoreNumbers: - '-1' - '0' @@ -579,6 +582,9 @@ style: active: false MandatoryBracesLoops: active: false + MaxChainedCallsOnSameLine: + active: false + maxChainedCalls: 5 MaxLineLength: active: true maxLineLength: 120 @@ -597,8 +603,10 @@ style: active: false NoTabs: active: false - ObjectLiteralToLambda: + NullableBooleanCheck: active: false + ObjectLiteralToLambda: + active: true OptionalAbstractKeyword: active: true OptionalUnit: @@ -612,7 +620,7 @@ style: RedundantExplicitType: active: false RedundantHigherOrderMapUsage: - active: false + active: true RedundantVisibilityModifierRule: active: false ReturnCount: @@ -644,8 +652,10 @@ style: active: false UnnecessaryApply: active: true - UnnecessaryFilter: + UnnecessaryBackticks: active: false + UnnecessaryFilter: + active: true UnnecessaryInheritance: active: true UnnecessaryInnerClass: @@ -664,13 +674,13 @@ style: active: true allowedNames: '(_|ignored|expected|serialVersionUID)' UseAnyOrNoneInsteadOfFind: - active: false + active: true UseArrayLiteralsInAnnotations: - active: false + active: true UseCheckNotNull: - active: false + active: true UseCheckOrError: - active: false + active: true UseDataClass: active: false allowVars: false @@ -681,19 +691,20 @@ style: UseIfInsteadOfWhen: active: false UseIsNullOrEmpty: - active: false + active: true UseOrEmpty: - active: false + active: true UseRequire: - active: false + active: true UseRequireNotNull: - active: false + active: true UselessCallOnNotNull: active: true UtilityClassWithPublicConstructor: active: true VarCouldBeVal: active: true + ignoreLateinitVar: false WildcardImport: active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']