diff --git a/.github/workflows/pr_checks.yml b/.github/workflows/pr_checks.yml index bb192f490..088741c95 100644 --- a/.github/workflows/pr_checks.yml +++ b/.github/workflows/pr_checks.yml @@ -42,23 +42,3 @@ jobs: with: path: ./**/build/reports/jacoco key: ${{ runner.os }}-unit-${{ env.GITHUB_SHA }} - upload-code-coverage: - runs-on: ubuntu-latest - needs: - - unit - steps: - - uses: actions/checkout@v2 - - name: Cache Coverage Results - uses: actions/cache@v2 - with: - path: ./**/build/reports/jacoco - key: ${{ runner.os }}-unit-${{ env.GITHUB_SHA }} - - name: Cache Coverage Results - uses: actions/cache@v2 - with: - path: ./**/build/reports/jacoco - key: ${{ runner.os }}-integration-${{ env.GITHUB_SHA }} - - name: Publish code coverage to Codacy - uses: codacy/codacy-coverage-reporter-action@v1 - with: - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ad66e1a7..e76183402 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [1.9.1] - October 17th, 2021 + +### Changed + +- Code Coverage removed from PR checks due to limitations with GitHub workflows +- Minor linting fixes +- Detekt now builds off of default config + ## [1.9.0] - october 15th, 2021 ### Added diff --git a/build.gradle.kts b/build.gradle.kts index 20369e274..2ee5d6f3b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("org.jetbrains.kotlin.jvm") version "1.5.31" apply false - id("io.gitlab.arturbosch.detekt") version "1.17.0-RC3" apply false + id("io.gitlab.arturbosch.detekt") version "1.18.1" apply false id("com.adarshr.test-logger") version "3.0.0" apply false id("io.github.gradle-nexus.publish-plugin") version "1.1.0" apply true } @@ -53,6 +53,7 @@ allprojects { toolVersion = "0.8.7" } + @Suppress("MagicNumber") configure { theme = ThemeType.MOCHA setLogLevel("lifecycle") @@ -73,7 +74,7 @@ allprojects { } configure { - toolVersion = "1.17.0-RC3" + toolVersion = "1.18.1" config = files("${rootProject.projectDir}/detekt.yml") buildUponDefaultConfig = true } diff --git a/detekt.yml b/detekt.yml index e7350691a..21bea2069 100644 --- a/detekt.yml +++ b/detekt.yml @@ -1,710 +1,20 @@ -build: - maxIssues: 0 - excludeCorrectable: false - weights: - # complexity: 2 - # LongParameterList: 1 - # style: 1 - # comments: 1 - -config: - validation: true - warningsAsErrors: 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' - -console-reports: - active: true - exclude: - - 'ProjectStatisticsReport' - - 'ComplexityReport' - - 'NotificationReport' - - 'FileBasedFindingsReport' - -output-reports: - active: true - -comments: - active: true - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - AbsentOrWrongFileLicense: - active: false - licenseTemplateFile: 'license.template' - CommentOverPrivateFunction: - active: false - CommentOverPrivateProperty: - active: false - EndOfSentenceFormat: - active: false - endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)' - UndocumentedPublicClass: - active: false - searchInNestedClass: true - searchInInnerClass: true - searchInInnerObject: true - searchInInnerInterface: true - UndocumentedPublicFunction: - active: false - UndocumentedPublicProperty: - active: false - complexity: - active: true - ComplexCondition: - active: true - threshold: 4 - ComplexInterface: + TooManyFunctions: active: false - threshold: 10 - includeStaticDeclarations: false - includePrivateDeclarations: false - ComplexMethod: - active: true - threshold: 25 - ignoreSingleWhenExpression: false - ignoreSimpleWhenEntries: false - ignoreNestingFunctions: false - nestingFunctions: [run, let, apply, with, also, use, forEach, isNotNull, ifNull] - LabeledExpression: - active: false - ignoredLabels: [] - LargeClass: - active: true - threshold: 600 - LongMethod: - active: true - threshold: 80 LongParameterList: active: true functionThreshold: 10 constructorThreshold: 10 - ignoreDefaultParameters: false - ignoreDataClasses: true - ignoreAnnotated: [] - MethodOverloading: - active: false - threshold: 6 - NamedArguments: - active: false - threshold: 3 - NestedBlockDepth: - active: true - threshold: 6 - ReplaceSafeCallChainWithRun: - active: false - StringLiteralDuplication: - active: false - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - threshold: 3 - ignoreAnnotation: true - excludeStringsWithLessThan5Characters: true - ignoreStringsRegex: '$^' - TooManyFunctions: - active: false - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - thresholdInFiles: 11 - thresholdInClasses: 11 - thresholdInInterfaces: 11 - thresholdInObjects: 11 - thresholdInEnums: 11 - ignoreDeprecated: false - ignorePrivate: false - ignoreOverridden: false - -coroutines: - active: true - GlobalCoroutineUsage: - active: false - RedundantSuspendModifier: - active: false - SleepInsteadOfDelay: - active: false - SuspendFunWithFlowReturnType: - active: false - -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: [toString, hashCode, equals, finalize] - InstanceOfCheckForException: - active: false - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - NotImplementedDeclaration: - active: false - ObjectExtendsThrowable: - active: false - PrintStackTrace: - active: true - RethrowCaughtException: - active: true - ReturnFromFinally: - active: true - ignoreLabeled: false - SwallowedException: - active: true - ignoredExceptionTypes: - - InterruptedException - - NumberFormatException - - ParseException - - MalformedURLException - allowedExceptionNameRegex: '_|(ignore|expected).*' - ThrowingExceptionFromFinally: - active: true - ThrowingExceptionInMain: - active: false - ThrowingExceptionsWithoutMessageOrCause: - active: true - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - exceptions: - - IllegalArgumentException - - IllegalStateException - - IOException - ThrowingNewInstanceOfSameException: - active: true - TooGenericExceptionCaught: - active: true - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - exceptionNames: - - ArrayIndexOutOfBoundsException - - Error - - Exception - - IllegalMonitorStateException - - NullPointerException - - IndexOutOfBoundsException - - RuntimeException - - Throwable - allowedExceptionNameRegex: '_|(ignore|expected).*' - TooGenericExceptionThrown: - active: true - exceptionNames: - - Error - - Exception - - Throwable - - RuntimeException - + ComplexMethod: + threshold: 20 formatting: - active: true - android: false - autoCorrect: true - AnnotationOnSeparateLine: - active: false - autoCorrect: true - AnnotationSpacing: - active: false - autoCorrect: true - ArgumentListWrapping: - active: false - autoCorrect: true - ChainWrapping: - active: true - autoCorrect: true - CommentSpacing: - active: true - autoCorrect: true - EnumEntryNameCase: - active: false - autoCorrect: true - Filename: - active: true - FinalNewline: - active: true - autoCorrect: true - insertFinalNewLine: true - ImportOrdering: - active: false - autoCorrect: true - layout: 'idea' - Indentation: - active: false - autoCorrect: true - indentSize: 4 - continuationIndentSize: 4 - MaximumLineLength: - active: true - maxLineLength: 120 - ModifierOrdering: - active: true - autoCorrect: true - MultiLineIfElse: - active: true - autoCorrect: true - NoBlankLineBeforeRbrace: - active: true - autoCorrect: true - NoConsecutiveBlankLines: - active: true - autoCorrect: true - NoEmptyClassBody: - active: true - autoCorrect: true - NoEmptyFirstLineInMethodBlock: - active: false - autoCorrect: true - NoLineBreakAfterElse: - active: true - autoCorrect: true - NoLineBreakBeforeAssignment: - active: true - autoCorrect: true - NoMultipleSpaces: - active: true - autoCorrect: true - NoSemicolons: - active: true - autoCorrect: true - NoTrailingSpaces: - active: true - autoCorrect: true - NoUnitReturn: - active: true - autoCorrect: true - NoUnusedImports: - active: true - autoCorrect: true - NoWildcardImports: - active: true - PackageName: - active: true - autoCorrect: true ParameterListWrapping: active: false - autoCorrect: true - indentSize: 4 - SpacingAroundAngleBrackets: - active: false - autoCorrect: true - SpacingAroundColon: - active: true - autoCorrect: true - SpacingAroundComma: - active: true - autoCorrect: true - SpacingAroundCurly: - active: true - autoCorrect: true - SpacingAroundDot: - active: true - autoCorrect: true - SpacingAroundDoubleColon: - active: false - autoCorrect: true - SpacingAroundKeyword: - active: true - autoCorrect: true - SpacingAroundOperators: - active: true - autoCorrect: true - SpacingAroundParens: - active: true - autoCorrect: true - SpacingAroundRangeOperator: - active: true - autoCorrect: true - SpacingAroundUnaryOperator: - active: false - autoCorrect: true - SpacingBetweenDeclarationsWithAnnotations: - active: false - autoCorrect: true - SpacingBetweenDeclarationsWithComments: - active: false - autoCorrect: true - StringTemplate: - active: true - autoCorrect: true - -naming: - active: true - ClassNaming: - active: true - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - classPattern: '[A-Z][a-zA-Z0-9]*' - ConstructorParameterNaming: - active: false - excludes: ['**/test/**', '**/testIntegration/**', '**/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/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - enumEntryPattern: '[A-Z][_a-zA-Z0-9]*' - ForbiddenClassName: - active: false - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - forbiddenName: [] - FunctionMaxLength: - active: false - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - maximumFunctionNameLength: 30 - FunctionMinLength: - active: false - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - minimumFunctionNameLength: 3 - FunctionNaming: - active: true - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - functionPattern: '([a-z][a-zA-Z0-9]*)|(`.*`)' - excludeClassPattern: '$^' - ignoreOverridden: true - ignoreAnnotated: ['Composable'] - FunctionParameterNaming: - active: true - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - parameterPattern: '[a-z][A-Za-z0-9]*' - excludeClassPattern: '$^' - ignoreOverridden: true - InvalidPackageDeclaration: - active: false - excludes: ['*.kts'] - rootPackage: '' - MatchingDeclarationName: - active: true - mustBeFirst: true - MemberNameEqualsClassName: - active: true - ignoreOverridden: true - NonBooleanPropertyPrefixedWithIs: - active: false - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - ObjectPropertyNaming: - active: true - excludes: ['**/test/**', '**/testIntegration/**', '**/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/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*' - TopLevelPropertyNaming: - active: true - excludes: ['**/test/**', '**/testIntegration/**', '**/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/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - maximumVariableNameLength: 64 - VariableMinLength: - active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - minimumVariableNameLength: 1 - VariableNaming: - active: true - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - variablePattern: '[a-z][A-Za-z0-9]*' - privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' - excludeClassPattern: '$^' - ignoreOverridden: true - -performance: - active: true - ArrayPrimitive: - active: true - ForEachOnRange: - active: true - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - SpreadOperator: - active: true - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - UnnecessaryTemporaryInstantiation: - active: true - -potential-bugs: - active: true - Deprecation: - active: false - DontDowncastCollectionTypes: - active: false - DuplicateCaseInWhenExpression: - active: true - EqualsAlwaysReturnsTrueOrFalse: - active: true - EqualsWithHashCodeExist: - active: true - ExitOutsideMain: - active: false - ExplicitGarbageCollectionCall: - active: true - HasPlatformType: - active: false - IgnoredReturnValue: - active: false - restrictToAnnotatedMethods: true - returnValueAnnotations: ['*.CheckReturnValue', '*.CheckResult'] - ImplicitDefaultLocale: - active: true - ImplicitUnitReturnType: - active: false - allowExplicitReturnType: true - InvalidRange: - active: true - IteratorHasNextCallsNextMethod: - active: true - IteratorNotThrowingNoSuchElementException: - active: true - LateinitUsage: - active: false - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - excludeAnnotatedProperties: [] - ignoreOnClassesPattern: '' - MapGetWithNotNullAssertionOperator: - active: false - MissingWhenCase: - active: true - allowElseExpression: true - NullableToStringCall: - active: false - RedundantElseInWhen: - active: true - UnconditionalJumpStatementInLoop: - active: false - UnnecessaryNotNullOperator: - active: true - UnnecessarySafeCall: - active: true - UnreachableCatchBlock: - active: false - UnreachableCode: - active: true - UnsafeCallOnNullableType: - active: true - UnsafeCast: - active: true - UselessPostfixExpression: - active: false - WrongEqualsTypeParameter: - active: true - style: - active: true - ClassOrdering: - active: false - CollapsibleIfStatements: - active: false - DataClassContainsFunctions: - active: false - conversionFunctionPrefix: 'to' - DataClassShouldBeImmutable: - active: false - DestructuringDeclarationWithTooManyEntries: - active: false - maxDestructuringEntries: 3 - EqualsNullCall: - active: true - EqualsOnSignatureLine: - active: false - ExplicitCollectionElementAccessMethod: - active: false - ExplicitItLambdaParameter: - active: false - ExpressionBodySyntax: - active: false - includeLineWrapping: false - ForbiddenComment: - active: true - values: ['TODO:', 'FIXME:', 'STOPSHIP:'] - allowedPatterns: '' - ForbiddenImport: - active: false - imports: [] - forbiddenPatterns: '' - ForbiddenMethodCall: - active: false - methods: ['kotlin.io.println', 'kotlin.io.print'] - ForbiddenPublicDataClass: - active: true - excludes: ['**'] - ignorePackages: ['*.internal', '*.internal.*'] - ForbiddenVoid: - active: false - ignoreOverridden: false - ignoreUsageInGenerics: false - FunctionOnlyReturningConstant: - active: true - ignoreOverridableFunction: true - ignoreActualFunction: true - excludedFunctions: 'describeContents' - excludeAnnotatedFunction: ['dagger.Provides'] - LibraryCodeMustSpecifyReturnType: - active: true - excludes: ['**'] - LibraryEntitiesShouldNotBePublic: - active: true - excludes: ['**'] - LoopWithTooManyJumpStatements: - active: true - maxJumpCount: 1 - MagicNumber: - active: true - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - 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 - MandatoryBracesIfStatements: - active: false - MandatoryBracesLoops: - active: false MaxLineLength: + excludes: ['**/test/**/*', '**/testIntegration/**/*'] active: true maxLineLength: 120 - excludePackageStatements: true - excludeImportStatements: true - excludeCommentStatements: false - MayBeConst: - active: true - ModifierOrder: - active: true - MultilineLambdaItParameter: +naming: + ConstructorParameterNaming: active: false - NestedClassesVisibility: - active: true - NewLineAtEndOfFile: - active: true - NoTabs: - active: false - OptionalAbstractKeyword: - active: true - OptionalUnit: - active: false - OptionalWhenBraces: - active: false - PreferToOverPairSyntax: - active: false - ProtectedMemberInFinalClass: - active: true - RedundantExplicitType: - active: false - RedundantHigherOrderMapUsage: - active: false - 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 - ThrowsCount: - active: true - max: 2 - TrailingWhitespace: - active: false - UnderscoresInNumericLiterals: - active: false - acceptableDecimalLength: 5 - UnnecessaryAbstractClass: - active: true - excludeAnnotatedClasses: ['dagger.Module'] - UnnecessaryAnnotationUseSiteTarget: - active: false - UnnecessaryApply: - active: true - UnnecessaryFilter: - active: false - UnnecessaryInheritance: - active: true - UnnecessaryLet: - active: false - UnnecessaryParentheses: - active: false - UntilInsteadOfRangeTo: - active: false - UnusedImports: - active: false - UnusedPrivateClass: - active: true - UnusedPrivateMember: - active: true - allowedNames: '(_|ignored|expected|serialVersionUID)' - UseArrayLiteralsInAnnotations: - active: false - UseCheckNotNull: - active: false - UseCheckOrError: - active: false - UseDataClass: - active: false - excludeAnnotatedClasses: [] - allowVars: false - UseEmptyCounterpart: - active: false - UseIfEmptyOrIfBlank: - active: false - UseIfInsteadOfWhen: - active: false - UseIsNullOrEmpty: - active: false - UseRequire: - active: false - UseRequireNotNull: - active: false - UselessCallOnNotNull: - active: true - UtilityClassWithPublicConstructor: - active: true - VarCouldBeVal: - active: true - WildcardImport: - active: true - excludes: ['**/test/**', '**/testIntegration/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - excludeImports: ['java.util.*', 'kotlinx.android.synthetic.*'] diff --git a/gradle.properties b/gradle.properties index b5650987d..970b0cd2c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Kompendium -project.version=1.9.0 +project.version=1.9.1 # Kotlin kotlin.code.style=official # Gradle diff --git a/kompendium-core/src/main/kotlin/io/bkbn/kompendium/Kompendium.kt b/kompendium-core/src/main/kotlin/io/bkbn/kompendium/Kompendium.kt index 101585a1c..831d90608 100644 --- a/kompendium-core/src/main/kotlin/io/bkbn/kompendium/Kompendium.kt +++ b/kompendium-core/src/main/kotlin/io/bkbn/kompendium/Kompendium.kt @@ -46,5 +46,4 @@ object Kompendium { ) { PathCalculator.addCustomRouteHandler(selector, handler) } - } diff --git a/kompendium-core/src/main/kotlin/io/bkbn/kompendium/KompendiumPreFlight.kt b/kompendium-core/src/main/kotlin/io/bkbn/kompendium/KompendiumPreFlight.kt index cf028c319..982da3586 100644 --- a/kompendium-core/src/main/kotlin/io/bkbn/kompendium/KompendiumPreFlight.kt +++ b/kompendium-core/src/main/kotlin/io/bkbn/kompendium/KompendiumPreFlight.kt @@ -1,9 +1,7 @@ package io.bkbn.kompendium import io.ktor.routing.Route -import kotlin.reflect.KClass import kotlin.reflect.KType -import kotlin.reflect.full.createType import kotlin.reflect.typeOf /** diff --git a/kompendium-core/src/main/kotlin/io/bkbn/kompendium/Kontent.kt b/kompendium-core/src/main/kotlin/io/bkbn/kompendium/Kontent.kt index df8a309d4..88f1057f6 100644 --- a/kompendium-core/src/main/kotlin/io/bkbn/kompendium/Kontent.kt +++ b/kompendium-core/src/main/kotlin/io/bkbn/kompendium/Kontent.kt @@ -8,7 +8,6 @@ import io.bkbn.kompendium.models.oas.DictionarySchema import io.bkbn.kompendium.models.oas.EnumSchema import io.bkbn.kompendium.models.oas.FormatSchema import io.bkbn.kompendium.models.oas.ObjectSchema -import io.bkbn.kompendium.models.oas.OpenApiSpecComponentSchema import io.bkbn.kompendium.models.oas.ReferencedSchema import io.bkbn.kompendium.models.oas.SimpleSchema import io.bkbn.kompendium.util.Helpers.COMPONENT_SLUG @@ -16,6 +15,9 @@ import io.bkbn.kompendium.util.Helpers.genericNameAdapter import io.bkbn.kompendium.util.Helpers.getReferenceSlug import io.bkbn.kompendium.util.Helpers.getSimpleSlug import io.bkbn.kompendium.util.Helpers.logged +import org.slf4j.LoggerFactory +import java.math.BigDecimal +import java.math.BigInteger import java.util.UUID import kotlin.reflect.KClass import kotlin.reflect.KType @@ -24,9 +26,6 @@ import kotlin.reflect.full.isSubclassOf import kotlin.reflect.full.memberProperties import kotlin.reflect.jvm.javaField import kotlin.reflect.typeOf -import org.slf4j.LoggerFactory -import java.math.BigDecimal -import java.math.BigInteger /** * Responsible for generating the schema map that is used to power all object references across the API Spec. @@ -142,6 +141,8 @@ object Kontent { * @param clazz Class of the object to analyze * @param cache Existing schema map to append to */ + // TODO Fix as part of this issue https://github.com/bkbnio/kompendium/issues/80 + @Suppress("LongMethod", "ComplexMethod") private fun handleComplexType(type: KType, clazz: KClass<*>, cache: SchemaMap): SchemaMap { // This needs to be simple because it will be stored under it's appropriate reference component implicitly val slug = type.getSimpleSlug() @@ -280,7 +281,7 @@ object Kontent { ReferencedSchema(("$COMPONENT_SLUG/${it.getSimpleSlug()}")) }) } - false -> ReferencedSchema("${COMPONENT_SLUG}/${collectionClass.simpleName}") + false -> ReferencedSchema("$COMPONENT_SLUG/${collectionClass.simpleName}") } val schema = ArraySchema(items = valueReference) val updatedCache = generateKontent(collectionType, cache) diff --git a/kompendium-core/src/main/kotlin/io/bkbn/kompendium/Notarized.kt b/kompendium-core/src/main/kotlin/io/bkbn/kompendium/Notarized.kt index 724ba21a6..dd3945ec0 100644 --- a/kompendium-core/src/main/kotlin/io/bkbn/kompendium/Notarized.kt +++ b/kompendium-core/src/main/kotlin/io/bkbn/kompendium/Notarized.kt @@ -112,5 +112,4 @@ object Notarized { info.parseErrorInfo(errorType, responseType) exception(handler) } - } diff --git a/kompendium-core/src/main/kotlin/io/bkbn/kompendium/models/oas/OpenApiSpecComponentSchema.kt b/kompendium-core/src/main/kotlin/io/bkbn/kompendium/models/oas/OpenApiSpecComponentSchema.kt index 89069198e..a54733bda 100644 --- a/kompendium-core/src/main/kotlin/io/bkbn/kompendium/models/oas/OpenApiSpecComponentSchema.kt +++ b/kompendium-core/src/main/kotlin/io/bkbn/kompendium/models/oas/OpenApiSpecComponentSchema.kt @@ -1,7 +1,6 @@ package io.bkbn.kompendium.models.oas sealed class OpenApiSpecComponentSchema(open val default: Any? = null) { - fun addDefault(default: Any?): OpenApiSpecComponentSchema = when (this) { is AnyOfReferencedSchema -> error("Cannot add default to anyOf reference") is ReferencedSchema -> this.copy(default = default) @@ -12,7 +11,6 @@ sealed class OpenApiSpecComponentSchema(open val default: Any? = null) { is FormatSchema -> this.copy(default = default) is ArraySchema -> this.copy(default = default) } - } sealed class TypedSchema(open val type: String, override val default: Any? = null) : OpenApiSpecComponentSchema(default) diff --git a/kompendium-core/src/test/kotlin/io/bkbn/kompendium/util/TestModels.kt b/kompendium-core/src/test/kotlin/io/bkbn/kompendium/util/TestModels.kt index f0002f690..d7ee55224 100644 --- a/kompendium-core/src/test/kotlin/io/bkbn/kompendium/util/TestModels.kt +++ b/kompendium-core/src/test/kotlin/io/bkbn/kompendium/util/TestModels.kt @@ -95,7 +95,7 @@ data class AnothaJamma(val b: Float) : SlammaJamma sealed interface Flibbity -data class Gibbity(val a: T): Flibbity +data class Gibbity(val a: T) : Flibbity data class Bibbity(val b: String, val f: T) : Flibbity enum class Hehe {