Skip to content

Instantly share code, notes, and snippets.

@realdadfish
Created March 30, 2020 21:17
Show Gist options
  • Save realdadfish/3bc3a0b568ad56f64cbe7d7452020219 to your computer and use it in GitHub Desktop.
Save realdadfish/3bc3a0b568ad56f64cbe7d7452020219 to your computer and use it in GitHub Desktop.
Detekt configuration
#
# This file configures the static code analysis done by Detekt (https://arturbosch.github.io/detekt/index.html)
#
# Derivations from the defaults (https://github.com/arturbosch/detekt/blob/master/detekt-cli/src/main/resources/default-detekt-config.yml)
# are not listed here, unless we specifically voted on a rule to be used / not used.
#
# If adaptions to a default rule are made, the _complete_ configuration of that rule should be included here, not
# only the part that is actually overridden. This is important to see the rule in context.
#
# If you want to introduce changes to existing rules and / or want to introduce new rules, please use the
# Handheld Sync as a forum to propose these, ideally accompanied with a MR that would show the consequences
# of the rule adaption.
#
build:
maxIssues: 0
excludeCorrectable: false
weights:
# complexity: 2
# LongParameterList: 1
# style: 1
# comments: 1
config:
validation: true
# when writing own rules with new properties, exclude the property path e.g.: "my_rule_set,.*>.*>[my_property]"
excludes: ""
processors:
active: true
exclude:
- 'DetektProgressListener'
# - 'FunctionCountProcessor'
# - 'PropertyCountProcessor'
# - 'ClassCountProcessor'
# - 'PackageCountProcessor'
# - 'KtFileCountProcessor'
console-reports:
active: true
exclude:
- 'ProjectStatisticsReport'
- 'ComplexityReport'
- 'NotificationReport'
# - 'FindingsReport'
- 'FileBasedFindingsReport'
# voted on 2020-03-29
# comment checking left out - https://arturbosch.github.io/detekt/comments.html
comments:
active: false
complexity:
ComplexInterface:
active: false # voted on 2020-03-29
threshold: 10
includeStaticDeclarations: false
LabeledExpression:
active: true
ignoredLabels: ""
MethodOverloading:
active: false # voted on 2020-03-29
threshold: 3
StringLiteralDuplication:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
threshold: 3
ignoreAnnotation: true
excludeStringsWithLessThan5Characters: true
ignoreStringsRegex: '$^'
LongMethod:
active: true
threshold: 60 # voted on 2020-03-29
LongParameterList:
active: false # disabled because voted-on parameters only exist in Detekt 1.7.1 onwards which is still unstable
#functionThreshold: 6 # voted on 2020-03-29
#constructorThreshold: 10 # voted on 2020-03-29
ignoreDefaultParameters: false
#ignoreDataClasses: true
TooManyFunctions:
active: true
excludes: '**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt'
thresholdInFiles: 11
thresholdInClasses: 11
thresholdInInterfaces: 11
thresholdInObjects: 11
thresholdInEnums: 11
ignoreDeprecated: false
ignorePrivate: true # voted on 2020-03-29
ignoreOverridden: false
# voted on 2020-03-29
# couroutine checking left out - https://arturbosch.github.io/detekt/coroutines.html
coroutines:
active: false
exceptions:
ExceptionRaisedInUnexpectedLocation:
active: true
methodNames: 'toString,hashCode,equals,finalize'
InstanceOfCheckForException:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
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
ThrowingExceptionsWithoutMessageOrCause:
active: true
exceptions: 'IllegalArgumentException,IllegalStateException,IOException'
ThrowingNewInstanceOfSameException:
active: true
naming:
FunctionMaxLength:
active: true
maximumFunctionNameLength: 60 # voted on 2020-03-29
FunctionMinLength:
active: true
minimumFunctionNameLength: 3 # voted on 2020-03-29
FunctionNaming:
active: true
excludes: '**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt'
functionPattern: '^[a-z][a-zA-Z0-9]*$' # voted on 2020-03-29
excludeClassPattern: '$^'
ignoreOverridden: true
InvalidPackageDeclaration:
active: false
rootPackage: 'de.db.mt'
PackageNaming:
active: true
excludes: '**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt'
packagePattern: '^[a-z]+(\.[a-z0-9]*)*$' # voted on 2020-03-29
VariableMaxLength:
active: true
maximumVariableNameLength: 64
performance:
active: true
SpreadOperator:
active: false # voted on 2020-03-29
excludes: '**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt'
potential-bugs:
active: true
Deprecation:
active: true
HasPlatformType:
active: true
ImplicitDefaultLocale:
active: true
LateinitUsage:
active: false
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludeAnnotatedProperties: ""
ignoreOnClassesPattern: ""
MapGetWithNotNullAssertionOperator:
active: true
UnconditionalJumpStatementInLoop:
active: true
UnsafeCast:
active: true
UselessPostfixExpression:
active: true
style:
active: true
CollapsibleIfStatements:
active: true
DataClassContainsFunctions:
active: false # voted on 2020-03-29
DataClassShouldBeImmutable:
active: false
EqualsOnSignatureLine:
active: true
ExpressionBodySyntax:
includeLineWrapping: true
ForbiddenComment:
active: false # voted on 2020-03-29
values: 'FIXME:,STOPSHIP:,TODO:' # https://arturbosch.github.io/detekt/style.html#forbiddencomment
ForbiddenImport:
active: false
imports: '' # https://arturbosch.github.io/detekt/style.html#forbiddenimport
forbiddenPatterns: ''
ForbiddenMethodCall:
active: false
methods: '' # https://arturbosch.github.io/detekt/style.html#forbiddenmethodcall
ForbiddenVoid:
active: true
MagicNumber:
ignoreEnums: true
MaxLineLength:
active: false # checked by ktlint
NestedClassesVisibility:
active: true
NewLineAtEndOfFile:
active: false # checked by ktlint, configured for the opposite
OptionalUnit:
active: true
OptionalWhenBraces:
active: false # voted on 2020-03-29
RedundantExplicitType:
active: true
RedundantVisibilityModifierRule:
active: true
ReturnCount:
active: true
max: 3 # voted on 2020-03-29
excludedFunctions: 'equals'
excludeLabeled: false
excludeReturnFromLambda: true
excludeGuardClauses: false
SerialVersionUIDInSerializableClass:
active: true
ThrowsCount:
active: false # voted on 2020-03-29
max: 2
UnderscoresInNumericLiterals:
active: false # voted on 2020-03-29
acceptableDecimalLength: 5
UnnecessaryAnnotationUseSiteTarget:
active: true
UnnecessaryApply:
active: false # voted on 2020-03-29
UnnecessaryLet:
active: true
UnnecessaryParentheses:
active: true
UntilInsteadOfRangeTo:
active: true
UnusedPrivateMember:
active: true
allowedNames: "(_|ignored|expected|serialVersionUID)"
UseArrayLiteralsInAnnotations:
active: true
UseCheckOrError:
active: true
UseDataClass:
active: false # voted on 2020-03-29
excludeAnnotatedClasses: ""
allowVars: false
UseIfInsteadOfWhen:
active: true
UseRequire:
active: true
VarCouldBeVal:
active: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment