diff --git a/src/python/review/inspectors/detekt/detekt.py b/src/python/review/inspectors/detekt/detekt.py index 7460880e..ab5af4ab 100644 --- a/src/python/review/inspectors/detekt/detekt.py +++ b/src/python/review/inspectors/detekt/detekt.py @@ -13,9 +13,9 @@ logger = logging.getLogger(__name__) PATH_TOOLS_PMD_FILES = Path(__file__).parent / 'files' -PATH_DETEKT_JAR = PATH_TOOLS_PMD_FILES / 'detekt-cli-1.8.0-all.jar' +PATH_DETEKT_JAR = PATH_TOOLS_PMD_FILES / 'detekt-cli-1.14.2-all.jar' PATH_DETEKT_CONFIG = PATH_TOOLS_PMD_FILES / 'detekt-config.yml' -PATH_DETEKT_PLUGIN = PATH_TOOLS_PMD_FILES / 'detekt-formatting-1.5.1.jar' +PATH_DETEKT_PLUGIN = PATH_TOOLS_PMD_FILES / 'detekt-formatting-1.14.2.jar' class DetektInspector(BaseInspector): diff --git a/src/python/review/inspectors/detekt/files/detekt-cli-1.8.0-all.jar b/src/python/review/inspectors/detekt/files/detekt-cli-1.14.2-all.jar similarity index 80% rename from src/python/review/inspectors/detekt/files/detekt-cli-1.8.0-all.jar rename to src/python/review/inspectors/detekt/files/detekt-cli-1.14.2-all.jar index bdf8d3f1..fba9b869 100644 Binary files a/src/python/review/inspectors/detekt/files/detekt-cli-1.8.0-all.jar and b/src/python/review/inspectors/detekt/files/detekt-cli-1.14.2-all.jar differ diff --git a/src/python/review/inspectors/detekt/files/detekt-config.yml b/src/python/review/inspectors/detekt/files/detekt-config.yml index fec64e95..950bc7b4 100644 --- a/src/python/review/inspectors/detekt/files/detekt-config.yml +++ b/src/python/review/inspectors/detekt/files/detekt-config.yml @@ -1,52 +1,59 @@ +# This config was created based on the default config for Detekt 1.18.0 +# using the following table: https://bit.ly/2V2kCyi + +# Some inspections have been commented out due to problems with upgrading to version 1.18.0. +# The current config contains only those inspections that work on version 1.14.2. + build: maxIssues: 0 excludeCorrectable: false weights: - # complexity: 2 - # LongParameterList: 1 - # style: 1 - # comments: 1 + # 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: "" + warningsAsErrors: false + # when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]' + excludes: '' processors: active: true exclude: - 'DetektProgressListener' + # - 'KtFileCountProcessor' + # - 'PackageCountProcessor' + # - 'ClassCountProcessor' # - 'FunctionCountProcessor' # - 'PropertyCountProcessor' - # - 'ClassCountProcessor' - # - 'PackageCountProcessor' - # - 'KtFileCountProcessor' console-reports: active: true exclude: - - 'ProjectStatisticsReport' - - 'ComplexityReport' - - 'NotificationReport' - # - 'FindingsReport' - - 'FileBasedFindingsReport' + - 'ProjectStatisticsReport' + - 'ComplexityReport' + - 'NotificationReport' + # - 'FindingsReport' + - 'FileBasedFindingsReport' + +# TODO: Uncomment inspections when upgrading Detekt to version 1.18.0+. Don't forget to uncomment them in issue_types. comments: - active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + active: false + AbsentOrWrongFileLicense: + active: false CommentOverPrivateFunction: active: false CommentOverPrivateProperty: active: false +# DeprecatedBlockTag: +# active: false EndOfSentenceFormat: active: false - endOfSentenceFormat: ([.?!][ \t\n\r\f<])|([.?!:]$) UndocumentedPublicClass: active: false - searchInNestedClass: true - searchInInnerClass: true - searchInInnerObject: true - searchInInnerInterface: true UndocumentedPublicFunction: active: false UndocumentedPublicProperty: @@ -59,18 +66,14 @@ complexity: threshold: 0 ComplexInterface: active: false - threshold: 10 - includeStaticDeclarations: false ComplexMethod: active: true threshold: 0 ignoreSingleWhenExpression: true ignoreSimpleWhenEntries: true ignoreNestingFunctions: false - nestingFunctions: run,let,apply,with,also,use,forEach,isNotNull,ifNull LabeledExpression: active: false - ignoredLabels: "" LargeClass: active: true threshold: 600 @@ -79,45 +82,38 @@ complexity: threshold: 0 LongParameterList: active: true - threshold: 6 - ignoreDefaultParameters: false MethodOverloading: active: false - threshold: 6 +# NamedArguments: +# active: false NestedBlockDepth: active: true threshold: 4 + ReplaceSafeCallChainWithRun: + active: false StringLiteralDuplication: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - threshold: 3 - ignoreAnnotation: true - excludeStringsWithLessThan5Characters: true - ignoreStringsRegex: '$^' TooManyFunctions: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" thresholdInFiles: 21 thresholdInClasses: 21 - thresholdInInterfaces: 11 thresholdInObjects: 21 - thresholdInEnums: 11 - ignoreDeprecated: false - ignorePrivate: false - ignoreOverridden: false coroutines: - active: true + active: false GlobalCoroutineUsage: active: false RedundantSuspendModifier: active: false +# SleepInsteadOfDelay: +# active: false + SuspendFunWithFlowReturnType: + active: false empty-blocks: active: true EmptyCatchBlock: active: true - allowedExceptionNameRegex: "^(_|(ignore|expected).*)" EmptyClassBlock: active: true EmptyDefaultConstructor: @@ -132,7 +128,6 @@ empty-blocks: active: true EmptyFunctionBlock: active: true - ignoreOverridden: false EmptyIfBlock: active: true EmptyInitBlock: @@ -141,6 +136,8 @@ empty-blocks: active: true EmptySecondaryConstructor: active: true + EmptyTryBlock: + active: true EmptyWhenBlock: active: true EmptyWhileBlock: @@ -149,53 +146,33 @@ empty-blocks: exceptions: active: true ExceptionRaisedInUnexpectedLocation: - active: false - methodNames: 'toString,hashCode,equals,finalize' + active: true InstanceOfCheckForException: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" NotImplementedDeclaration: active: false +# ObjectExtendsThrowable: +# active: false PrintStackTrace: active: false RethrowCaughtException: - active: false + active: true ReturnFromFinally: active: true - ignoreLabeled: false SwallowedException: active: false - ignoredExceptionTypes: 'InterruptedException,NumberFormatException,ParseException,MalformedURLException' - allowedExceptionNameRegex: "^(_|(ignore|expected).*)" ThrowingExceptionFromFinally: active: true ThrowingExceptionInMain: active: false ThrowingExceptionsWithoutMessageOrCause: active: true - exceptions: 'IllegalArgumentException,IllegalStateException,IOException' ThrowingNewInstanceOfSameException: active: false TooGenericExceptionCaught: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - exceptionNames: - - ArrayIndexOutOfBoundsException - - Error - - Exception - - IllegalMonitorStateException - - NullPointerException - - IndexOutOfBoundsException - - RuntimeException - - Throwable - allowedExceptionNameRegex: "^(_|(ignore|expected).*)" TooGenericExceptionThrown: active: false - exceptionNames: - - Error - - Exception - - Throwable - - RuntimeException formatting: active: true @@ -203,197 +180,138 @@ formatting: autoCorrect: false AnnotationOnSeparateLine: active: false - autoCorrect: true + AnnotationSpacing: + active: false + ArgumentListWrapping: + active: false ChainWrapping: active: true - autoCorrect: true CommentSpacing: active: true - autoCorrect: true EnumEntryNameCase: active: true - autoCorrect: true Filename: active: false - # duplicated by NewLineAtEndOfFile + # Duplicated by NewLineAtEndOfFile FinalNewline: active: false - autoCorrect: true ImportOrdering: active: true - autoCorrect: true Indentation: active: true - autoCorrect: true - indentSize: 4 - continuationIndentSize: 4 - # duplicated by MaxLineLength + # Duplicated by MaxLineLength MaximumLineLength: active: false - maxLineLength: 120 - # duplicated by ModifierOrder + # Duplicated by ModifierOrder ModifierOrdering: active: false - autoCorrect: true MultiLineIfElse: active: true - autoCorrect: true NoBlankLineBeforeRbrace: active: false - autoCorrect: true NoConsecutiveBlankLines: active: true - autoCorrect: true - # duplicated by EmptyClassBlock + # Duplicated by EmptyClassBlock NoEmptyClassBody: active: false - autoCorrect: true NoEmptyFirstLineInMethodBlock: active: false - autoCorrect: true NoLineBreakAfterElse: active: true - autoCorrect: true NoLineBreakBeforeAssignment: active: true - autoCorrect: true NoMultipleSpaces: active: true - autoCorrect: true NoSemicolons: active: true - autoCorrect: true - # duplicated by TrailingWhitespace + # Duplicated by TrailingWhitespace NoTrailingSpaces: active: false - autoCorrect: true - # duplicated by OptionalUnit + # Duplicated by OptionalUnit NoUnitReturn: active: false - autoCorrect: true - # duplicated by UnusedImports + # Duplicated by UnusedImports NoUnusedImports: active: false - autoCorrect: true - # duplicated by WildcardImport + # Duplicated by WildcardImport NoWildcardImports: active: false - # duplicated by PackageNaming + # Duplicated by PackageNaming PackageName: active: false - autoCorrect: true ParameterListWrapping: active: true - autoCorrect: true - indentSize: 4 +# SpacingAroundAngleBrackets: +# active: false SpacingAroundColon: active: true - autoCorrect: true SpacingAroundComma: active: true - autoCorrect: true SpacingAroundCurly: active: true - autoCorrect: true SpacingAroundDot: active: true - autoCorrect: true + SpacingAroundDoubleColon: + active: false SpacingAroundKeyword: active: true - autoCorrect: true SpacingAroundOperators: active: true - autoCorrect: true SpacingAroundParens: active: true - autoCorrect: true SpacingAroundRangeOperator: active: true - autoCorrect: true +# SpacingAroundUnaryOperator: +# active: false + SpacingBetweenDeclarationsWithAnnotations: + active: false + SpacingBetweenDeclarationsWithComments: + active: false StringTemplate: active: true - autoCorrect: true naming: active: true +# BooleanPropertyNaming: +# active: true ClassNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - classPattern: '[A-Z$][a-zA-Z0-9$]*' ConstructorParameterNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - parameterPattern: '[a-z][A-Za-z0-9]*' - privateParameterPattern: '[a-z][A-Za-z0-9]*' - excludeClassPattern: '$^' - ignoreOverridden: true EnumNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*' ForbiddenClassName: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - forbiddenName: '' FunctionMaxLength: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - maximumFunctionNameLength: 30 FunctionMinLength: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - minimumFunctionNameLength: 3 FunctionNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$' - excludeClassPattern: '$^' - ignoreOverridden: true FunctionParameterNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - parameterPattern: '[a-z][A-Za-z0-9]*' - excludeClassPattern: '$^' - ignoreOverridden: true InvalidPackageDeclaration: active: false - rootPackage: '' MatchingDeclarationName: active: false MemberNameEqualsClassName: active: false - ignoreOverridden: true +# NoNameShadowing: +# active: false + NonBooleanPropertyPrefixedWithIs: + active: true ObjectPropertyNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - constantPattern: '[A-Za-z][_A-Za-z0-9]*' - propertyPattern: '[A-Za-z][_A-Za-z0-9]*' - privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*' PackageNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - packagePattern: '^[a-z]+(\.[a-z][A-Za-z0-9]*)*$' TopLevelPropertyNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - constantPattern: '[A-Z][_A-Z0-9]*' - propertyPattern: '[A-Za-z][_A-Za-z0-9]*' - privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*' VariableMaxLength: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - maximumVariableNameLength: 64 VariableMinLength: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - minimumVariableNameLength: 1 VariableNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - variablePattern: '[a-z][A-Za-z0-9]*' - privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' - excludeClassPattern: '$^' - ignoreOverridden: true performance: active: true @@ -401,29 +319,41 @@ performance: active: true ForEachOnRange: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" SpreadOperator: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" UnnecessaryTemporaryInstantiation: active: true potential-bugs: active: true +# AvoidReferentialEquality: +# active: false +# CastToNullableType: +# active: false Deprecation: active: false +# DontDowncastCollectionTypes: +# active: false +# DoubleMutabilityForCollection: +# active: false DuplicateCaseInWhenExpression: active: true EqualsAlwaysReturnsTrueOrFalse: active: true EqualsWithHashCodeExist: active: true +# ExitOutsideMain: +# active: false ExplicitGarbageCollectionCall: active: true HasPlatformType: active: false + IgnoredReturnValue: + active: false ImplicitDefaultLocale: active: false + ImplicitUnitReturnType: + active: false InvalidRange: active: true IteratorHasNextCallsNextMethod: @@ -432,37 +362,47 @@ potential-bugs: active: true LateinitUsage: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - excludeAnnotatedProperties: "" - ignoreOnClassesPattern: "" MapGetWithNotNullAssertionOperator: active: true MissingWhenCase: active: true + NullableToStringCall: + active: true RedundantElseInWhen: active: true UnconditionalJumpStatementInLoop: - active: false + active: true + UnnecessaryNotNullOperator: + active: true + UnnecessarySafeCall: + active: true +# UnreachableCatchBlock: +# active: true UnreachableCode: active: true UnsafeCallOnNullableType: active: true UnsafeCast: - active: false + active: true +# UnusedUnaryOperator: +# active: true UselessPostfixExpression: - active: false + active: true WrongEqualsTypeParameter: active: true style: active: true - CollapsibleIfStatements: + ClassOrdering: active: false + CollapsibleIfStatements: + active: true DataClassContainsFunctions: active: false - conversionFunctionPrefix: 'to' DataClassShouldBeImmutable: active: false +# DestructuringDeclarationWithTooManyEntries: +# active: false EqualsNullCall: active: true EqualsOnSignatureLine: @@ -473,87 +413,65 @@ style: active: false ExpressionBodySyntax: active: false - includeLineWrapping: false ForbiddenComment: active: false - values: 'TODO:,FIXME:,STOPSHIP:' - allowedPatterns: "" ForbiddenImport: active: false - imports: '' - forbiddenPatterns: "" ForbiddenMethodCall: active: false - methods: '' ForbiddenPublicDataClass: active: false - ignorePackages: '*.internal,*.internal.*' ForbiddenVoid: active: false - ignoreOverridden: false - ignoreUsageInGenerics: false FunctionOnlyReturningConstant: active: false - ignoreOverridableFunction: true - excludedFunctions: 'describeContents' - excludeAnnotatedFunction: "dagger.Provides" LibraryCodeMustSpecifyReturnType: active: true + LibraryEntitiesShouldNotBePublic: + active: false LoopWithTooManyJumpStatements: active: false - maxJumpCount: 1 MagicNumber: - active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - ignoreNumbers: '-1,0,1,2' - ignoreHashCodeFunction: true - ignorePropertyDeclaration: false - ignoreLocalVariableDeclaration: false - ignoreConstantDeclaration: true - ignoreCompanionObjectPropertyDeclaration: true - ignoreAnnotation: false - ignoreNamedArgument: true - ignoreEnums: false - ignoreRanges: false + active: true MandatoryBracesIfStatements: active: true + MandatoryBracesLoops: + active: true MaxLineLength: active: true maxLineLength: 120 - excludePackageStatements: true - excludeImportStatements: true - excludeCommentStatements: false MayBeConst: active: true ModifierOrder: active: true +# MultilineLambdaItParameter: +# active: false NestedClassesVisibility: active: false NewLineAtEndOfFile: active: false NoTabs: active: false +# ObjectLiteralToLambda: +# active: false OptionalAbstractKeyword: active: true OptionalUnit: active: true OptionalWhenBraces: - active: false + active: true PreferToOverPairSyntax: active: false ProtectedMemberInFinalClass: active: true RedundantExplicitType: active: true +# RedundantHigherOrderMapUsage: +# active: true RedundantVisibilityModifierRule: active: true ReturnCount: active: false - max: 2 - excludedFunctions: "equals" - excludeLabeled: false - excludeReturnFromLambda: true - excludeGuardClauses: false SafeCast: active: true SerialVersionUIDInSerializableClass: @@ -562,19 +480,18 @@ style: active: true ThrowsCount: active: false - max: 2 TrailingWhitespace: active: false UnderscoresInNumericLiterals: - active: true - acceptableDecimalLength: 5 + active: false UnnecessaryAbstractClass: active: true - excludeAnnotatedClasses: "dagger.Module" UnnecessaryAnnotationUseSiteTarget: active: false UnnecessaryApply: active: true +# UnnecessaryFilter: +# active: true UnnecessaryInheritance: active: true UnnecessaryLet: @@ -587,21 +504,31 @@ style: active: true UnusedPrivateClass: active: true + # TODO: Maybe we should activate it. UnusedPrivateMember: active: false - allowedNames: "(_|ignored|expected|serialVersionUID)" UseArrayLiteralsInAnnotations: active: false + UseCheckNotNull: + active: true UseCheckOrError: active: true UseDataClass: active: true - excludeAnnotatedClasses: "" - allowVars: false + UseEmptyCounterpart: + active: true +# UseIfEmptyOrIfBlank: +# active: true UseIfInsteadOfWhen: active: true +# UseIsNullOrEmpty: +# active: true +# UseOrEmpty: +# active: true UseRequire: active: true + UseRequireNotNull: + active: true UselessCallOnNotNull: active: true UtilityClassWithPublicConstructor: @@ -610,5 +537,3 @@ style: active: true WildcardImport: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - excludeImports: 'java.util.*,kotlinx.android.synthetic.*' diff --git a/src/python/review/inspectors/detekt/files/detekt-formatting-1.14.2.jar b/src/python/review/inspectors/detekt/files/detekt-formatting-1.14.2.jar new file mode 100644 index 00000000..54cf8763 Binary files /dev/null and b/src/python/review/inspectors/detekt/files/detekt-formatting-1.14.2.jar differ diff --git a/src/python/review/inspectors/detekt/files/detekt-formatting-1.5.1.jar b/src/python/review/inspectors/detekt/files/detekt-formatting-1.5.1.jar deleted file mode 100644 index 633f282a..00000000 Binary files a/src/python/review/inspectors/detekt/files/detekt-formatting-1.5.1.jar and /dev/null differ diff --git a/src/python/review/inspectors/detekt/issue_types.py b/src/python/review/inspectors/detekt/issue_types.py index 2379bba8..0d441f20 100644 --- a/src/python/review/inspectors/detekt/issue_types.py +++ b/src/python/review/inspectors/detekt/issue_types.py @@ -3,35 +3,40 @@ from src.python.review.inspectors.issue import IssueType DETECT_CLASS_NAME_TO_ISSUE_TYPE: Dict[str, IssueType] = { - # comments - 'CommentOverPrivateFunction': IssueType.BEST_PRACTICES, - 'CommentOverPrivateProperty': IssueType.BEST_PRACTICES, - 'CommentSpacing': IssueType.CODE_STYLE, - 'EndOfSentenceFormat': IssueType.CODE_STYLE, - 'UndocumentedPublicClass': IssueType.BEST_PRACTICES, - 'UndocumentedPublicFunction': IssueType.BEST_PRACTICES, - 'UndocumentedPublicProperty': IssueType.BEST_PRACTICES, + # Comments + # 'AbsentOrWrongFileLicense': IssueType.BEST_PRACTICES, + # 'CommentOverPrivateFunction': IssueType.BEST_PRACTICES, + # 'CommentOverPrivateProperty': IssueType.BEST_PRACTICES, + # 'DeprecatedBlockTag': IssueType.BEST_PRACTICES, + # 'EndOfSentenceFormat': IssueType.CODE_STYLE, + # 'UndocumentedPublicClass': IssueType.BEST_PRACTICES, + # 'UndocumentedPublicFunction': IssueType.BEST_PRACTICES, + # 'UndocumentedPublicProperty': IssueType.BEST_PRACTICES, - # complexity: + # Complexity 'ComplexCondition': IssueType.BOOL_EXPR_LEN, - 'ComplexInterface': IssueType.COMPLEXITY, + # 'ComplexInterface': IssueType.COMPLEXITY, 'ComplexMethod': IssueType.CYCLOMATIC_COMPLEXITY, - 'LabeledExpression': IssueType.COMPLEXITY, + # 'LabeledExpression': IssueType.COMPLEXITY, 'LargeClass': IssueType.COMPLEXITY, 'LongMethod': IssueType.FUNC_LEN, 'LongParameterList': IssueType.COMPLEXITY, - 'MethodOverloading': IssueType.COMPLEXITY, + # 'MethodOverloading': IssueType.COMPLEXITY, + # 'NamedArguments': IssueType.COMPLEXITY, 'NestedBlockDepth': IssueType.COMPLEXITY, - 'StringLiteralDuplication': IssueType.COMPLEXITY, + # 'ReplaceSafeCallChainWithRun': IssueType.BEST_PRACTICES, + 'StringLiteralDuplication': IssueType.BEST_PRACTICES, 'TooManyFunctions': IssueType.COMPLEXITY, - # coroutines: - 'GlobalCoroutineUsage': IssueType.BEST_PRACTICES, - 'RedundantSuspendModifier': IssueType.BEST_PRACTICES, + # Coroutines + # 'GlobalCoroutineUsage': IssueType.BEST_PRACTICES, + # 'RedundantSuspendModifier': IssueType.BEST_PRACTICES, + # 'SleepInsteadOfDelay': IssueType.BEST_PRACTICES, + # 'SuspendFunWithFlowReturnType': IssueType.BEST_PRACTICES, - # empty-blocks: + # Empty-blocks 'EmptyCatchBlock': IssueType.BEST_PRACTICES, - 'EmptyClassBlock': IssueType.CODE_STYLE, + 'EmptyClassBlock': IssueType.BEST_PRACTICES, 'EmptyDefaultConstructor': IssueType.BEST_PRACTICES, 'EmptyDoWhileBlock': IssueType.BEST_PRACTICES, 'EmptyElseBlock': IssueType.BEST_PRACTICES, @@ -42,162 +47,202 @@ 'EmptyInitBlock': IssueType.BEST_PRACTICES, 'EmptyKtFile': IssueType.BEST_PRACTICES, 'EmptySecondaryConstructor': IssueType.BEST_PRACTICES, + 'EmptyTryBlock': IssueType.BEST_PRACTICES, 'EmptyWhenBlock': IssueType.BEST_PRACTICES, 'EmptyWhileBlock': IssueType.BEST_PRACTICES, - # exceptions: + # Exceptions 'ExceptionRaisedInUnexpectedLocation': IssueType.BEST_PRACTICES, - 'InstanceOfCheckForException': IssueType.BEST_PRACTICES, - 'NotImplementedDeclaration': IssueType.BEST_PRACTICES, - 'PrintStackTrace': IssueType.BEST_PRACTICES, + # 'InstanceOfCheckForException': IssueType.BEST_PRACTICES, + # 'NotImplementedDeclaration': IssueType.BEST_PRACTICES, + # 'ObjectExtendsThrowable': IssueType.BEST_PRACTICES, + # 'PrintStackTrace': IssueType.BEST_PRACTICES, 'RethrowCaughtException': IssueType.BEST_PRACTICES, 'ReturnFromFinally': IssueType.BEST_PRACTICES, - 'SwallowedException': IssueType.BEST_PRACTICES, + # 'SwallowedException': IssueType.BEST_PRACTICES, 'ThrowingExceptionFromFinally': IssueType.BEST_PRACTICES, - 'ThrowingExceptionInMain': IssueType.BEST_PRACTICES, + # 'ThrowingExceptionInMain': IssueType.BEST_PRACTICES, 'ThrowingExceptionsWithoutMessageOrCause': IssueType.BEST_PRACTICES, - 'ThrowingNewInstanceOfSameException': IssueType.BEST_PRACTICES, - 'TooGenericExceptionCaught': IssueType.BEST_PRACTICES, - 'TooGenericExceptionThrown': IssueType.BEST_PRACTICES, + # 'ThrowingNewInstanceOfSameException': IssueType.BEST_PRACTICES, + # 'TooGenericExceptionCaught': IssueType.BEST_PRACTICES, + # 'TooGenericExceptionThrown': IssueType.BEST_PRACTICES, - # naming: + # Naming + # 'BooleanPropertyNaming': IssueType.INFO, 'ClassNaming': IssueType.CODE_STYLE, 'ConstructorParameterNaming': IssueType.CODE_STYLE, 'EnumNaming': IssueType.CODE_STYLE, - 'ForbiddenClassName': IssueType.CODE_STYLE, - 'FunctionMaxLength': IssueType.CODE_STYLE, - 'FunctionMinLength': IssueType.CODE_STYLE, + # 'ForbiddenClassName': IssueType.CODE_STYLE, + # 'FunctionMaxLength': IssueType.CODE_STYLE, + # 'FunctionMinLength': IssueType.CODE_STYLE, 'FunctionNaming': IssueType.CODE_STYLE, 'FunctionParameterNaming': IssueType.CODE_STYLE, - 'InvalidPackageDeclaration': IssueType.ERROR_PRONE, - 'MatchingDeclarationName': IssueType.CODE_STYLE, - 'MemberNameEqualsClassName': IssueType.BEST_PRACTICES, + # 'InvalidPackageDeclaration': IssueType.ERROR_PRONE, + # 'MatchingDeclarationName': IssueType.CODE_STYLE, + # 'MemberNameEqualsClassName': IssueType.BEST_PRACTICES, + # 'NoNameShadowing': IssueType.ERROR_PRONE, + 'NonBooleanPropertyPrefixedWithIs': IssueType.INFO, 'ObjectPropertyNaming': IssueType.CODE_STYLE, 'PackageNaming': IssueType.CODE_STYLE, 'TopLevelPropertyNaming': IssueType.CODE_STYLE, - 'VariableMaxLength': IssueType.CODE_STYLE, - 'VariableMinLength': IssueType.CODE_STYLE, + # 'VariableMaxLength': IssueType.CODE_STYLE, + # 'VariableMinLength': IssueType.CODE_STYLE, 'VariableNaming': IssueType.CODE_STYLE, - # performance: + # Performance 'ArrayPrimitive': IssueType.BEST_PRACTICES, 'ForEachOnRange': IssueType.BEST_PRACTICES, 'SpreadOperator': IssueType.BEST_PRACTICES, 'UnnecessaryTemporaryInstantiation': IssueType.BEST_PRACTICES, - # potential-bugs: - 'Deprecation': IssueType.ERROR_PRONE, + # Potential bugs + # 'AvoidReferentialEquality': IssueType.ERROR_PRONE, + # 'CastToNullableType': IssueType.ERROR_PRONE, + # 'Deprecation': IssueType.ERROR_PRONE, + # 'DontDowncastCollectionTypes': IssueType.ERROR_PRONE, + # 'DoubleMutabilityForCollection': IssueType.BEST_PRACTICES, 'DuplicateCaseInWhenExpression': IssueType.ERROR_PRONE, 'EqualsAlwaysReturnsTrueOrFalse': IssueType.ERROR_PRONE, 'EqualsWithHashCodeExist': IssueType.ERROR_PRONE, + # 'ExitOutsideMain': IssueType.BEST_PRACTICES, 'ExplicitGarbageCollectionCall': IssueType.ERROR_PRONE, - 'HasPlatformType': IssueType.ERROR_PRONE, - 'ImplicitDefaultLocale': IssueType.ERROR_PRONE, + # 'HasPlatformType': IssueType.ERROR_PRONE, + # 'IgnoredReturnValue': IssueType.ERROR_PRONE, + # 'ImplicitDefaultLocale': IssueType.ERROR_PRONE, + # 'ImplicitUnitReturnType': IssueType.ERROR_PRONE, 'InvalidRange': IssueType.ERROR_PRONE, 'IteratorHasNextCallsNextMethod': IssueType.ERROR_PRONE, 'IteratorNotThrowingNoSuchElementException': IssueType.ERROR_PRONE, - 'LateinitUsage': IssueType.ERROR_PRONE, + # 'LateinitUsage': IssueType.ERROR_PRONE, 'MapGetWithNotNullAssertionOperator': IssueType.ERROR_PRONE, 'MissingWhenCase': IssueType.ERROR_PRONE, + 'NullableToStringCall': IssueType.BEST_PRACTICES, 'RedundantElseInWhen': IssueType.ERROR_PRONE, 'UnconditionalJumpStatementInLoop': IssueType.ERROR_PRONE, + 'UnnecessaryNotNullOperator': IssueType.ERROR_PRONE, + 'UnnecessarySafeCall': IssueType.ERROR_PRONE, + # 'UnreachableCatchBlock': IssueType.ERROR_PRONE, 'UnreachableCode': IssueType.ERROR_PRONE, 'UnsafeCallOnNullableType': IssueType.ERROR_PRONE, + # 'UnusedUnaryOperator': IssueType.ERROR_PRONE, 'UnsafeCast': IssueType.ERROR_PRONE, 'UselessPostfixExpression': IssueType.ERROR_PRONE, 'WrongEqualsTypeParameter': IssueType.ERROR_PRONE, - # style: - 'AnnotationOnSeparateLine': IssueType.CODE_STYLE, + # Formatting + # 'AnnotationOnSeparateLine': IssueType.CODE_STYLE, + # 'AnnotationSpacing': IssueType.CODE_STYLE, + # 'ArgumentListWrapping': IssueType.CODE_STYLE, 'ChainWrapping': IssueType.CODE_STYLE, + 'CommentSpacing': IssueType.CODE_STYLE, 'EnumEntryNameCase': IssueType.CODE_STYLE, - 'Filename': IssueType.CODE_STYLE, - 'FinalNewline': IssueType.CODE_STYLE, + # 'Filename': IssueType.CODE_STYLE, + # 'FinalNewline': IssueType.CODE_STYLE, 'ImportOrdering': IssueType.CODE_STYLE, 'Indentation': IssueType.CODE_STYLE, - 'MaximumLineLength': IssueType.CODE_STYLE, - 'ModifierOrdering': IssueType.CODE_STYLE, + # 'MaximumLineLength': IssueType.CODE_STYLE, + # 'ModifierOrdering': IssueType.CODE_STYLE, 'MultiLineIfElse': IssueType.CODE_STYLE, - 'NoBlankLineBeforeRbrace': IssueType.CODE_STYLE, + # 'NoBlankLineBeforeRbrace': IssueType.CODE_STYLE, 'NoConsecutiveBlankLines': IssueType.CODE_STYLE, - 'NoEmptyClassBody': IssueType.CODE_STYLE, - 'NoEmptyFirstLineInMethodBlock': IssueType.CODE_STYLE, + # 'NoEmptyClassBody': IssueType.CODE_STYLE, + # 'NoEmptyFirstLineInMethodBlock': IssueType.CODE_STYLE, 'NoLineBreakAfterElse': IssueType.CODE_STYLE, 'NoLineBreakBeforeAssignment': IssueType.CODE_STYLE, 'NoMultipleSpaces': IssueType.CODE_STYLE, 'NoSemicolons': IssueType.CODE_STYLE, - 'NoTrailingSpaces': IssueType.CODE_STYLE, - 'NoUnitReturn': IssueType.CODE_STYLE, - 'NoUnusedImports': IssueType.CODE_STYLE, - 'NoWildcardImports': IssueType.CODE_STYLE, - 'PackageName': IssueType.CODE_STYLE, + # 'NoTrailingSpaces': IssueType.CODE_STYLE, + # 'NoUnitReturn': IssueType.CODE_STYLE, + # 'NoUnusedImports': IssueType.CODE_STYLE, + # 'NoWildcardImports': IssueType.CODE_STYLE, + # 'PackageName': IssueType.CODE_STYLE, 'ParameterListWrapping': IssueType.CODE_STYLE, + # 'SpacingAroundAngleBrackets': IssueType.CODE_STYLE, 'SpacingAroundColon': IssueType.CODE_STYLE, 'SpacingAroundComma': IssueType.CODE_STYLE, 'SpacingAroundCurly': IssueType.CODE_STYLE, 'SpacingAroundDot': IssueType.CODE_STYLE, + # 'SpacingAroundDoubleColon': IssueType.CODE_STYLE, 'SpacingAroundKeyword': IssueType.CODE_STYLE, 'SpacingAroundOperators': IssueType.CODE_STYLE, 'SpacingAroundParens': IssueType.CODE_STYLE, 'SpacingAroundRangeOperator': IssueType.CODE_STYLE, + # 'SpacingAroundUnaryOperator': IssueType.CODE_STYLE, + # 'SpacingBetweenDeclarationsWithAnnotations': IssueType.CODE_STYLE, + # 'SpacingBetweenDeclarationsWithComments': IssueType.CODE_STYLE, 'StringTemplate': IssueType.CODE_STYLE, - # best practices: + # Style + # 'ClassOrdering': IssueType.BEST_PRACTICES, 'CollapsibleIfStatements': IssueType.BEST_PRACTICES, - 'DataClassContainsFunctions': IssueType.BEST_PRACTICES, - 'DataClassShouldBeImmutable': IssueType.BEST_PRACTICES, + # 'DataClassContainsFunctions': IssueType.BEST_PRACTICES, + # 'DataClassShouldBeImmutable': IssueType.BEST_PRACTICES, + # 'DestructuringDeclarationWithTooManyEntries': IssueType.BEST_PRACTICES, 'EqualsNullCall': IssueType.BEST_PRACTICES, - 'EqualsOnSignatureLine': IssueType.CODE_STYLE, - 'ExplicitCollectionElementAccessMethod': IssueType.BEST_PRACTICES, - 'ExplicitItLambdaParameter': IssueType.BEST_PRACTICES, - 'ExpressionBodySyntax': IssueType.BEST_PRACTICES, - 'ForbiddenComment': IssueType.BEST_PRACTICES, - 'ForbiddenImport': IssueType.BEST_PRACTICES, - 'ForbiddenMethodCall': IssueType.BEST_PRACTICES, - 'ForbiddenPublicDataClass': IssueType.BEST_PRACTICES, - 'ForbiddenVoid': IssueType.BEST_PRACTICES, - 'FunctionOnlyReturningConstant': IssueType.BEST_PRACTICES, + # 'EqualsOnSignatureLine': IssueType.CODE_STYLE, + # 'ExplicitCollectionElementAccessMethod': IssueType.BEST_PRACTICES, + # 'ExplicitItLambdaParameter': IssueType.BEST_PRACTICES, + # 'ExpressionBodySyntax': IssueType.BEST_PRACTICES, + # 'ForbiddenComment': IssueType.BEST_PRACTICES, + # 'ForbiddenImport': IssueType.BEST_PRACTICES, + # 'ForbiddenMethodCall': IssueType.BEST_PRACTICES, + # 'ForbiddenPublicDataClass': IssueType.BEST_PRACTICES, + # 'ForbiddenVoid': IssueType.BEST_PRACTICES, + # 'FunctionOnlyReturningConstant': IssueType.BEST_PRACTICES, 'LibraryCodeMustSpecifyReturnType': IssueType.BEST_PRACTICES, - 'LoopWithTooManyJumpStatements': IssueType.COMPLEXITY, - 'MagicNumber': IssueType.CODE_STYLE, + # 'LibraryEntitiesShouldNotBePublic': IssueType.BEST_PRACTICES, + # 'LoopWithTooManyJumpStatements': IssueType.COMPLEXITY, + 'MagicNumber': IssueType.INFO, 'MandatoryBracesIfStatements': IssueType.CODE_STYLE, + 'MandatoryBracesLoops': IssueType.CODE_STYLE, + # TODO: Change to LINE_LEN when Detekt is able to display the line length in the message to this inspection 'MaxLineLength': IssueType.CODE_STYLE, 'MayBeConst': IssueType.BEST_PRACTICES, 'ModifierOrder': IssueType.CODE_STYLE, - 'NestedClassesVisibility': IssueType.BEST_PRACTICES, - 'NewLineAtEndOfFile': IssueType.CODE_STYLE, - 'NoTabs': IssueType.CODE_STYLE, + # 'MultilineLambdaItParameter': IssueType.BEST_PRACTICES, + # 'NestedClassesVisibility': IssueType.BEST_PRACTICES, + # 'NewLineAtEndOfFile': IssueType.CODE_STYLE, + # 'NoTabs': IssueType.CODE_STYLE, + # 'ObjectLiteralToLambda': IssueType.BEST_PRACTICES, 'OptionalAbstractKeyword': IssueType.CODE_STYLE, 'OptionalUnit': IssueType.CODE_STYLE, 'OptionalWhenBraces': IssueType.CODE_STYLE, - 'PreferToOverPairSyntax': IssueType.BEST_PRACTICES, + # 'PreferToOverPairSyntax': IssueType.BEST_PRACTICES, 'ProtectedMemberInFinalClass': IssueType.BEST_PRACTICES, 'RedundantExplicitType': IssueType.CODE_STYLE, + # 'RedundantHigherOrderMapUsage': IssueType.BEST_PRACTICES, 'RedundantVisibilityModifierRule': IssueType.CODE_STYLE, - 'ReturnCount': IssueType.COMPLEXITY, + # 'ReturnCount': IssueType.COMPLEXITY, 'SafeCast': IssueType.BEST_PRACTICES, - 'SerialVersionUIDInSerializableClass': IssueType.BEST_PRACTICES, + # 'SerialVersionUIDInSerializableClass': IssueType.BEST_PRACTICES, 'SpacingBetweenPackageAndImports': IssueType.CODE_STYLE, - 'ThrowsCount': IssueType.COMPLEXITY, - 'TrailingWhitespace': IssueType.CODE_STYLE, - 'UnderscoresInNumericLiterals': IssueType.CODE_STYLE, + # 'ThrowsCount': IssueType.COMPLEXITY, + # 'TrailingWhitespace': IssueType.CODE_STYLE, + # 'UnderscoresInNumericLiterals': IssueType.CODE_STYLE, 'UnnecessaryAbstractClass': IssueType.BEST_PRACTICES, - 'UnnecessaryAnnotationUseSiteTarget': IssueType.BEST_PRACTICES, - 'UnnecessaryApply': IssueType.CODE_STYLE, + # 'UnnecessaryAnnotationUseSiteTarget': IssueType.BEST_PRACTICES, + 'UnnecessaryApply': IssueType.BEST_PRACTICES, + # 'UnnecessaryFilter': IssueType.BEST_PRACTICES, 'UnnecessaryInheritance': IssueType.BEST_PRACTICES, - 'UnnecessaryLet': IssueType.CODE_STYLE, + 'UnnecessaryLet': IssueType.BEST_PRACTICES, 'UnnecessaryParentheses': IssueType.CODE_STYLE, - 'UntilInsteadOfRangeTo': IssueType.BEST_PRACTICES, + # 'UntilInsteadOfRangeTo': IssueType.BEST_PRACTICES, 'UnusedImports': IssueType.BEST_PRACTICES, 'UnusedPrivateClass': IssueType.BEST_PRACTICES, - 'UnusedPrivateMember': IssueType.BEST_PRACTICES, - 'UseArrayLiteralsInAnnotations': IssueType.CODE_STYLE, + # 'UnusedPrivateMember': IssueType.BEST_PRACTICES, + # 'UseArrayLiteralsInAnnotations': IssueType.BEST_PRACTICES, + 'UseCheckNotNull': IssueType.BEST_PRACTICES, 'UseCheckOrError': IssueType.BEST_PRACTICES, 'UseDataClass': IssueType.BEST_PRACTICES, + 'UseEmptyCounterpart': IssueType.BEST_PRACTICES, + # 'UseIfEmptyOrIfBlank': IssueType.BEST_PRACTICES, 'UseIfInsteadOfWhen': IssueType.BEST_PRACTICES, + # 'UseIsNullOrEmpty': IssueType.BEST_PRACTICES, + # 'UseOrEmpty': IssueType.BEST_PRACTICES, 'UseRequire': IssueType.BEST_PRACTICES, + 'UseRequireNotNull': IssueType.BEST_PRACTICES, 'UselessCallOnNotNull': IssueType.BEST_PRACTICES, - 'UtilityClassWithPublicConstructor': IssueType.BEST_PRACTICES, + # 'UtilityClassWithPublicConstructor': IssueType.BEST_PRACTICES, 'VarCouldBeVal': IssueType.BEST_PRACTICES, 'WildcardImport': IssueType.BEST_PRACTICES, } diff --git a/test/python/inspectors/test_detekt_inspector.py b/test/python/inspectors/test_detekt_inspector.py index 99f84f27..e9a650c2 100644 --- a/test/python/inspectors/test_detekt_inspector.py +++ b/test/python/inspectors/test_detekt_inspector.py @@ -12,22 +12,22 @@ ('case2_valid_program.kt', 0), ('case3_todo.kt', 0), ('case4_semicolons.kt', 6), - ('case5_imports.kt', 3), + ('case5_imports.kt', 6), ('case6_missing_spaces.kt', 6), ('case8_needless_blank_line.kt', 3), - ('case9_braces.kt', 3), - ('case11_bad_ident.kt', 2), + ('case9_braces.kt', 8), + ('case11_bad_ident.kt', 3), ('case13_good_filename.kt', 0), ('case14_keyword_spacing.kt', 12), ('case15_empty_class_func.kt', 2), ('case16_redundant_unit.kt', 1), - ('case18_redundant_braces.kt', 3), + ('case18_redundant_braces.kt', 6), ('case20_cyclomatic_complexity.kt', 0), ('case21_cyclomatic_complexity_bad.kt', 2), ('case22_too_many_arguments.kt', 1), - ('case23_bad_range_performance.kt', 3), + ('case23_bad_range_performance.kt', 7), ('case24_duplicate_when_bug.kt', 1), - ('case25_unreachable_code.kt', 3), + ('case25_unreachable_code.kt', 4), ('case26_var_could_be_val.kt', 1), ] diff --git a/whitelist.txt b/whitelist.txt index 0fc7798b..34148f0a 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -49,6 +49,7 @@ conftest const consts copytree +coroutine coroutines csv ctor @@ -63,6 +64,7 @@ datasets dedent delslice desc +destructuring detekt df dicts @@ -126,6 +128,7 @@ json jsons jsonschema kts +lateinit lcom linecache linecolor @@ -160,6 +163,7 @@ noc nom noqa nrows +nullable num numpy oop @@ -186,6 +190,7 @@ pyast pylint qodana qodanadataset +rbrace rdiv readouterr redeclared @@ -216,9 +221,11 @@ sym textangle textposition textwrap +throwable tmp tokenizer toplevel +unary uncommented unichr uniformtext