Skip to content

Instantly share code, notes, and snippets.

@mrsasha
Created December 18, 2019 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrsasha/27b5cd8d10e5f6b1b94797a38788d61c to your computer and use it in GitHub Desktop.
Save mrsasha/27b5cd8d10e5f6b1b94797a38788d61c to your computer and use it in GitHub Desktop.
detekt setup for 1.2.2 version
build:
maxIssues: 0
comments:
active: true
excludes: "**/*Test.kt, **/*Spec.kt"
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
complexity:
active: true
ComplexCondition:
active: true
threshold: 4
ComplexInterface:
active: false
threshold: 10
includeStaticDeclarations: false
ComplexMethod:
active: true
threshold: 10
ignoreSingleWhenExpression: false
LabeledExpression:
active: false
LargeClass:
active: true
excludes: "**/*Test.kt, **/*Spec.kt"
threshold: 180
LongMethod:
active: true
threshold: 31
LongParameterList:
active: true
threshold: 6
ignoreDefaultParameters: false
MethodOverloading:
active: true
threshold: 6
NestedBlockDepth:
active: true
threshold: 4
StringLiteralDuplication:
active: false
threshold: 3
ignoreAnnotation: true
excludeStringsWithLessThan5Characters: true
ignoreStringsRegex: '$^'
TooManyFunctions:
active: true
excludes: "**/*Test.kt, **/*Spec.kt"
thresholdInFiles: 15
thresholdInClasses: 15
thresholdInInterfaces: 15
thresholdInObjects: 15
thresholdInEnums: 11
ignoreDeprecated: false
ignorePrivate: 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
ignoreOverriddenFunctions: false
EmptyIfBlock:
active: true
EmptyInitBlock:
active: true
EmptyKtFile:
active: true
EmptySecondaryConstructor:
active: true
EmptyWhenBlock:
active: true
EmptyWhileBlock:
active: true
exceptions:
active: true
ExceptionRaisedInUnexpectedLocation:
active: false
methodNames: 'toString,hashCode,equals,finalize'
InstanceOfCheckForException:
active: false
NotImplementedDeclaration:
active: false
PrintStackTrace:
active: false
RethrowCaughtException:
active: false
ReturnFromFinally:
active: false
SwallowedException:
active: false
ThrowingExceptionFromFinally:
active: false
ThrowingExceptionInMain:
active: false
ThrowingExceptionsWithoutMessageOrCause:
active: true
exceptions: 'IllegalArgumentException,IllegalStateException,IOException'
ThrowingNewInstanceOfSameException:
active: true
TooGenericExceptionCaught:
active: false
TooGenericExceptionThrown:
active: true
exceptionNames:
- Error
- Exception
- Throwable
- RuntimeException
formatting:
active: true
android: true
AnnotationOnSeparateLine:
active: true
ChainWrapping:
active: true
CommentSpacing:
active: false
Filename:
active: true
FinalNewline:
active: true
ImportOrdering:
active: true
Indentation:
active: true
indentSize: 4
continuationIndentSize: 4
MaximumLineLength:
active: true
maxLineLength: 160
ModifierOrdering:
active: true
NoBlankLineBeforeRbrace:
active: true
NoConsecutiveBlankLines:
active: true
NoEmptyClassBody:
active: true
NoLineBreakAfterElse:
active: true
NoLineBreakBeforeAssignment:
active: true
NoMultipleSpaces:
active: true
NoSemicolons:
active: true
NoTrailingSpaces:
active: true
NoUnitReturn:
active: true
NoUnusedImports:
active: true
NoWildcardImports:
active: true
PackageName:
active: true
ParameterListWrapping:
active: true
indentSize: 4
SpacingAroundColon:
active: true
SpacingAroundComma:
active: true
SpacingAroundCurly:
active: true
SpacingAroundDot:
active: true
SpacingAroundKeyword:
active: true
SpacingAroundOperators:
active: true
SpacingAroundParens:
active: true
SpacingAroundRangeOperator:
active: true
StringTemplate:
active: true
naming:
active: true
ClassNaming:
active: true
classPattern: '[A-Z$][a-zA-Z0-9$]*'
ConstructorParameterNaming:
active: true
EnumNaming:
active: true
enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*'
ForbiddenClassName:
active: false
forbiddenName: ''
FunctionMaxLength:
active: true
maximumFunctionNameLength: 36
FunctionMinLength:
active: true
minimumFunctionNameLength: 3
FunctionNaming:
active: true
functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
excludeClassPattern: '$^'
FunctionParameterNaming:
active: true
InvalidPackageDeclaration:
active: true
MatchingDeclarationName:
active: false
MemberNameEqualsClassName:
active: false
ignoreOverriddenFunction: true
ObjectPropertyNaming:
active: true
propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
constantPattern: '[A-Za-z][_A-Za-z0-9]*'
PackageNaming:
active: true
packagePattern: '^[a-z]+(\.[a-z][a-z0-9]*)*$'
TopLevelPropertyNaming:
active: true
constantPattern: '[A-Z][_A-Z0-9]*'
propertyPattern: '[a-z][A-Za-z\d]*'
privatePropertyPattern: '(_)?[a-z][A-Za-z0-9]*'
VariableMaxLength:
active: true
maximumVariableNameLength: 36
VariableMinLength:
active: true
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
ForEachOnRange:
active: true
SpreadOperator:
active: false
UnnecessaryTemporaryInstantiation:
active: true
potential-bugs:
active: true
Deprecation:
active: true
DuplicateCaseInWhenExpression:
active: true
EqualsAlwaysReturnsTrueOrFalse:
active: true
EqualsWithHashCodeExist:
active: true
ExplicitGarbageCollectionCall:
active: true
HasPlatformType:
active: true
ImplicitDefaultLocale:
active: true
InvalidRange:
active: true
IteratorHasNextCallsNextMethod:
active: true
IteratorNotThrowingNoSuchElementException:
active: true
LateinitUsage:
active: false
excludeAnnotatedProperties: ""
ignoreOnClassesPattern: ""
MissingWhenCase:
active: true
RedundantElseInWhen:
active: true
UnconditionalJumpStatementInLoop:
active: true
UnreachableCode:
active: true
UnsafeCallOnNullableType:
active: false
UnsafeCast:
active: false
UselessPostfixExpression:
active: true
WrongEqualsTypeParameter:
active: true
style:
active: true
CollapsibleIfStatements:
active: false # TODO
DataClassContainsFunctions:
active: true
conversionFunctionPrefix: 'to'
DataClassShouldBeImmutable:
active: false # TODO
EqualsNullCall:
active: true
EqualsOnSignatureLine:
active: true
ExplicitItLambdaParameter:
active: true
ExpressionBodySyntax:
active: false # TODO
includeLineWrapping: false
ForbiddenComment:
active: true
values: 'STOPSHIP'
ForbiddenImport:
active: false
imports: ''
ForbiddenVoid:
active: true
FunctionOnlyReturningConstant:
active: true
ignoreOverridableFunction: true
excludedFunctions: 'describeContents'
LibraryCodeMustSpecifyReturnType:
active: true
LoopWithTooManyJumpStatements:
active: true
maxJumpCount: 1
MagicNumber:
active: true
excludes: "**/*Test.kt, **/*Spec.kt"
ignoreNumbers: '-1,0,1,2'
ignoreHashCodeFunction: true
ignorePropertyDeclaration: false
ignoreConstantDeclaration: true
ignoreCompanionObjectPropertyDeclaration: true
ignoreAnnotation: false
ignoreNamedArgument: true
ignoreEnums: true
MandatoryBracesIfStatements:
active: false # TODO
MaxLineLength:
active: true
maxLineLength: 160
excludePackageStatements: false
excludeImportStatements: false
excludeCommentStatements: false
MayBeConst:
active: true
excludes: "**/*Test.kt, **/*Spec.kt"
ModifierOrder:
active: true
NestedClassesVisibility:
active: true
NewLineAtEndOfFile:
active: true
NoTabs:
active: true
OptionalAbstractKeyword:
active: true
OptionalUnit:
active: false
OptionalWhenBraces:
active: false # TODO
PreferToOverPairSyntax:
active: false
ProtectedMemberInFinalClass:
active: true
RedundantExplicitType:
active: true
RedundantVisibilityModifierRule:
active: true
ReturnCount:
active: false # TODO
max: 2
excludedFunctions: "equals"
SafeCast:
active: true
SerialVersionUIDInSerializableClass:
active: false
SpacingBetweenPackageAndImports:
active: true
ThrowsCount:
active: true
max: 2
TrailingWhitespace:
active: true
UnderscoresInNumericLiterals:
active: true
UnnecessaryAbstractClass:
active: true
UnnecessaryApply:
active: true
UnnecessaryInheritance:
active: true
UnnecessaryLet:
active: true
UnnecessaryParentheses:
active: true
UntilInsteadOfRangeTo:
active: true
UnusedImports:
active: true
UnusedPrivateClass:
active: true
UnusedPrivateMember:
active: true
allowedNames: "(_|ignored|expected)"
UseArrayLiteralsInAnnotations:
active: true
UseCheckOrError:
active: true
UseDataClass:
active: false # TODO
excludeAnnotatedClasses: ""
UseIfInsteadOfWhen:
active: false # TODO
UseRequire:
active: true
UselessCallOnNotNull:
active: true
UtilityClassWithPublicConstructor:
active: true
VarCouldBeVal:
active: true
WildcardImport:
active: false
excludes: "**/*Test.kt, **/*Spec.kt"
excludeImports: 'kotlinx.android.synthetic.*'
apply plugin: 'io.gitlab.arturbosch.detekt'
//TODO nuclear option!!!
//dependencies {
// detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:${Versions.detekt}"
//}
detekt {
config = files("../scripts/detekt-config.yml")
parallel = true
reports {
xml {
enabled = true
destination = file("build/reports/detekt/detekt.xml")
}
html {
enabled = true
destination = file("build/reports/detekt/detekt.html")
}
txt {
enabled = false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment