From b43d1c5d2405242adf470b49e6968dce2e09540a Mon Sep 17 00:00:00 2001 From: Sebastiano Poggi Date: Sat, 13 Jan 2018 20:34:28 +0000 Subject: [PATCH 1/2] Update Detekt 1.0.0.RC6 -> 1.0.0.RC6-2 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7fd64715..0d7e614f 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { } plugins { - id 'io.gitlab.arturbosch.detekt' version '1.0.0.RC6' + id 'io.gitlab.arturbosch.detekt' version '1.0.0.RC6-2' } def teamPropsFile(propsFile) { From c7ed028d1939f7b4ea0fcc73d424179c8a397d70 Mon Sep 17 00:00:00 2001 From: Sebastiano Poggi Date: Sat, 13 Jan 2018 20:34:42 +0000 Subject: [PATCH 2/2] Update Detekt rules for RC6-2 --- team-props/static-analysis/detekt-config.yml | 361 ++++++++++--------- 1 file changed, 182 insertions(+), 179 deletions(-) diff --git a/team-props/static-analysis/detekt-config.yml b/team-props/static-analysis/detekt-config.yml index 99fa4195..74ecac3f 100644 --- a/team-props/static-analysis/detekt-config.yml +++ b/team-props/static-analysis/detekt-config.yml @@ -16,6 +16,8 @@ test-pattern: # Configure exclusions for test sources - 'MaxLineLength' - 'LateinitUsage' - 'StringLiteralDuplication' + - 'SpreadOperator' + - 'TooManyFunctions' build: warningThreshold: 1 @@ -51,93 +53,63 @@ output-reports: # - 'PlainOutputReport' # - 'XmlOutputReport' -potential-bugs: +comments: active: true - DuplicateCaseInWhenExpression: - active: true - EqualsAlwaysReturnsTrueOrFalse: - active: false - EqualsWithHashCodeExist: - active: true - InvalidLoopCondition: - active: false - WrongEqualsTypeParameter: - active: false - IteratorHasNextCallsNextMethod: - active: false - ExplicitGarbageCollectionCall: + CommentOverPrivateFunction: active: true - UnconditionalJumpStatementInLoop: - active: false - IteratorNotThrowingNoSuchElementException: - active: false - UnreachableCode: + CommentOverPrivateProperty: active: true - LateinitUsage: - active: false - excludeAnnotatedProperties: '' - ignoreOnClassesPattern: '' - UnsafeCallOnNullableType: - active: false - UnsafeCast: + UndocumentedPublicClass: active: false - UselessPostfixExpression: + searchInNestedClass: true + searchInInnerClass: true + searchInInnerObject: true + searchInInnerInterface: true + UndocumentedPublicFunction: active: false -performance: +complexity: active: true - ForEachOnRange: + LongParameterList: active: true - SpreadOperator: + threshold: 5 + ignoreDefaultParameters: false + LongMethod: active: true - UnnecessaryTemporaryInstantiation: + threshold: 20 + LargeClass: active: true - -exceptions: - active: true - ExceptionRaisedInUnexpectedLocation: - active: false - methodNames: 'toString,hashCode,equals,finalize' - SwallowedException: + threshold: 150 + ComplexInterface: active: false - TooGenericExceptionCaught: - active: true - exceptions: - - ArrayIndexOutOfBoundsException - - Error - - Exception - - IllegalMonitorStateException - - IndexOutOfBoundsException - # - InterruptedException - - NullPointerException - - RuntimeException - - Throwable - TooGenericExceptionThrown: + threshold: 10 + includeStaticDeclarations: false + ComplexMethod: active: true - exceptions: - - Error - - Exception - - NullPointerException - - RuntimeException - - Throwable - InstanceOfCheckForException: - active: false - NotImplementedDeclaration: - active: false - ThrowingExceptionsWithoutMessageOrCause: - active: false - exceptions: 'IllegalArgumentException,IllegalStateException,IOException' - PrintStackTrace: - active: false - RethrowCaughtException: - active: false - ReturnFromFinally: + threshold: 10 + StringLiteralDuplication: active: false - ThrowingExceptionFromFinally: + threshold: 2 + ignoreAnnotation: true + excludeStringsWithLessThan5Characters: true + ignoreStringsRegex: '$^' + MethodOverloading: active: false - ThrowingExceptionInMain: + threshold: 5 + NestedBlockDepth: + active: true + threshold: 3 + TooManyFunctions: active: false - ThrowingNewInstanceOfSameException: + thresholdInFiles: 10 + thresholdInClasses: 10 + thresholdInInterfaces: 10 + thresholdInObjects: 10 + thresholdInEnums: 10 + ComplexCondition: + active: true + threshold: 3 + LabeledExpression: active: false empty-blocks: @@ -171,106 +143,155 @@ empty-blocks: EmptyWhileBlock: active: true -complexity: +exceptions: active: true - LongMethod: + SwallowedException: + active: false + TooGenericExceptionCaught: active: true - threshold: 20 - NestedBlockDepth: + exceptions: + - ArrayIndexOutOfBoundsException + - Error + - Exception + - IllegalMonitorStateException + - NullPointerException + - IndexOutOfBoundsException + - RuntimeException + - Throwable + ExceptionRaisedInUnexpectedLocation: + active: false + methodNames: 'toString,hashCode,equals,finalize' + TooGenericExceptionThrown: active: true - threshold: 3 - LongParameterList: + exceptions: + - Error + - Exception + - NullPointerException + - Throwable + - RuntimeException + NotImplementedDeclaration: + active: false + PrintStackTrace: + active: false + InstanceOfCheckForException: + active: false + ThrowingExceptionsWithoutMessageOrCause: + active: false + exceptions: 'IllegalArgumentException,IllegalStateException,IOException' + ReturnFromFinally: + active: false + ThrowingExceptionFromFinally: + active: false + ThrowingExceptionInMain: + active: false + RethrowCaughtException: + active: false + ThrowingNewInstanceOfSameException: + active: false + SwallowedException: + active: false + +performance: + active: true + ForEachOnRange: active: true - threshold: 5 - LargeClass: + SpreadOperator: active: true - threshold: 150 - ComplexInterface: + UnnecessaryTemporaryInstantiation: + active: true + +potential-bugs: + active: true + DuplicateCaseInWhenExpression: + active: true + EqualsAlwaysReturnsTrueOrFalse: active: false - threshold: 10 - includeStaticDeclarations: false - ComplexMethod: + EqualsWithHashCodeExist: active: true - threshold: 10 - MethodOverloading: + IteratorNotThrowingNoSuchElementException: active: false - threshold: 5 - TooManyFunctions: + IteratorHasNextCallsNextMethod: active: false - threshold: 10 - ComplexCondition: + UselessPostfixExpression: + active: false + InvalidRange: + active: false + WrongEqualsTypeParameter: + active: false + ExplicitGarbageCollectionCall: active: true - threshold: 3 - LabeledExpression: + LateinitUsage: active: false - StringLiteralDuplication: + excludeAnnotatedProperties: "" + ignoreOnClassesPattern: "" + UnconditionalJumpStatementInLoop: + active: false + UnreachableCode: + active: true + UnsafeCallOnNullableType: + active: false + UnsafeCast: active: false - threshold: 2 - ignoreAnnotation: true - excludeStringsWithLessThan5Characters: true - ignoreStringsRegex: '$^' - -code-smell: - active: true - FeatureEnvy: - threshold: 0.5 - weight: 0.45 - base: 0.5 style: active: true + CollapsibleIfStatements: + active: false ReturnCount: active: false max: 2 + excludedFunctions: "equals" ThrowsCount: active: true max: 2 NewLineAtEndOfFile: active: true - OptionalAbstractKeyword: + WildcardImport: active: true - OptionalWhenBraces: - active: false - CollapsibleIfStatements: - active: false + excludeImports: 'kotlinx.android.synthetic.*' + MaxLineLength: + active: true + maxLineLength: 150 + excludePackageStatements: false + excludeImportStatements: false EqualsNullCall: active: false ForbiddenComment: active: true - values: 'STOPSHIP:' + values: 'STOPSHIP' ForbiddenImport: active: false imports: '' - PackageDeclarationStyle: + FunctionOnlyReturningConstant: + active: false + ignoreOverridableFunction: true + excludedFunctions: 'describeContents' + SpacingBetweenPackageAndImports: active: false LoopWithTooManyJumpStatements: active: false maxJumpCount: 1 - MethodNameEqualsClassName: + MemberNameEqualsClassName: active: false ignoreOverriddenFunction: true - ModifierOrder: - active: true - MagicNumber: - active: true - ignoreNumbers: '-1,0,1,2' - ignoreHashCodeFunction: false - ignorePropertyDeclaration: false - ignoreConstantDeclaration: true - ignoreCompanionObjectPropertyDeclaration: true - ignoreAnnotation: false - ignoreNamedArgument: true - ignoreEnums: false - WildcardImport: + VariableNaming: active: true - excludeImports: 'kotlinx.android.synthetic.*' - SafeCast: + variablePattern: '[a-z][a-zA-Z$0-9]*' + privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' + VariableMinLength: + active: false + minimumVariableNameLength: 1 + VariableMaxLength: + active: false + maximumVariableNameLength: 64 + TopLevelPropertyNaming: active: true - MaxLineLength: + constantPattern: '[A-Z][_A-Z0-9]*' + propertyPattern: '[a-z][A-Za-z\d]*' + privatePropertyPattern: '(_)?[a-z][A-Za-z0-9]*' + ObjectPropertyNaming: active: true - maxLineLength: 150 - excludePackageStatements: false - excludeImportStatements: false + propertyPattern: '[A-Za-z][_A-Za-z0-9]*' PackageNaming: active: true packagePattern: '^[a-z]+(\.[a-z][a-z0-9]*)*$' @@ -289,24 +310,12 @@ style: FunctionMinLength: active: false minimumFunctionNameLength: 3 - VariableNaming: - active: true - variablePattern: '^(_)?[a-z$][a-zA-Z$0-9]*$' - ConstantNaming: - active: true - constantPattern: '^([A-Z_]*|serialVersionUID)$' - VariableMaxLength: - active: false - maximumVariableNameLength: 30 - VariableMinLength: - active: false - minimumVariableNameLength: 3 ForbiddenClassName: active: false forbiddenName: '' - ProtectedMemberInFinalClass: + SafeCast: active: true - SerialVersionUIDInSerializableClass: + UnnecessaryAbstractClass: active: false UnnecessaryParentheses: active: false @@ -314,50 +323,44 @@ style: active: false UtilityClassWithPublicConstructor: active: false - DataClassContainsFunctions: - active: false - conversionFunctionPrefix: 'to' - UseDataClass: + OptionalAbstractKeyword: + active: true + OptionalWhenBraces: active: false - UnnecessaryAbstractClass: + OptionalReturnKeyword: active: false OptionalUnit: active: false - OptionalReturnKeyword: + ProtectedMemberInFinalClass: + active: true + SerialVersionUIDInSerializableClass: active: false - ExpressionBodySyntax: + MagicNumber: + active: true + ignoreNumbers: '-1,0,1,2' + ignoreHashCodeFunction: false + ignorePropertyDeclaration: false + ignoreConstantDeclaration: true + ignoreCompanionObjectPropertyDeclaration: true + ignoreAnnotation: false + ignoreNamedArgument: true + ignoreEnums: false + ModifierOrder: + active: true + DataClassContainsFunctions: + active: false + conversionFunctionPrefix: 'to' + UseDataClass: active: false UnusedImports: active: false + ExpressionBodySyntax: + active: false NestedClassesVisibility: active: false RedundantVisibilityModifierRule: active: false - FunctionOnlyReturningConstant: + MatchingDeclarationName: active: false - ignoreOverridableFunction: true - excludedFunctions: 'describeContents' - -comments: - active: true - CommentOverPrivateFunction: - active: true - CommentOverPrivateProperty: - active: true - UndocumentedPublicClass: - active: false - searchInNestedClass: true - searchInInnerClass: true - searchInInnerObject: true - searchInInnerInterface: true - UndocumentedPublicFunction: + UntilInsteadOfRangeTo: active: false - -# *experimental feature* -# Migration rules can be defined in the same config file or a new one -migration: - active: false - imports: - # your.package.Class: new.package.or.Class - # for example: - # io.gitlab.arturbosch.detekt.api.Rule: io.gitlab.arturbosch.detekt.rule.Rule