diff --git a/gradle/commonStaticAnalysis.gradle b/gradle/commonStaticAnalysis.gradle index 764a10a..3f272c2 100644 --- a/gradle/commonStaticAnalysis.gradle +++ b/gradle/commonStaticAnalysis.gradle @@ -403,12 +403,17 @@ getKotlinDetektTask = { isAndroidProject -> main = "io.gitlab.arturbosch.detekt.cli.Main" classpath = configurations.detekt def input = "${rootDir}" - def output = "${project.buildDir}/reports/kotlin-detekt.xml" + def output = "${project.buildDir}/reports" + def outputName = "kotlin-detekt" def config = "${rootDir}/libraries/BuildScripts/kotlin/detekt-config.yml" // TODO add excludes from rootProject.extensions.findByName("staticAnalysisExcludes") def filters = ".*src/test.*,.*/resources/.*,.*/tmp/.*" - def params = ['-i', input, '-o', output, '-c', config, '-f', filters] + def params = ['-i', input, + '-o', output, + '-c', config, + '-f', filters, + '--output-name', outputName] args(params) } return taskName @@ -437,6 +442,5 @@ dependencies { pngtastic 'com.github.depsypher:pngtastic:1.2' - detekt 'io.gitlab.arturbosch.detekt:detekt-cli:1.0.0.M13.2' - detekt 'io.gitlab.arturbosch.detekt:detekt-formatting:1.0.0.M13.2' + detekt 'io.gitlab.arturbosch.detekt:detekt-cli:1.0.0.RC6-2' } diff --git a/kotlin/detekt-config.yml b/kotlin/detekt-config.yml index 3a384cf..757c24a 100644 --- a/kotlin/detekt-config.yml +++ b/kotlin/detekt-config.yml @@ -1,4 +1,5 @@ autoCorrect: true +failFast: false build: warningThreshold: 1 @@ -9,20 +10,215 @@ build: LongParameterList: 1 comments: 0.5 -potential-bugs: +processors: active: true - DuplicateCaseInWhenExpression: - active: true - EqualsWithHashCodeExist: - active: true - ExplicitGarbageCollectionCall: - active: true - LateinitUsage: + exclude: + # - 'FunctionCountProcessor' + # - 'PropertyCountProcessor' + # - 'ClassCountProcessor' + # - 'PackageCountProcessor' + # - 'KtFileCountProcessor' + +console-reports: + active: true + exclude: + # - 'ProjectStatisticsReport' + # - 'ComplexityReport' + # - 'NotificationReport' + # - 'FindingsReport' + # - 'BuildFailureReport' + +output-reports: + active: true + exclude: + - 'PlainOutputReport' + - 'HtmlOutputReport' + +comments: + active: false + CommentOverPrivateFunction: active: false - UnsafeCallOnNullableType: + CommentOverPrivateProperty: active: false - UnsafeCast: + 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: 5 + ComplexInterface: + active: false + threshold: 10 + includeStaticDeclarations: false + ComplexMethod: + active: true + threshold: 10 + LabeledExpression: + active: true + LargeClass: + active: true + threshold: 800 + LongMethod: + active: true + threshold: 40 + LongParameterList: + active: true + threshold: 10 + ignoreDefaultParameters: false + MethodOverloading: + active: false + threshold: 5 + NestedBlockDepth: + active: true + threshold: 3 + StringLiteralDuplication: + active: true + threshold: 3 + ignoreAnnotation: true + excludeStringsWithLessThan5Characters: true + ignoreStringsRegex: '$^' + TooManyFunctions: + active: true + thresholdInFiles: 20 + thresholdInClasses: 20 + thresholdInInterfaces: 20 + thresholdInObjects: 20 + thresholdInEnums: 20 + +empty-blocks: + active: true + EmptyCatchBlock: + active: true + EmptyClassBlock: + active: true + EmptyDefaultConstructor: + active: false + EmptyDoWhileBlock: + active: true + EmptyElseBlock: + active: true + EmptyFinallyBlock: + active: true + EmptyForBlock: + active: true + EmptyFunctionBlock: + active: true + EmptyIfBlock: + active: true + EmptyInitBlock: + active: true + EmptyKtFile: + active: true + EmptySecondaryConstructor: + active: true + EmptyWhenBlock: + active: true + EmptyWhileBlock: + active: true + +exceptions: + active: true + ExceptionRaisedInUnexpectedLocation: + active: true + methodNames: 'toString,hashCode,equals,finalize' + InstanceOfCheckForException: + active: false + NotImplementedDeclaration: + active: true + PrintStackTrace: + active: true + RethrowCaughtException: + active: false + ReturnFromFinally: + active: false + SwallowedException: + active: false + ThrowingExceptionFromFinally: + active: false + ThrowingExceptionInMain: + active: false + ThrowingExceptionsWithoutMessageOrCause: + active: true + exceptions: 'IllegalArgumentException,IllegalStateException,IOException' + ThrowingNewInstanceOfSameException: + active: false + TooGenericExceptionCaught: + active: true + exceptions: + - ArrayIndexOutOfBoundsException + - Error + - Exception + - IllegalMonitorStateException + - NullPointerException + - IndexOutOfBoundsException + - RuntimeException + - Throwable + TooGenericExceptionThrown: + active: true + exceptions: + - Error + - Exception + - NullPointerException + - Throwable + - RuntimeException + +naming: + active: true + ClassNaming: + active: true + classPattern: '^[A-Z][a-zA-Z0-9]*$' + 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 + functionPattern: '^[a-z][a-z0-9][a-zA-Z0-9_]*$' + MatchingDeclarationName: + active: true + MemberNameEqualsClassName: + active: false + ignoreOverriddenFunction: true + ObjectPropertyNaming: + active: true + propertyPattern: '[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]*(_[A-Z0-9]+)*$' + propertyPattern: '^[a-z][a-z0-9][a-zA-Z0-9]*$' + privatePropertyPattern: '^[a-z][a-z0-9][a-zA-Z0-9]*$' + VariableMaxLength: + active: false + maximumVariableNameLength: 64 + VariableMinLength: + active: false + minimumVariableNameLength: 1 + VariableNaming: + active: true + variablePattern: '^[a-z][a-z0-9][a-zA-Z0-9]*$' + privateVariablePattern: '^[a-z][a-z0-9][a-zA-Z0-9]*$' performance: active: true @@ -30,113 +226,127 @@ performance: active: true SpreadOperator: active: true + UnnecessaryTemporaryInstantiation: + active: true -exceptions: - active: false - -empty-blocks: +potential-bugs: active: true - -complexity: - active: true - LongMethod: - threshold: 40 - LongParameterList: - threshold: 10 - LargeClass: - threshold: 800 - ComplexMethod: - threshold: 10 - TooManyFunctions: - threshold: 20 - ComplexCondition: - threshold: 6 - -code-smell: - active: true - FeatureEnvy: - threshold: 0.5 - weight: 0.45 - base: 0.5 - -formatting: - active: true - useTabs: true - Indentation: + DuplicateCaseInWhenExpression: + active: true + EqualsAlwaysReturnsTrueOrFalse: active: false - indentSize: 4 - ConsecutiveBlankLines: + EqualsWithHashCodeExist: active: true - autoCorrect: false - MultipleSpaces: + ExplicitGarbageCollectionCall: active: true - autoCorrect: true - SpacingAfterComma: + InvalidRange: active: true - autoCorrect: true - SpacingAfterKeyword: + IteratorHasNextCallsNextMethod: + active: false + IteratorNotThrowingNoSuchElementException: + active: false + LateinitUsage: + active: false + excludeAnnotatedProperties: "" + ignoreOnClassesPattern: "" + UnconditionalJumpStatementInLoop: + active: false + UnreachableCode: active: true - autoCorrect: true - SpacingAroundColon: - active: true - autoCorrect: true - SpacingAroundCurlyBraces: - active: true - autoCorrect: true - SpacingAroundOperator: - active: true - autoCorrect: true - TrailingSpaces: - active: true - autoCorrect: true - UnusedImports: - active: true - autoCorrect: true - OptionalSemicolon: - active: true - autoCorrect: true - OptionalUnit: - active: true - autoCorrect: true - ExpressionBodySyntax: - active: true - autoCorrect: false - ExpressionBodySyntaxLineBreaks: - active: true - autoCorrect: false - OptionalReturnKeyword: - active: true - autoCorrect: false + UnsafeCallOnNullableType: + active: false + UnsafeCast: + active: false + UselessPostfixExpression: + active: false + WrongEqualsTypeParameter: + active: false style: active: true - NewLineAtEndOfFile: + CollapsibleIfStatements: active: false + DataClassContainsFunctions: + active: false + conversionFunctionPrefix: 'to' + EqualsNullCall: + active: false + ExpressionBodySyntax: + active: true ForbiddenComment: active: true values: 'STOPSHIP:' - WildcardImport: - active: true + ForbiddenImport: + active: false + imports: '' + FunctionOnlyReturningConstant: + active: false + ignoreOverridableFunction: true + excludedFunctions: 'describeContents' + LoopWithTooManyJumpStatements: + active: false + maxJumpCount: 1 + MagicNumber: + active: false + ignoreNumbers: '-1,0,1,2' + ignoreHashCodeFunction: false + ignorePropertyDeclaration: true + ignoreConstantDeclaration: true + ignoreCompanionObjectPropertyDeclaration: true + ignoreAnnotation: true + ignoreNamedArgument: true + ignoreEnums: true MaxLineLength: active: true maxLineLength: 150 excludePackageStatements: false excludeImportStatements: false - NamingConventionViolation: + ModifierOrder: active: true - variablePattern: '^[a-z][a-z0-9][a-zA-Z0-9]*$' - constantPattern: '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$' - methodPattern: '^[a-z][a-z0-9][a-zA-Z0-9_]*$' - classPattern: '^[A-Z][a-zA-Z0-9]*$' - enumEntryPattern: '^[A-Z][a-zA-Z0-9_]*$' - -comments: - active: false - CommentOverPrivateMethod: + NestedClassesVisibility: active: false - CommentOverPrivateProperty: + NewLineAtEndOfFile: active: false - UndocumentedPublicClass: + OptionalAbstractKeyword: + active: true + OptionalReturnKeyword: + active: true + OptionalUnit: + active: true + OptionalWhenBraces: active: false - UndocumentedPublicFunction: - active: false \ No newline at end of file + ProtectedMemberInFinalClass: + active: false + RedundantVisibilityModifierRule: + active: false + ReturnCount: + active: true + max: 3 + excludedFunctions: "equals" + SafeCast: + active: true + SerialVersionUIDInSerializableClass: + active: false + SpacingBetweenPackageAndImports: + active: true + ThrowsCount: + active: true + max: 3 + UnnecessaryAbstractClass: + active: false + UnnecessaryInheritance: + active: false + UnnecessaryParentheses: + active: false + UntilInsteadOfRangeTo: + active: true + UnusedImports: + active: true + UseDataClass: + active: true + excludeAnnotatedClasses: "" + UtilityClassWithPublicConstructor: + active: false + WildcardImport: + active: true + excludeImports: 'java.util.*,kotlinx.android.synthetic.*' \ No newline at end of file