From a119d8339a67a3593a3157d331450ab720beae32 Mon Sep 17 00:00:00 2001 From: Ian Brandt Date: Sun, 8 Sep 2024 21:03:55 -0700 Subject: [PATCH] Integrated Detekt. --- .editorconfig | 3 + build-logic/build.gradle.kts | 1 + ...otlin.buildlogic.kotlin-project.gradle.kts | 2 + config/detekt/detekt.yml | 785 ++++++++++++++++++ effective-kotlin/detekt-baseline.xml | 27 + gradle/libs.versions.toml | 9 + kotlin-dl/detekt-baseline.xml | 8 + .../detekt-baseline.xml | 10 + kotlin-for-java-devs/detekt-baseline.xml | 281 +++++++ .../api/annotations/GeneratedBuilder.kt | 2 +- .../processor/detekt-baseline.xml | 8 + tdd-in-kotlin/detekt-baseline.xml | 12 + typed-errors-in-kotlin/detekt-baseline.xml | 12 + 13 files changed, 1159 insertions(+), 1 deletion(-) create mode 100644 config/detekt/detekt.yml create mode 100644 effective-kotlin/detekt-baseline.xml create mode 100644 kotlin-dl/detekt-baseline.xml create mode 100644 kotlin-for-java-devs-client/detekt-baseline.xml create mode 100644 kotlin-for-java-devs/detekt-baseline.xml create mode 100644 ksp-builder-generator/processor/detekt-baseline.xml create mode 100644 tdd-in-kotlin/detekt-baseline.xml create mode 100644 typed-errors-in-kotlin/detekt-baseline.xml diff --git a/.editorconfig b/.editorconfig index 720c5c6..99b5717 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,6 +7,9 @@ insert_final_newline = true indent_style = tab tab_width = 4 +[**/detekt-baseline.xml] +max_line_length = off + [{.idea/**/*.xml,*.iml}] indent_size = 2 max_line_length = off diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 08a4a4f..38b6c39 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -9,6 +9,7 @@ dependencies { implementation(platform("org.sdkotlin.platforms:plugins-platform")) implementation(libs.dependency.analysis.gradle.plugin.dependency) + implementation(libs.detekt.gradle.plugin.dependency) implementation(libs.jvm.dependency.conflict.resolution.gradle.plugin.dependency) implementation(libs.kotlin.gradle.plugin.dependency) implementation(libs.ksp.gradle.plugin.dependency) diff --git a/build-logic/src/main/kotlin/org.sdkotlin.buildlogic.kotlin-project.gradle.kts b/build-logic/src/main/kotlin/org.sdkotlin.buildlogic.kotlin-project.gradle.kts index 1221cec..9e159d5 100644 --- a/build-logic/src/main/kotlin/org.sdkotlin.buildlogic.kotlin-project.gradle.kts +++ b/build-logic/src/main/kotlin/org.sdkotlin.buildlogic.kotlin-project.gradle.kts @@ -7,6 +7,8 @@ plugins { // https://github.com/gradle/gradle/issues/15383 // alias(libs.plugins.dependency.analysis.gradle.plugin) id("com.autonomousapps.dependency-analysis") + // alias(libs.plugins.detekt.gradle.plugin) + id("io.gitlab.arturbosch.detekt") // alias(libs.plugins.jvm.dependency.conflict.detection.gradle.plugin) id("org.gradlex.jvm-dependency-conflict-detection") } diff --git a/config/detekt/detekt.yml b/config/detekt/detekt.yml new file mode 100644 index 0000000..bf3ea46 --- /dev/null +++ b/config/detekt/detekt.yml @@ -0,0 +1,785 @@ +build: + maxIssues: 0 + excludeCorrectable: false + weights: + # complexity: 2 + # LongParameterList: 1 + # style: 1 + # comments: 1 + +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: '' + +processors: + active: true + exclude: + - 'DetektProgressListener' + # - 'KtFileCountProcessor' + # - 'PackageCountProcessor' + # - 'ClassCountProcessor' + # - 'FunctionCountProcessor' + # - 'PropertyCountProcessor' + # - 'ProjectComplexityProcessor' + # - 'ProjectCognitiveComplexityProcessor' + # - 'ProjectLLOCProcessor' + # - 'ProjectCLOCProcessor' + # - 'ProjectLOCProcessor' + # - 'ProjectSLOCProcessor' + # - 'LicenseHeaderLoaderExtension' + +console-reports: + active: true + exclude: + - 'ProjectStatisticsReport' + - 'ComplexityReport' + - 'NotificationReport' + - 'FindingsReport' + - 'FileBasedFindingsReport' + # - 'LiteFindingsReport' + +output-reports: + active: true + exclude: + # - 'TxtOutputReport' + # - 'XmlOutputReport' + # - 'HtmlOutputReport' + # - 'MdOutputReport' + # - 'SarifOutputReport' + +comments: + active: true + AbsentOrWrongFileLicense: + active: false + licenseTemplateFile: 'license.template' + licenseTemplateIsRegex: false + CommentOverPrivateFunction: + active: false + CommentOverPrivateProperty: + active: false + DeprecatedBlockTag: + active: false + EndOfSentenceFormat: + active: false + endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)' + KDocReferencesNonPublicProperty: + active: false + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ] + OutdatedDocumentation: + active: false + matchTypeParameters: true + matchDeclarationsOrder: true + allowParamOnConstructorProperties: false + UndocumentedPublicClass: + active: false + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ] + searchInNestedClass: true + searchInInnerClass: true + searchInInnerObject: true + searchInInnerInterface: true + searchInProtectedClass: false + UndocumentedPublicFunction: + active: false + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ] + searchProtectedFunction: false + UndocumentedPublicProperty: + active: false + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ] + searchProtectedProperty: false + +complexity: + active: true + CognitiveComplexMethod: + active: false + threshold: 15 + ComplexCondition: + active: true + threshold: 4 + ComplexInterface: + active: false + threshold: 10 + includeStaticDeclarations: false + includePrivateDeclarations: false + ignoreOverloaded: false + CyclomaticComplexMethod: + active: true + threshold: 15 + ignoreSingleWhenExpression: false + ignoreSimpleWhenEntries: false + ignoreNestingFunctions: false + nestingFunctions: + - 'also' + - 'apply' + - 'forEach' + - 'isNotNull' + - 'ifNull' + - 'let' + - 'run' + - 'use' + - 'with' + LabeledExpression: + active: false + ignoredLabels: [ ] + LargeClass: + active: true + threshold: 600 + LongMethod: + active: true + threshold: 60 + LongParameterList: + active: true + functionThreshold: 6 + constructorThreshold: 7 + ignoreDefaultParameters: false + ignoreDataClasses: true + ignoreAnnotatedParameter: [ ] + MethodOverloading: + active: false + threshold: 6 + NamedArguments: + active: false + threshold: 3 + ignoreArgumentsMatchingNames: false + 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: + active: false + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ] + threshold: 3 + ignoreAnnotation: true + excludeStringsWithLessThan5Characters: true + ignoreStringsRegex: '$^' + TooManyFunctions: + active: true + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ] + thresholdInFiles: 11 + thresholdInClasses: 11 + thresholdInInterfaces: 11 + thresholdInObjects: 11 + thresholdInEnums: 11 + ignoreDeprecated: false + ignorePrivate: false + ignoreOverridden: false + ignoreAnnotatedFunctions: [ ] + +coroutines: + active: true + GlobalCoroutineUsage: + active: false + InjectDispatcher: + active: true + dispatcherNames: + - 'IO' + - 'Default' + - 'Unconfined' + RedundantSuspendModifier: + active: true + SleepInsteadOfDelay: + active: true + SuspendFunSwallowedCancellation: + active: false + SuspendFunWithCoroutineScopeReceiver: + active: false + SuspendFunWithFlowReturnType: + active: true + +empty-blocks: + active: true + EmptyCatchBlock: + active: true + allowedExceptionNameRegex: '_|(ignore|expected).*' + EmptyClassBlock: + active: true + EmptyDefaultConstructor: + active: true + EmptyDoWhileBlock: + active: true + EmptyElseBlock: + active: true + EmptyFinallyBlock: + active: true + EmptyForBlock: + active: true + EmptyFunctionBlock: + active: true + ignoreOverridden: false + EmptyIfBlock: + active: true + EmptyInitBlock: + active: true + EmptyKtFile: + active: true + EmptySecondaryConstructor: + active: true + EmptyTryBlock: + active: true + EmptyWhenBlock: + active: true + EmptyWhileBlock: + active: true + +exceptions: + active: true + ExceptionRaisedInUnexpectedLocation: + active: true + methodNames: + - 'equals' + - 'finalize' + - 'hashCode' + - 'toString' + InstanceOfCheckForException: + active: true + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ] + NotImplementedDeclaration: + active: false + ObjectExtendsThrowable: + active: false + PrintStackTrace: + active: true + RethrowCaughtException: + active: true + ReturnFromFinally: + active: true + ignoreLabeled: false + SwallowedException: + active: true + ignoredExceptionTypes: + - 'InterruptedException' + - 'MalformedURLException' + - 'NumberFormatException' + - 'ParseException' + allowedExceptionNameRegex: '_|(ignore|expected).*' + ThrowingExceptionFromFinally: + active: true + ThrowingExceptionInMain: + active: false + ThrowingExceptionsWithoutMessageOrCause: + active: true + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ] + exceptions: + - 'ArrayIndexOutOfBoundsException' + - 'Exception' + - 'IllegalArgumentException' + - 'IllegalMonitorStateException' + - 'IllegalStateException' + - 'IndexOutOfBoundsException' + - 'NullPointerException' + - 'RuntimeException' + - 'Throwable' + ThrowingNewInstanceOfSameException: + active: true + TooGenericExceptionCaught: + active: true + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ] + exceptionNames: + - 'ArrayIndexOutOfBoundsException' + - 'Error' + - 'Exception' + - 'IllegalMonitorStateException' + - 'IndexOutOfBoundsException' + - 'NullPointerException' + - 'RuntimeException' + - 'Throwable' + allowedExceptionNameRegex: '_|(ignore|expected).*' + TooGenericExceptionThrown: + active: true + exceptionNames: + - 'Error' + - 'Exception' + - 'RuntimeException' + - 'Throwable' + +naming: + active: true + BooleanPropertyNaming: + active: false + allowedPattern: '^(is|has|are)' + ClassNaming: + active: true + classPattern: '[A-Z][a-zA-Z0-9]*' + ConstructorParameterNaming: + active: true + parameterPattern: '[a-z][A-Za-z0-9]*' + privateParameterPattern: '[a-z][A-Za-z0-9]*' + excludeClassPattern: '$^' + EnumNaming: + active: true + enumEntryPattern: '[A-Z][_a-zA-Z0-9]*' + ForbiddenClassName: + active: false + forbiddenName: [ ] + FunctionMaxLength: + active: false + maximumFunctionNameLength: 30 + FunctionMinLength: + active: false + minimumFunctionNameLength: 3 + FunctionNaming: + active: true + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ] + functionPattern: '[a-z][a-zA-Z0-9]*' + excludeClassPattern: '$^' + FunctionParameterNaming: + active: true + parameterPattern: '[a-z][A-Za-z0-9]*' + excludeClassPattern: '$^' + InvalidPackageDeclaration: + active: true + rootPackage: '' + requireRootInDeclaration: false + LambdaParameterNaming: + active: false + parameterPattern: '[a-z][A-Za-z0-9]*|_' + MatchingDeclarationName: + active: true + mustBeFirst: true + MemberNameEqualsClassName: + active: true + ignoreOverridden: true + NoNameShadowing: + active: true + NonBooleanPropertyPrefixedWithIs: + active: false + ObjectPropertyNaming: + active: true + 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 + packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*' + TopLevelPropertyNaming: + active: true + 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 + maximumVariableNameLength: 64 + VariableMinLength: + active: false + minimumVariableNameLength: 1 + VariableNaming: + active: true + variablePattern: '[a-z][A-Za-z0-9]*' + privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' + excludeClassPattern: '$^' + +performance: + active: true + ArrayPrimitive: + active: true + CouldBeSequence: + active: false + threshold: 3 + ForEachOnRange: + active: true + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ] + SpreadOperator: + active: true + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ] + UnnecessaryPartOfBinaryExpression: + active: false + UnnecessaryTemporaryInstantiation: + active: true + +potential-bugs: + active: true + AvoidReferentialEquality: + active: true + forbiddenTypePatterns: + - 'kotlin.String' + CastNullableToNonNullableType: + active: false + CastToNullableType: + active: false + Deprecation: + active: false + DontDowncastCollectionTypes: + active: false + DoubleMutabilityForCollection: + active: true + mutableTypes: + - 'kotlin.collections.MutableList' + - 'kotlin.collections.MutableMap' + - 'kotlin.collections.MutableSet' + - 'java.util.ArrayList' + - 'java.util.LinkedHashSet' + - 'java.util.HashSet' + - 'java.util.LinkedHashMap' + - 'java.util.HashMap' + ElseCaseInsteadOfExhaustiveWhen: + active: false + ignoredSubjectTypes: [ ] + EqualsAlwaysReturnsTrueOrFalse: + active: true + EqualsWithHashCodeExist: + active: true + ExitOutsideMain: + active: false + ExplicitGarbageCollectionCall: + active: true + HasPlatformType: + active: true + IgnoredReturnValue: + active: true + restrictToConfig: true + returnValueAnnotations: + - 'CheckResult' + - '*.CheckResult' + - 'CheckReturnValue' + - '*.CheckReturnValue' + ignoreReturnValueAnnotations: + - 'CanIgnoreReturnValue' + - '*.CanIgnoreReturnValue' + returnValueTypes: + - 'kotlin.sequences.Sequence' + - 'kotlinx.coroutines.flow.*Flow' + - 'java.util.stream.*Stream' + ignoreFunctionCall: [ ] + ImplicitDefaultLocale: + active: true + ImplicitUnitReturnType: + active: false + allowExplicitReturnType: true + InvalidRange: + active: true + IteratorHasNextCallsNextMethod: + active: true + IteratorNotThrowingNoSuchElementException: + active: true + LateinitUsage: + active: false + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ] + ignoreOnClassesPattern: '' + MapGetWithNotNullAssertionOperator: + active: true + MissingPackageDeclaration: + active: false + excludes: [ '**/*.kts' ] + NullCheckOnMutableProperty: + active: false + NullableToStringCall: + active: false + PropertyUsedBeforeDeclaration: + active: false + UnconditionalJumpStatementInLoop: + active: false + UnnecessaryNotNullCheck: + active: false + UnnecessaryNotNullOperator: + active: true + UnnecessarySafeCall: + active: true + UnreachableCatchBlock: + active: true + UnreachableCode: + active: true + UnsafeCallOnNullableType: + active: true + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ] + UnsafeCast: + active: true + UnusedUnaryOperator: + active: true + UselessPostfixExpression: + active: true + WrongEqualsTypeParameter: + active: true + +style: + active: true + AlsoCouldBeApply: + active: false + BracesOnIfStatements: + active: false + singleLine: 'never' + multiLine: 'always' + BracesOnWhenStatements: + active: false + singleLine: 'necessary' + multiLine: 'consistent' + CanBeNonNullable: + active: false + CascadingCallWrapping: + active: false + includeElvis: true + ClassOrdering: + active: false + CollapsibleIfStatements: + active: false + DataClassContainsFunctions: + active: false + conversionFunctionPrefix: + - 'to' + allowOperators: false + DataClassShouldBeImmutable: + active: false + DestructuringDeclarationWithTooManyEntries: + active: true + maxDestructuringEntries: 3 + DoubleNegativeLambda: + active: false + negativeFunctions: + - reason: 'Use `takeIf` instead.' + value: 'takeUnless' + - reason: 'Use `all` instead.' + value: 'none' + negativeFunctionNameParts: + - 'not' + - 'non' + EqualsNullCall: + active: true + EqualsOnSignatureLine: + active: false + ExplicitCollectionElementAccessMethod: + active: false + ExplicitItLambdaParameter: + active: true + ExpressionBodySyntax: + active: false + includeLineWrapping: false + ForbiddenAnnotation: + active: false + annotations: + - reason: 'it is a java annotation. Use `Suppress` instead.' + value: 'java.lang.SuppressWarnings' + - reason: 'it is a java annotation. Use `kotlin.Deprecated` instead.' + value: 'java.lang.Deprecated' + - reason: 'it is a java annotation. Use `kotlin.annotation.MustBeDocumented` instead.' + value: 'java.lang.annotation.Documented' + - reason: 'it is a java annotation. Use `kotlin.annotation.Target` instead.' + value: 'java.lang.annotation.Target' + - reason: 'it is a java annotation. Use `kotlin.annotation.Retention` instead.' + value: 'java.lang.annotation.Retention' + - reason: 'it is a java annotation. Use `kotlin.annotation.Repeatable` instead.' + value: 'java.lang.annotation.Repeatable' + - reason: 'Kotlin does not support @Inherited annotation, see https://youtrack.jetbrains.com/issue/KT-22265' + value: 'java.lang.annotation.Inherited' + ForbiddenComment: + active: true + comments: + - reason: 'Forbidden FIXME todo marker in comment, please fix the problem.' + value: 'FIXME:' + - reason: 'Forbidden STOPSHIP todo marker in comment, please address the problem before shipping the code.' + value: 'STOPSHIP:' + - reason: 'Forbidden TODO todo marker in comment, please do the changes.' + value: 'TODO:' + allowedPatterns: '' + ForbiddenImport: + active: false + imports: [ ] + forbiddenPatterns: '' + ForbiddenMethodCall: + active: false + methods: + - 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: [ ] + ForbiddenVoid: + active: true + ignoreOverridden: false + ignoreUsageInGenerics: false + FunctionOnlyReturningConstant: + active: true + ignoreOverridableFunction: true + ignoreActualFunction: true + excludedFunctions: [ ] + LoopWithTooManyJumpStatements: + active: true + maxJumpCount: 1 + MagicNumber: + active: true + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/*.kts' ] + ignoreNumbers: + - '-1' + - '0' + - '1' + - '2' + ignoreHashCodeFunction: true + ignorePropertyDeclaration: false + ignoreLocalVariableDeclaration: false + ignoreConstantDeclaration: true + ignoreCompanionObjectPropertyDeclaration: true + ignoreAnnotation: false + ignoreNamedArgument: true + ignoreEnums: false + ignoreRanges: false + ignoreExtensionFunctions: true + MandatoryBracesLoops: + active: false + MaxChainedCallsOnSameLine: + active: false + maxChainedCalls: 5 + MaxLineLength: + active: true + maxLineLength: 120 + excludePackageStatements: true + excludeImportStatements: true + excludeCommentStatements: false + excludeRawStrings: true + MayBeConst: + active: true + ModifierOrder: + active: true + MultilineLambdaItParameter: + active: false + MultilineRawStringIndentation: + active: false + indentSize: 4 + trimmingMethods: + - 'trimIndent' + - 'trimMargin' + NestedClassesVisibility: + active: true + NewLineAtEndOfFile: + active: true + NoTabs: + active: false + NullableBooleanCheck: + active: false + ObjectLiteralToLambda: + active: true + OptionalAbstractKeyword: + active: true + OptionalUnit: + active: false + PreferToOverPairSyntax: + active: false + ProtectedMemberInFinalClass: + active: true + RedundantExplicitType: + active: false + RedundantHigherOrderMapUsage: + active: true + RedundantVisibilityModifierRule: + active: false + ReturnCount: + active: true + max: 2 + excludedFunctions: + - 'equals' + excludeLabeled: false + excludeReturnFromLambda: true + excludeGuardClauses: false + SafeCast: + active: true + SerialVersionUIDInSerializableClass: + active: true + SpacingBetweenPackageAndImports: + active: false + StringShouldBeRawString: + active: false + maxEscapedCharacterCount: 2 + ignoredCharacters: [ ] + ThrowsCount: + active: true + max: 2 + excludeGuardClauses: false + TrailingWhitespace: + active: false + TrimMultilineRawString: + active: false + trimmingMethods: + - 'trimIndent' + - 'trimMargin' + UnderscoresInNumericLiterals: + active: false + acceptableLength: 4 + allowNonStandardGrouping: false + UnnecessaryAbstractClass: + active: true + UnnecessaryAnnotationUseSiteTarget: + active: false + UnnecessaryApply: + active: true + UnnecessaryBackticks: + active: false + UnnecessaryBracesAroundTrailingLambda: + active: false + UnnecessaryFilter: + active: true + UnnecessaryInheritance: + active: true + UnnecessaryInnerClass: + active: false + UnnecessaryLet: + active: false + UnnecessaryParentheses: + active: false + allowForUnclearPrecedence: false + UntilInsteadOfRangeTo: + active: false + UnusedImports: + active: false + UnusedParameter: + active: true + allowedNames: 'ignored|expected' + UnusedPrivateClass: + active: true + UnusedPrivateMember: + active: true + allowedNames: '' + UnusedPrivateProperty: + active: true + allowedNames: '_|ignored|expected|serialVersionUID' + UseAnyOrNoneInsteadOfFind: + active: true + UseArrayLiteralsInAnnotations: + active: true + UseCheckNotNull: + active: true + UseCheckOrError: + active: true + UseDataClass: + active: false + allowVars: false + UseEmptyCounterpart: + active: false + UseIfEmptyOrIfBlank: + active: false + UseIfInsteadOfWhen: + active: false + ignoreWhenContainingVariableDeclaration: false + UseIsNullOrEmpty: + active: true + UseLet: + active: false + UseOrEmpty: + active: true + UseRequire: + active: true + UseRequireNotNull: + active: true + UseSumOfInsteadOfFlatMapSize: + active: false + UselessCallOnNotNull: + active: true + UtilityClassWithPublicConstructor: + active: true + VarCouldBeVal: + active: true + ignoreLateinitVar: false + WildcardImport: + active: true + excludeImports: + - 'java.util.*' diff --git a/effective-kotlin/detekt-baseline.xml b/effective-kotlin/detekt-baseline.xml new file mode 100644 index 0000000..0748295 --- /dev/null +++ b/effective-kotlin/detekt-baseline.xml @@ -0,0 +1,27 @@ + + + + + FunctionNaming:CommonMethods.kt$fun `with data classes`() + FunctionNaming:ConsiderStaticFactoryMethods.kt$fun `with Java static factory functions`() + FunctionNaming:ConsiderStaticFactoryMethods.kt$fun `with Kotlin companion object extension factory functions`() + FunctionNaming:ConsiderStaticFactoryMethods.kt$fun `with Kotlin companion object factory functions`() + FunctionNaming:ConsiderStaticFactoryMethods.kt$fun `with Kotlin top-level factory functions`() + FunctionNaming:FavorComposition.kt$fun `with decorators`() + FunctionNaming:FavorComposition.kt$fun `with prohibiting or documenting for inheritance`() + MagicNumber:CommonMethods.kt$22 + MagicNumber:CommonMethods.kt$32 + MagicNumber:ConsiderStaticFactoryMethods.kt$3 + MagicNumber:ControlStructuresAsExpressions.kt$3 + MagicNumber:ControlStructuresAsExpressions.kt$4 + MagicNumber:Destructuring.kt$3 + MagicNumber:MakeDefensiveCopies.kt$OlympicTriplets$33 + MatchingDeclarationName:AccessorsOverFields.kt$Programmer + MatchingDeclarationName:AvoidStrings.kt$EmailAddress + MatchingDeclarationName:CommonMethods.kt$Person + MatchingDeclarationName:ConsiderBuilders.kt$NutritionFacts + MatchingDeclarationName:Destructuring.kt$Point3D + MatchingDeclarationName:Singletons.kt$HelloSingleton + SwallowedException:ControlStructuresAsExpressions.kt$e: JSONException + + diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d381613..37464ec 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,6 +3,7 @@ arrow = "1.2.4" assertj = "3.26.3" dependency-analysis-gradle-plugin = "2.0.0" +detekt = "1.23.7" equalsverifier = "3.16.2" jetbrains-annotations = "24.1.0" junit = "5.11.0" @@ -39,6 +40,10 @@ version.ref = "assertj" module = "com.autonomousapps.dependency-analysis:com.autonomousapps.dependency-analysis.gradle.plugin" version.ref = "dependency-analysis-gradle-plugin" +[libraries.detekt-gradle-plugin-dependency] +module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin" +version.ref = "detekt" + [libraries.equalsverifier] module = "nl.jqno.equalsverifier:equalsverifier" version.ref = "equalsverifier" @@ -207,6 +212,10 @@ mockk-jvm = [ id = "com.autonomousapps.dependency-analysis" version.ref = "dependency-analysis-gradle-plugin" +[plugins.detekt-gradle-plugin] +id = "io.gitlab.arturbosch.detekt" +version.ref = "detekt" + [plugins.jvm-dependency-conflict-detection-gradle-plugin] id = "org.gradlex.jvm-dependency-conflict-detection" version.ref = "jvm-dependency-conflict-resolution" diff --git a/kotlin-dl/detekt-baseline.xml b/kotlin-dl/detekt-baseline.xml new file mode 100644 index 0000000..2251828 --- /dev/null +++ b/kotlin-dl/detekt-baseline.xml @@ -0,0 +1,8 @@ + + + + + MagicNumber:FashionMnist.kt$100 + MagicNumber:FashionMnist.kt$300 + + diff --git a/kotlin-for-java-devs-client/detekt-baseline.xml b/kotlin-for-java-devs-client/detekt-baseline.xml new file mode 100644 index 0000000..d2a97fb --- /dev/null +++ b/kotlin-for-java-devs-client/detekt-baseline.xml @@ -0,0 +1,10 @@ + + + + + MagicNumber:OtherModuleAndPackageNPC.kt$OtherModuleAndPackageNPC$100 + PackageNaming:OtherModuleAndPackageNPC.kt$package org.sdkotlin.intro.kotlin._30_sealedtypes.otherpackage + PackageNaming:OtherModulePlayer.kt$package org.sdkotlin.intro.kotlin._30_sealedtypes + PackageNaming:SealedTypeSmartCastFromOtherModule.kt$package org.sdkotlin.intro.kotlin._30_sealedtypes + + diff --git a/kotlin-for-java-devs/detekt-baseline.xml b/kotlin-for-java-devs/detekt-baseline.xml new file mode 100644 index 0000000..b0930e8 --- /dev/null +++ b/kotlin-for-java-devs/detekt-baseline.xml @@ -0,0 +1,281 @@ + + + + + CyclomaticComplexMethod:NullSafetyInKotlin.kt$fun main() + EmptyFunctionBlock:FunctionsInKotlin.kt${} + ForEachOnRange:CoroutinesInKotlin.kt$1..ONE_MILLION + ForEachOnRange:IterationInKotlin.kt$1 until 5 + ForEachOnRange:IterationInKotlin.kt$1..5 + ForbiddenComment:ReflectionInKotlin.kt$// TODO: Add reflection example for Kotlin. + ForbiddenComment:ScopingFunctionsInKotlin.kt$// TODO: Add scoping functions example for Kotlin. + ForbiddenComment:TailRecursionInKotlin.kt$// TODO: Why does stack depth change and why does this not succeed? + FunctionNaming:AnnotationsInKotlin.kt$fun `with deprecation`() + FunctionNaming:DataClassesInKotlin.kt$fun `with component and copy functions`() + FunctionNaming:DataClassesInKotlin.kt$fun `with data classes in the standard library`() + FunctionNaming:DataClassesInKotlin.kt$fun `with equals, hashCode, and toString`() + FunctionNaming:DataClassesInKotlin.kt$fun `with private data class constructor`() + FunctionNaming:DelegationInKotlin.kt$fun `creating property delegates`() + FunctionNaming:DelegationInKotlin.kt$fun `with delegates`() + FunctionNaming:DelegationInKotlin.kt$fun `with deprecated property delegation`() + FunctionNaming:DelegationInKotlin.kt$fun `with lateInit`() + FunctionNaming:DelegationInKotlin.kt$fun `with the Lazy property delegate`() + FunctionNaming:DelegationInKotlin.kt$fun `with the NotNull property delegate`() + FunctionNaming:DelegationInKotlin.kt$fun `with the Observable property delegate`() + FunctionNaming:DelegationInKotlin.kt$fun `with the Vetoable property delegate`() + FunctionNaming:DelegationInKotlin.kt$fun `with the map-backed property delegate`() + FunctionNaming:DelegationInKotlin.kt$fun `with the mutable map-backed property delegate`() + FunctionNaming:EnumsInKotlin.kt$fun `while driving`(light: TrafficLight) + FunctionNaming:EnumsInKotlin.kt$fun `with states`() + FunctionNaming:GenericsInKotlin.kt$fun `better give and receive`() + FunctionNaming:GenericsInKotlin.kt$fun `gift anything`() + FunctionNaming:GenericsInKotlin.kt$fun `give and receive FAIL`() + FunctionNaming:GenericsInKotlin.kt$fun `only from Mom`() + FunctionNaming:GenericsInKotlin.kt$fun `only open on your birthday`() + FunctionNaming:InfixFunctionsInKotlin.kt$infix fun Int.`+-`(other: Int) + FunctionNaming:VarianceInKotlin.kt$fun `with array and collection variance`() + FunctionNaming:VarianceInKotlin.kt$fun `with consumers`() + FunctionNaming:VarianceInKotlin.kt$fun `with producers`() + FunctionNaming:VarianceInKotlin.kt$fun `with simple container variance`() + FunctionNaming:VarianceInKotlin.kt$fun `with star projections`() + FunctionNaming:VarianceInKotlin.kt$fun `with substitution`() + FunctionNaming:VarianceInKotlin.kt$fun `with use-site variance`() + FunctionOnlyReturningConstant:AnnotationsInKotlin.kt$@ArrayAnnotation(["One", "Two"]) fun arrayAnnotations() + FunctionOnlyReturningConstant:AnnotationsInKotlin.kt$@MetaGreat(InherentlyGreat()) fun greatness() + FunctionOnlyReturningConstant:AnnotationsInKotlin.kt$@RedundantAnnotation @RedundantAnnotation fun test() + FunctionOnlyReturningConstant:AnnotationsInKotlin.kt$@Suppress("unused") fun notUsed() + FunctionOnlyReturningConstant:AnnotationsInKotlin.kt$@Suppress(unused) fun alsoUnused() + FunctionOnlyReturningConstant:AnnotationsInKotlin.kt$@Valuable("This much") fun valuation() + FunctionOnlyReturningConstant:AnnotationsInKotlin.kt$@VarargAnnotation("One", "Two") fun varagAnnotations() + FunctionOnlyReturningConstant:ExtensionFunctionsInKotlin.kt$fun Animal.name() + FunctionOnlyReturningConstant:ExtensionFunctionsInKotlin.kt$fun Lion.name() + FunctionOnlyReturningConstant:HigherOrderFunctionsAndLambdasInKotlin.kt$fun theBoss() + FunctionOnlyReturningConstant:StaticInKotlin.kt$StaticInKotlin$fun instanceFunction() + FunctionOnlyReturningConstant:TddInKotlin.kt$TddInKotlin$fun weCanDoIt() + FunctionOnlyReturningConstant:UnionTypesInKotlin.kt$Garbage$fun throwAway() + FunctionOnlyReturningConstant:Utilities.kt$internal fun itsYourBirthday() + InvalidPackageDeclaration:PackagesInKotlin.kt$package somewhere.over.the.rainbow + InvalidRange:RangesInKotlin.kt$1..0 + LongMethod:NullSafetyInKotlin.kt$fun main() + MagicNumber:ArraysInKotlin.kt$100 + MagicNumber:ArraysInKotlin.kt$200 + MagicNumber:ArraysInKotlin.kt$3 + MagicNumber:ArraysInKotlin.kt$3.0 + MagicNumber:ArraysInKotlin.kt$300 + MagicNumber:ArraysInKotlin.kt$4 + MagicNumber:ArraysInKotlin.kt$5 + MagicNumber:ArraysInKotlin.kt$6 + MagicNumber:CollectionsInKotlin.kt$10 + MagicNumber:CollectionsInKotlin.kt$100 + MagicNumber:CollectionsInKotlin.kt$3 + MagicNumber:DelegationInKotlin.kt$1025 + MagicNumber:DelegationInKotlin.kt$3 + MagicNumber:EnumsInKotlin.kt$40 + MagicNumber:EnumsInKotlin.kt$TrafficLight.CAUTION$5 + MagicNumber:EnumsInKotlin.kt$TrafficLight.GO$30 + MagicNumber:EnumsInKotlin.kt$TrafficLight.STOP$20 + MagicNumber:EnumsInKotlin.kt$Trio.BASS$4 + MagicNumber:EnumsInKotlin.kt$Trio.GUITAR$6 + MagicNumber:FunctionsInKotlin.kt$3 + MagicNumber:GenericsInKotlin.kt$36 + MagicNumber:HigherOrderFunctionsAndLambdasInKotlin.kt$113 + MagicNumber:HigherOrderFunctionsAndLambdasInKotlin.kt$3 + MagicNumber:HigherOrderFunctionsAndLambdasInKotlin.kt$355 + MagicNumber:HigherOrderFunctionsAndLambdasInKotlin.kt$4 + MagicNumber:InlineClassesInKotlin.kt$100 + MagicNumber:InlineClassesInKotlin.kt$3 + MagicNumber:IterationInKotlin.kt$5 + MagicNumber:NullSafetyInKotlin.kt$16 + MagicNumber:RangesInKotlin.kt$10 + MagicNumber:RangesInKotlin.kt$10.5 + MagicNumber:RangesInKotlin.kt$10.5f + MagicNumber:RangesInKotlin.kt$10L + MagicNumber:RangesInKotlin.kt$11 + MagicNumber:RangesInKotlin.kt$12 + MagicNumber:RangesInKotlin.kt$19 + MagicNumber:RangesInKotlin.kt$20 + MagicNumber:RangesInKotlin.kt$2020 + MagicNumber:RangesInKotlin.kt$3 + MagicNumber:RangesInKotlin.kt$31 + MagicNumber:RangesInKotlin.kt$4 + MagicNumber:RangesInKotlin.kt$6 + MagicNumber:SelectionInKotlin.kt$10 + MagicNumber:SelectionInKotlin.kt$100 + MagicNumber:SequencesInKotlin.kt$10 + MagicNumber:SequencesInKotlin.kt$100 + MagicNumber:SequencesInKotlin.kt$1000 + MagicNumber:SequencesInKotlin.kt$5 + MagicNumber:SequencesInKotlin.kt$50 + MagicNumber:TailRecursionDebugging.kt$10 + MagicNumber:TailRecursionDebugging.kt$15 + MagicNumber:TailRecursionInKotlin.kt$5 + MagicNumber:UnionTypesInKotlin.kt$127 + MagicNumber:UnionTypesInKotlin.kt$3 + MagicNumber:UnionTypesInKotlin.kt$4 + MagicNumber:VarianceInKotlin.kt$<no name provided>$5 + MagicNumber:VarianceInKotlin.kt$NaiveTester$5 + MatchingDeclarationName:ImportsInKotlin.kt$Thing1 + MatchingDeclarationName:OperatorOverloadingInKotlin.kt$Zebra + MayBeConst:ConstantsInKotlin.kt$@JvmField val JVM_FIELD_VAL = "Testing @JvmField val" + MayBeConst:ConstantsInKotlin.kt$ConstantsInKotlinObject$val OBJECT_VAL = "val in object" + MayBeConst:ConstantsInKotlin.kt$private val PRIVATE_VAL = "private val" + MayBeConst:ConstantsInKotlin.kt$val REGULAR_VAL = "val" + MayBeConst:ConstantsInKotlinCompanion.kt$ConstantsInKotlinCompanion.Companion$@JvmField val COMPANION_JVM_FIELD_VAL = "Testing @JvmField val in object" + MayBeConst:ConstantsInKotlinObject.kt$ConstantsInKotlinObject$@JvmField val OBJECT_JVM_FIELD_VAL = "Testing @JvmField val in object" + MayBeConst:HigherOrderFunctionsAndLambdasInKotlin.kt$val almostPi = 355 / 113 + MayBeConst:UnsignedTypesInKotlin.kt$val binUByte: UByte = 0b0000_0001u + MayBeConst:UnsignedTypesInKotlin.kt$val hexUByte: UByte = 0x01u + MayBeConst:UnsignedTypesInKotlin.kt$val uByte: UByte = 255u // or uppercase 255U + MayBeConst:UnsignedTypesInKotlin.kt$val uInt = 0u // UInt inferred type if literal fits + MayBeConst:UnsignedTypesInKotlin.kt$val uLong = 0xFF_FF_FF_FF_01u // ULong inferred when literal doesn't fit UInt + MayBeConst:VariablesAndTypesInKotlin.kt$val boolean = false // Boolean + MayBeConst:VariablesAndTypesInKotlin.kt$val byte: Byte = 0 // Byte, type required because no literal + MayBeConst:VariablesAndTypesInKotlin.kt$val character = 'c' // Char, can't be treated as a number + MayBeConst:VariablesAndTypesInKotlin.kt$val double = 0.0 // Double, 'd/D' not supported + MayBeConst:VariablesAndTypesInKotlin.kt$val float = 0.0f // Float, 'F' also supported + MayBeConst:VariablesAndTypesInKotlin.kt$val i = 0 + MayBeConst:VariablesAndTypesInKotlin.kt$val integer = 0 // Int + MayBeConst:VariablesAndTypesInKotlin.kt$val long = 0L // Long, lowercase 'l' not supported + PackageNaming:AbstractClassesInKotlin.kt$package org.sdkotlin.intro.kotlin._19_abstractclasses + PackageNaming:AiNPC.kt$package org.sdkotlin.intro.kotlin._30_sealedtypes.otherpackage + PackageNaming:AnnotationsInKotlin.kt$package org.sdkotlin.intro.kotlin._31_annotations + PackageNaming:ArraysInKotlin.kt$package org.sdkotlin.intro.kotlin._24_arrays + PackageNaming:ClassesInKotlin.kt$package org.sdkotlin.intro.kotlin._00_classes + PackageNaming:CollectionsInKotlin.kt$package org.sdkotlin.intro.kotlin._26_collections + PackageNaming:ConstantsInKotlin.kt$package org.sdkotlin.intro.kotlin._17_constants + PackageNaming:ConstantsInKotlin.kt$package org.sdkotlin.javainterop._XX_constants + PackageNaming:ConstantsInKotlinCompanion.kt$package org.sdkotlin.javainterop._XX_constants + PackageNaming:ConstantsInKotlinObject.kt$package org.sdkotlin.javainterop._XX_constants + PackageNaming:ConstructorsAndInitializersInKotlin.kt$package org.sdkotlin.intro.kotlin._13_constructors + PackageNaming:CoroutinesInKotlin.kt$package org.sdkotlin.intro.kotlin._XX_coroutines + PackageNaming:DataClassesInKotlin.kt$package org.sdkotlin.intro.kotlin._14_0_dataclasses + PackageNaming:DelegationInKotlin.kt$package org.sdkotlin.intro.kotlin._32_delegation + PackageNaming:EnumsInKotlin.kt$package org.sdkotlin.intro.kotlin._29_enums + PackageNaming:EqualityInKotlin.kt$package org.sdkotlin.intro.kotlin._07_equality + PackageNaming:ExtensionFunctionScopingInKotlin.kt$package org.sdkotlin.intro.kotlin._08_3_extensionfunctions.otherpackage + PackageNaming:ExtensionFunctionsInKotlin.kt$package org.sdkotlin.intro.kotlin._08_3_extensionfunctions + PackageNaming:FunctionsInKotlin.kt$package org.sdkotlin.intro.kotlin._08_0_functions + PackageNaming:GenericsInKotlin.kt$package org.sdkotlin.intro.kotlin._23_generics + PackageNaming:HelloKotlin.kt$package org.sdkotlin.intro.kotlin._02_helloworld + PackageNaming:HelloWithArgs.kt$package org.sdkotlin.intro.kotlin._02_helloworld.withargs + PackageNaming:HigherOrderFunctionsAndLambdasInKotlin.kt$package org.sdkotlin.intro.kotlin._08_1_higherorderfunctions + PackageNaming:ImportsInKotlin.kt$package org.sdkotlin.intro.kotlin._04_imports + PackageNaming:InfixFunctionsInKotlin.kt$package org.sdkotlin.intro.kotlin._08_5_infixfunctions + PackageNaming:InheritanceInKotlin.kt$package org.sdkotlin.intro.kotlin._18_inheritance + PackageNaming:InlineClassesInKotlin.kt$package org.sdkotlin.intro.kotlin._14_1_inlineclasses + PackageNaming:InterfacesInKotlin.kt$package org.sdkotlin.intro.kotlin._20_interfaces + PackageNaming:IterationInKotlin.kt$package org.sdkotlin.intro.kotlin._11_iteration + PackageNaming:LateInit.kt$package org.sdkotlin.intro.kotlin._32_delegation + PackageNaming:NullSafetyInKotlin.kt$package org.sdkotlin.intro.kotlin._22_nullsafety + PackageNaming:OperatorOverloadingInKotlin.kt$package org.sdkotlin.intro.kotlin._08_4_operatorfunctions + PackageNaming:OtherPackagePlayer.kt$package org.sdkotlin.intro.kotlin._30_sealedtypes.otherpackage + PackageNaming:PolyglotPersonTest.kt$package org.sdkotlin.intro.kotlin._14_0_dataclasses + PackageNaming:PropertiesInKotlin.kt$package org.sdkotlin.intro.kotlin._12_properties + PackageNaming:RangesInKotlin.kt$package org.sdkotlin.intro.kotlin._09_ranges + PackageNaming:ReflectionInKotlin.kt$package org.sdkotlin.intro.kotlin._XX_reflection + PackageNaming:ScopingFunctionsInKotlin.kt$package org.sdkotlin.intro.kotlin._XX_scopingfunctions + PackageNaming:SealedTypesInKotlin.kt$package org.sdkotlin.intro.kotlin._30_sealedtypes + PackageNaming:SelectionInKotlin.kt$package org.sdkotlin.intro.kotlin._10_selection + PackageNaming:SequencesInKotlin.kt$package org.sdkotlin.intro.kotlin._27_sequences + PackageNaming:SingletonInKotlin.kt$package org.sdkotlin.intro.kotlin._15_singletons + PackageNaming:SmartCastsInKotlin.kt$package org.sdkotlin.intro.kotlin._21_smartcasts + PackageNaming:StaticInKotlin.kt$package org.sdkotlin.intro.kotlin._16_static + PackageNaming:StringsInKotlin.kt$package org.sdkotlin.intro.kotlin._06_strings + PackageNaming:TailRecursionDebugging.kt$package org.sdkotlin.intro.kotlin._08_2_tailrecursivefunctions + PackageNaming:TailRecursionInKotlin.kt$package org.sdkotlin.intro.kotlin._08_2_tailrecursivefunctions + PackageNaming:TddInKotlin.kt$package org.sdkotlin.intro.kotlin._XX_tdd + PackageNaming:TddInKotlinTest.kt$package org.sdkotlin.intro.kotlin._XX_tdd + PackageNaming:Thing1.kt$package org.sdkotlin.intro.kotlin._04_imports.otherpackage + PackageNaming:TopLevelInKotlin.kt$package org.sdkotlin.intro.kotlin._03_toplevel + PackageNaming:TopLevelUsageInKotlin.kt$package org.sdkotlin.intro.kotlin._03_toplevel.usage + PackageNaming:TryWithResourcesInKotlin.kt$package org.sdkotlin.intro.kotlin._XX_try_w_resources + PackageNaming:UnionTypesInKotlin.kt$package org.sdkotlin.intro.kotlin._XX_uniontypes + PackageNaming:UnknownPlayer.kt$package org.sdkotlin.intro.kotlin._30_sealedtypes + PackageNaming:UnsignedTypesInKotlin.kt$package org.sdkotlin.intro.kotlin._05_1_unsigned_types + PackageNaming:Utilities.kt$package org.sdkotlin.intro.kotlin._23_generics.util + PackageNaming:VarargsInKotlin.kt$package org.sdkotlin.intro.kotlin._25_varargfunctions + PackageNaming:VariablesAndTypesInKotlin.kt$package org.sdkotlin.intro.kotlin._05_0_variables_and_types + PackageNaming:VarianceInKotlin.kt$package org.sdkotlin.intro.kotlin._28_variance + PrintStackTrace:TryWithResourcesInKotlin.kt$e + SerialVersionUIDInSerializableClass:InterfacesInKotlin.kt$Circle : ShapeSerializable + SerialVersionUIDInSerializableClass:InterfacesInKotlin.kt$Triangle : ShapeSerializable + SpreadOperator:VarargsInKotlin.kt$(*arrayOfThings) + SwallowedException:CoroutinesInKotlin.kt$e: OutOfMemoryError + SwallowedException:NullSafetyInKotlin.kt$e: IllegalStateException + SwallowedException:NullSafetyInKotlin.kt$e: NullPointerException + SwallowedException:SequencesInKotlin.kt$e: NullPointerException + SwallowedException:SmartCastsInKotlin.kt$e: ClassCastException + SwallowedException:TailRecursionInKotlin.kt$e: StackOverflowError + TooGenericExceptionCaught:ArraysInKotlin.kt$e: ArrayIndexOutOfBoundsException + TooGenericExceptionCaught:NullSafetyInKotlin.kt$e: NullPointerException + TooGenericExceptionCaught:SequencesInKotlin.kt$e: NullPointerException + TooManyFunctions:AnnotationsInKotlin.kt$org.sdkotlin.intro.kotlin._31_annotations.AnnotationsInKotlin.kt + TooManyFunctions:DelegationInKotlin.kt$org.sdkotlin.intro.kotlin._32_delegation.DelegationInKotlin.kt + TooManyFunctions:FunctionsInKotlin.kt$org.sdkotlin.intro.kotlin._08_0_functions.FunctionsInKotlin.kt + TopLevelPropertyNaming:AnnotationsInKotlin.kt$const val unused = "unused" + UnusedPrivateProperty:ArraysInKotlin.kt$val arrayOfNullableInts: Array<Int?> = arrayOf(1, null, 3) + UnusedPrivateProperty:ArraysInKotlin.kt$val booleanArray: BooleanArray = booleanArrayOf(true, false, true) + UnusedPrivateProperty:ArraysInKotlin.kt$val intArray: IntArray = intArrayOf(1, 2, 3) + UnusedPrivateProperty:ArraysInKotlin.kt$val noInts = emptyArray<Int>() + UnusedPrivateProperty:ArraysInKotlin.kt$val noStrings = emptyArray<String>() + UnusedPrivateProperty:ArraysInKotlin.kt$val nullInts = arrayOfNulls<Int>(size = 10) + UnusedPrivateProperty:ArraysInKotlin.kt$val numerals = Array(size = 10) { index -> index.toString() } + UnusedPrivateProperty:ArraysInKotlin.kt$val randomInts = Array(size = 10) { (1..100).random() } + UnusedPrivateProperty:CollectionsInKotlin.kt$val arrayListOfInts = arrayListOf(1, 2, 3).toList() + UnusedPrivateProperty:CollectionsInKotlin.kt$val fastMap = mutableMapOf<Int, String>().also { it[1] = "1" it[2] = "2" it[3] = "3" }.toMap() + UnusedPrivateProperty:CollectionsInKotlin.kt$val hashMapOfIntsToStrings = hashMapOf(1 to "1", 2 to "2", 3 to "3").toMap() + UnusedPrivateProperty:CollectionsInKotlin.kt$val hashSetOfInts = hashSetOf(1, 2, 3).toSet() + UnusedPrivateProperty:CollectionsInKotlin.kt$val listOfStrings = List(10) { index -> index.toString() } + UnusedPrivateProperty:CollectionsInKotlin.kt$val mapOfIntsToStrings = mapOf(1 to "1", 2 to "2", 3 to "3") + UnusedPrivateProperty:CollectionsInKotlin.kt$val mutableListOfStrings = MutableList(10) { index -> index.toString() } + UnusedPrivateProperty:CollectionsInKotlin.kt$val secondListOfInts = mutableCopiedListOfInts.toList() + UnusedPrivateProperty:CollectionsInKotlin.kt$val setOfInts = setOf(1, 2, 3) + UnusedPrivateProperty:ConstantsInKotlin.kt$private val PRIVATE_VAL = "private val" + UnusedPrivateProperty:ConstructorsAndInitializersInKotlin.kt$val han = Rebel("Han", false) + UnusedPrivateProperty:ConstructorsAndInitializersInKotlin.kt$val jabba = Hutt("Jabba", true) + UnusedPrivateProperty:ConstructorsAndInitializersInKotlin.kt$val luke = Rebel("Luke", true) + UnusedPrivateProperty:ConstructorsAndInitializersInKotlin.kt$val vader = Imperial("Darth Vader", true) + UnusedPrivateProperty:ConstructorsAndInitializersInKotlin.kt$val wicket = Ewok("Wicket") + UnusedPrivateProperty:GenericsInKotlin.kt$val amountOfPie = gift * 36 // `gift` is a `Double` now, so good to go. + UnusedPrivateProperty:GenericsInKotlin.kt$val amountOfPie = gift?.times(36) ?: 0.0 + UnusedPrivateProperty:GenericsInKotlin.kt$val largeSurprise = generousGift.asPresent() + UnusedPrivateProperty:GenericsInKotlin.kt$val perishableSurprise = yummyGift.asPresent() + UnusedPrivateProperty:NullSafetyInKotlin.kt$val definitelyGreatGazoo = GreatGazoo() + UnusedPrivateProperty:NullSafetyInKotlin.kt$val maybeGreatGazoo: GreatGazoo? = null + UnusedPrivateProperty:NullSafetyInKotlin.kt$val requiredName = nullableName ?: throw IllegalArgumentException("More specific than a NPE.") + UnusedPrivateProperty:NullSafetyInKotlin.kt$var age = 16 + UnusedPrivateProperty:NullSafetyInKotlin.kt$var nullableAge: Int? + UnusedPrivateProperty:RangesInKotlin.kt$val doubleRange = 1.0..10.5 + UnusedPrivateProperty:RangesInKotlin.kt$val floatRange = 1.0f..10.5f + UnusedPrivateProperty:RangesInKotlin.kt$val longRange = 0L..10L + UnusedPrivateProperty:RangesInKotlin.kt$val oddNumbersBackwards = 19 downTo 1 step 2 + UnusedPrivateProperty:RangesInKotlin.kt$val oneThroughTenIterator = oneThroughTen.iterator() + UnusedPrivateProperty:RangesInKotlin.kt$val openEndedIntRange: IntRange = 0 until 10 // 0-9 + UnusedPrivateProperty:RangesInKotlin.kt$val openEndedIntRangeOperator: IntRange = 0..<10 + UnusedPrivateProperty:RangesInKotlin.kt$val reverseIntegralProgression = 10 downTo 1 + UnusedPrivateProperty:SelectionInKotlin.kt$val isItANumber = when (randomBinaryInt) { // All Ints are Numbers. is Number -> true // And yet the compiler still requires this `else`. else -> false } + UnusedPrivateProperty:SequencesInKotlin.kt$val nope = streamBigEven + 1 + UnusedPrivateProperty:SmartCastsInKotlin.kt$val integer = thing as Int + UnusedPrivateProperty:VarianceInKotlin.kt$val KABLAMO: String = backToStringContainer.contents + UnusedPrivateProperty:VarianceInKotlin.kt$val anyList: List<Any> = stringList + UnusedPrivateProperty:VarianceInKotlin.kt$val anyProducer: Producer<Any> = stringProducer + UnusedPrivateProperty:VarianceInKotlin.kt$val anyTest = anyTester.test(any) + UnusedPrivateProperty:VarianceInKotlin.kt$val immutableStringContainer = ImmutableContainer("Hello") + UnusedPrivateProperty:VarianceInKotlin.kt$val indicesOfAnyAnythings = indicesOfAny(arrayOfAny) + UnusedPrivateProperty:VarianceInKotlin.kt$val indicesOfAnyStrings = indicesOfAny(arrayOfString) + UnusedPrivateProperty:VarianceInKotlin.kt$val indicesOfAnythings = indices(arrayOfAny) + UnusedPrivateProperty:VarianceInKotlin.kt$val indicesOfEAnythings = indicesOf(arrayOfAny) + UnusedPrivateProperty:VarianceInKotlin.kt$val indicesOfEStrings = indicesOf(arrayOfString) + UnusedPrivateProperty:VarianceInKotlin.kt$val indicesOfMaybeAnyAnythings = indicesOfAny(arrayOfMaybeAny) + UnusedPrivateProperty:VarianceInKotlin.kt$val indicesOfMaybeEAnythings = indicesOf(arrayOfMaybeAny) + UnusedPrivateProperty:VarianceInKotlin.kt$val indicesOfStrings = indices(arrayOfString) + UnusedPrivateProperty:VarianceInKotlin.kt$val mutableStringList = mutableListOf("Hello", "World") + UnusedPrivateProperty:VarianceInKotlin.kt$val naiveStringTester = NaiveTester<String>() + UnusedPrivateProperty:VarianceInKotlin.kt$val otherStringTest = anyTester.test(string) + UnusedPrivateProperty:VarianceInKotlin.kt$val stringArray = arrayOf("Hello", "World") + UnusedPrivateProperty:VarianceInKotlin.kt$val stringTest = stringTester.test(string) + UtilityClassWithPublicConstructor:ConstantsInKotlin.kt$ConstantsInKotlinCompanion + UtilityClassWithPublicConstructor:ConstantsInKotlinCompanion.kt$ConstantsInKotlinCompanion + VariableNaming:VarianceInKotlin.kt$val KABLAMO: String = backToStringContainer.contents + + diff --git a/ksp-builder-generator/api/annotations/src/main/kotlin/org/sdkotlin/buildergen/api/annotations/GeneratedBuilder.kt b/ksp-builder-generator/api/annotations/src/main/kotlin/org/sdkotlin/buildergen/api/annotations/GeneratedBuilder.kt index 5e8fea9..e70032c 100644 --- a/ksp-builder-generator/api/annotations/src/main/kotlin/org/sdkotlin/buildergen/api/annotations/GeneratedBuilder.kt +++ b/ksp-builder-generator/api/annotations/src/main/kotlin/org/sdkotlin/buildergen/api/annotations/GeneratedBuilder.kt @@ -1,3 +1,3 @@ package org.sdkotlin.buildergen.api.annotations -annotation class GeneratedBuilder() +annotation class GeneratedBuilder diff --git a/ksp-builder-generator/processor/detekt-baseline.xml b/ksp-builder-generator/processor/detekt-baseline.xml new file mode 100644 index 0000000..94b73ea --- /dev/null +++ b/ksp-builder-generator/processor/detekt-baseline.xml @@ -0,0 +1,8 @@ + + + + + LongMethod:BuilderGenVisitor.kt$BuilderGenVisitor$override fun visitFunctionDeclaration( function: KSFunctionDeclaration, data: Unit, ) + UnusedPrivateProperty:BuilderGenVisitor.kt$BuilderGenVisitor$private val logger: KSPLogger + + diff --git a/tdd-in-kotlin/detekt-baseline.xml b/tdd-in-kotlin/detekt-baseline.xml new file mode 100644 index 0000000..fab5596 --- /dev/null +++ b/tdd-in-kotlin/detekt-baseline.xml @@ -0,0 +1,12 @@ + + + + + ForEachOnRange:FizzBuzz.kt$1..100 + MagicNumber:FizzBuzz.kt$100 + MagicNumber:FizzBuzz.kt$15 + MagicNumber:FizzBuzz.kt$3 + MagicNumber:FizzBuzz.kt$5 + ReturnCount:FizzBuzz.kt$internal fun fizzBuzzOf(n: Int): String + + diff --git a/typed-errors-in-kotlin/detekt-baseline.xml b/typed-errors-in-kotlin/detekt-baseline.xml new file mode 100644 index 0000000..f1bfbe5 --- /dev/null +++ b/typed-errors-in-kotlin/detekt-baseline.xml @@ -0,0 +1,12 @@ + + + + + MagicNumber:TypedErrorsWithEither.kt$3 + MagicNumber:TypedErrorsWithEither.kt$5.0 + MagicNumber:TypedErrorsWithRaise.kt$3 + MagicNumber:TypedErrorsWithRaise.kt$5.0 + MatchingDeclarationName:TypedErrorsWithEither.kt$FruitBasketBuilder + MatchingDeclarationName:TypedErrorsWithRaise.kt$FruitBasketBuilder + +