From 973ef9db4660d860e823e8fdf145858a320c7b16 Mon Sep 17 00:00:00 2001 From: Victor Smirnov Date: Sun, 17 Mar 2024 14:21:07 +0300 Subject: [PATCH] #4 [setup] Setup detekt most evil rules --- .editorconfig | 2 + config/detekt.yml | 226 ++++++++++++++++++ .../lms/gateway/api/http/MonitoringHttpApi.kt | 5 +- .../lms/gateway/GatewayApplicationTests.kt | 4 +- 4 files changed, 233 insertions(+), 4 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..15cdff3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,2 @@ +[*.{kt,kts}] +ktlint_code_style = intellij_idea diff --git a/config/detekt.yml b/config/detekt.yml index b106b36..193aa0b 100644 --- a/config/detekt.yml +++ b/config/detekt.yml @@ -1,3 +1,229 @@ config: validation: true warningsAsErrors: true + +comments: + CommentOverPrivateFunction: + active: true + CommentOverPrivateProperty: + active: true + DeprecatedBlockTag: + active: true + EndOfSentenceFormat: + active: true + KDocReferencesNonPublicProperty: + active: true + OutdatedDocumentation: + active: true + +complexity: + CognitiveComplexMethod: + active: true + threshold: 12 + ComplexInterface: + active: true + threshold: 8 + CyclomaticComplexMethod: + active: true + threshold: 12 + LabeledExpression: + active: true + LargeClass: + active: true + threshold: 400 + LongMethod: + active: true + threshold: 30 + LongParameterList: + active: true + functionThreshold: 3 + constructorThreshold: 4 + MethodOverloading: + active: true + NamedArguments: + active: true + threshold: 2 + ignoreArgumentsMatchingNames: true + NestedScopeFunctions: + active: true + StringLiteralDuplication: + active: true + TooManyFunctions: + active: true + thresholdInFiles: 8 + thresholdInClasses: 8 + thresholdInInterfaces: 8 + thresholdInObjects: 8 + thresholdInEnums: 8 + +coroutines: + GlobalCoroutineUsage: + active: true + SuspendFunSwallowedCancellation: + active: true + SuspendFunWithCoroutineScopeReceiver: + active: true + +exceptions: + ObjectExtendsThrowable: + active: true + +naming: + BooleanPropertyNaming: + active: true + FunctionMinLength: + active: true + minimumFunctionNameLength: 3 + FunctionMaxLength: + active: true + maximumFunctionNameLength: 30 + LambdaParameterNaming: + active: true + NonBooleanPropertyPrefixedWithIs: + active: true + VariableMinLength: + active: true + minimumVariableNameLength: 1 + VariableMaxLength: + active: true + maximumVariableNameLength: 20 + +performance: + CouldBeSequence: + active: true + threshold: 2 + UnnecessaryPartOfBinaryExpression: + active: true + +potential-bugs: + CastNullableToNonNullableType: + active: true + CastToNullableType: + active: true + Deprecation: + active: true + DontDowncastCollectionTypes: + active: true + ElseCaseInsteadOfExhaustiveWhen: + active: true + ExitOutsideMain: + active: true + ImplicitUnitReturnType: + active: true + LateinitUsage: + active: true + MissingPackageDeclaration: + active: true + NullCheckOnMutableProperty: + active: true + NullableToStringCall: + active: true + PropertyUsedBeforeDeclaration: + active: true + UnconditionalJumpStatementInLoop: + active: true + UnnecessaryNotNullCheck: + active: true + +style: + AlsoCouldBeApply: + active: true + BracesOnIfStatements: + active: true + singleLine: always + multiLine: always + BracesOnWhenStatements: + active: true + singleLine: never + multiLine: always + CanBeNonNullable: + active: true + CascadingCallWrapping: + active: true + ClassOrdering: + active: true + CollapsibleIfStatements: + active: true + DataClassContainsFunctions: + active: true + DataClassShouldBeImmutable: + active: true + DoubleNegativeLambda: + active: true + EqualsOnSignatureLine: + active: true + ExplicitCollectionElementAccessMethod: + active: true + ExpressionBodySyntax: + active: true + includeLineWrapping: true + ForbiddenAnnotation: + active: true + ForbiddenImport: + active: true + ForbiddenMethodCall: + active: true + ForbiddenSuppress: + active: true + MandatoryBracesLoops: + active: true + MaxChainedCallsOnSameLine: + active: true + maxChainedCalls: 3 + MaxLineLength: + active: true + maxLineLength: 80 + MultilineLambdaItParameter: + active: true + MultilineRawStringIndentation: + active: true + NoTabs: + active: true + NullableBooleanCheck: + active: true + OptionalUnit: + active: true + PreferToOverPairSyntax: + active: true + RedundantExplicitType: + active: true + RedundantVisibilityModifierRule: + active: true + SpacingBetweenPackageAndImports: + active: true + StringShouldBeRawString: + active: true + TrailingWhitespace: + active: true + TrimMultilineRawString: + active: true + UnderscoresInNumericLiterals: + active: true + UnnecessaryAnnotationUseSiteTarget: + active: true + UnnecessaryBackticks: + active: true + UnnecessaryBracesAroundTrailingLambda: + active: true + UnnecessaryInnerClass: + active: true + UnnecessaryLet: + active: true + UnnecessaryParentheses: + active: true + UntilInsteadOfRangeTo: + active: true + UnusedImports: + active: true + UseDataClass: + active: true + UseEmptyCounterpart: + active: true + UseIfEmptyOrIfBlank: + active: true + UseIfInsteadOfWhen: + active: true + UseLet: + active: true + UseSumOfInsteadOfFlatMapSize: + active: true diff --git a/gateway/src/main/kotlin/ru/itmo/lms/gateway/api/http/MonitoringHttpApi.kt b/gateway/src/main/kotlin/ru/itmo/lms/gateway/api/http/MonitoringHttpApi.kt index cd260e9..2187504 100644 --- a/gateway/src/main/kotlin/ru/itmo/lms/gateway/api/http/MonitoringHttpApi.kt +++ b/gateway/src/main/kotlin/ru/itmo/lms/gateway/api/http/MonitoringHttpApi.kt @@ -6,7 +6,6 @@ import ru.itmo.lms.gateway.api.http.apis.MonitoringApi @RestController class MonitoringHttpApi : MonitoringApi { - override suspend fun monitoringPingGet(): ResponseEntity { - return ResponseEntity.ok("pong") - } + override suspend fun monitoringPingGet(): ResponseEntity = + ResponseEntity.ok("pong") } diff --git a/gateway/src/test/kotlin/ru/itmo/lms/gateway/GatewayApplicationTests.kt b/gateway/src/test/kotlin/ru/itmo/lms/gateway/GatewayApplicationTests.kt index 677de27..5431a9e 100644 --- a/gateway/src/test/kotlin/ru/itmo/lms/gateway/GatewayApplicationTests.kt +++ b/gateway/src/test/kotlin/ru/itmo/lms/gateway/GatewayApplicationTests.kt @@ -6,5 +6,7 @@ import org.springframework.boot.test.context.SpringBootTest @SpringBootTest class GatewayApplicationTests { @Test - fun contextLoads() = Unit + fun contextLoads() { + // Do nothing + } }