From bbff0584486130892b347e3da4a42cdfbd8b70fa Mon Sep 17 00:00:00 2001 From: Marco Saia Date: Tue, 23 Sep 2025 16:01:13 +0200 Subject: [PATCH 1/5] Updated detekt plugin for Gradle 9 support --- packages/core/android/build.gradle | 2 +- packages/internal-testing-tools/android/build.gradle | 2 +- packages/react-native-session-replay/android/build.gradle | 2 +- packages/react-native-webview/android/build.gradle | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle index b82587b33..e8d0a6827 100644 --- a/packages/core/android/build.gradle +++ b/packages/core/android/build.gradle @@ -16,7 +16,7 @@ buildscript { // noinspection DifferentKotlinGradleVersion classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1" - classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.18.0" + classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.8" classpath 'com.github.bjoernq:unmockplugin:0.7.9' // Uncomment here and in settings.gradle for getting rid of IDE errors for new architecture: // classpath "com.facebook.react:react-native-gradle-plugin" diff --git a/packages/internal-testing-tools/android/build.gradle b/packages/internal-testing-tools/android/build.gradle index 6bfab035c..da3f1e218 100644 --- a/packages/internal-testing-tools/android/build.gradle +++ b/packages/internal-testing-tools/android/build.gradle @@ -16,7 +16,7 @@ buildscript { // noinspection DifferentKotlinGradleVersion classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1" - classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.18.0" + classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.8" classpath 'com.github.bjoernq:unmockplugin:0.7.9' } } diff --git a/packages/react-native-session-replay/android/build.gradle b/packages/react-native-session-replay/android/build.gradle index 2756709d7..57d7c3bf7 100644 --- a/packages/react-native-session-replay/android/build.gradle +++ b/packages/react-native-session-replay/android/build.gradle @@ -16,7 +16,7 @@ buildscript { // noinspection DifferentKotlinGradleVersion classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1" - classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.18.0" + classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.8" classpath 'com.github.bjoernq:unmockplugin:0.7.9' } } diff --git a/packages/react-native-webview/android/build.gradle b/packages/react-native-webview/android/build.gradle index 9f2aba9c9..9c5a378d8 100644 --- a/packages/react-native-webview/android/build.gradle +++ b/packages/react-native-webview/android/build.gradle @@ -16,7 +16,7 @@ buildscript { // noinspection DifferentKotlinGradleVersion classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1" - classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.18.0" + classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.8" classpath 'com.github.bjoernq:unmockplugin:0.7.9' } } From 909a32896ede84a7cab2d153b4acb098dcbed448 Mon Sep 17 00:00:00 2001 From: Marco Saia Date: Tue, 23 Sep 2025 16:01:30 +0200 Subject: [PATCH 2/5] Updated snyk resolution version for Gradle 9 support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5b33fa717..b6535020e 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "send": "0.19.0", "serve-static": "1.16.0", "formidable": "3.5.3", - "snyk": "^1.1297.3", + "snyk": "^1.1298.3", "form-data": "4.0.4", "on-headers": "1.1.0", "tmp": "0.2.4" From 702dd79b72d76f980e6266b3d1b82be9f37b591e Mon Sep 17 00:00:00 2001 From: Marco Saia Date: Tue, 23 Sep 2025 16:03:27 +0200 Subject: [PATCH 3/5] Added compileSdk to build.gradle --- packages/core/android/build.gradle | 2 ++ packages/internal-testing-tools/android/build.gradle | 1 + packages/react-native-session-replay/android/build.gradle | 1 + packages/react-native-webview/android/build.gradle | 1 + yarn.lock | 8 ++++---- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle index e8d0a6827..6824b4467 100644 --- a/packages/core/android/build.gradle +++ b/packages/core/android/build.gradle @@ -96,6 +96,7 @@ def getExtOrIntegerDefault(name) { } android { + compileSdk getExtOrIntegerDefault('compileSdkVersion') compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') buildToolsVersion getExtOrDefault('buildToolsVersion') @@ -122,6 +123,7 @@ android { } defaultConfig { + compileSdk getExtOrIntegerDefault('compileSdkVersion') minSdkVersion getExtOrIntegerDefault('minSdkVersion') targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') versionCode 1 diff --git a/packages/internal-testing-tools/android/build.gradle b/packages/internal-testing-tools/android/build.gradle index da3f1e218..026b92c15 100644 --- a/packages/internal-testing-tools/android/build.gradle +++ b/packages/internal-testing-tools/android/build.gradle @@ -91,6 +91,7 @@ def getExtOrIntegerDefault(name) { } android { + compileSdk getExtOrIntegerDefault('compileSdkVersion') compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') buildToolsVersion getExtOrDefault('buildToolsVersion') diff --git a/packages/react-native-session-replay/android/build.gradle b/packages/react-native-session-replay/android/build.gradle index 57d7c3bf7..0b6589abd 100644 --- a/packages/react-native-session-replay/android/build.gradle +++ b/packages/react-native-session-replay/android/build.gradle @@ -94,6 +94,7 @@ def getExtOrIntegerDefault(name) { } android { + compileSdk getExtOrIntegerDefault('compileSdkVersion') compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') buildToolsVersion getExtOrDefault('buildToolsVersion') diff --git a/packages/react-native-webview/android/build.gradle b/packages/react-native-webview/android/build.gradle index 9c5a378d8..faad9d68f 100644 --- a/packages/react-native-webview/android/build.gradle +++ b/packages/react-native-webview/android/build.gradle @@ -94,6 +94,7 @@ def getExtOrIntegerDefault(name) { } android { + compileSdk getExtOrIntegerDefault('compileSdkVersion') compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') buildToolsVersion getExtOrDefault('buildToolsVersion') def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION diff --git a/yarn.lock b/yarn.lock index 4bee70033..928400580 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19538,15 +19538,15 @@ __metadata: languageName: node linkType: hard -"snyk@npm:^1.1297.3": - version: 1.1297.3 - resolution: "snyk@npm:1.1297.3" +"snyk@npm:^1.1298.3": + version: 1.1299.0 + resolution: "snyk@npm:1.1299.0" dependencies: "@sentry/node": ^7.36.0 global-agent: ^3.0.0 bin: snyk: bin/snyk - checksum: e9e81146e6bdf92f8ccff4b5a3a4ade7dd99464c01b39bc82665cd88eacfa50c633f3309e239e227685b227e6136caf6a0dfd13907556442651713911c5b7b92 + checksum: b5e81ee352b4140d271b6f7d7619489ac94328431c557d98523d13b381041621a7f88a476582e521ca879853e34c8a12e91e72bb49f5b528e2c0645004a69d10 languageName: node linkType: hard From fefd27e6278d0b3743075f0eda0339a6341090b7 Mon Sep 17 00:00:00 2001 From: Marco Saia Date: Mon, 29 Sep 2025 16:39:39 +0200 Subject: [PATCH 4/5] Added missing header search paths for RN 0.82+ support --- ...DatadogSDKReactNativeSessionReplay.podspec | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/packages/react-native-session-replay/DatadogSDKReactNativeSessionReplay.podspec b/packages/react-native-session-replay/DatadogSDKReactNativeSessionReplay.podspec index 9b9aacb63..781e62881 100644 --- a/packages/react-native-session-replay/DatadogSDKReactNativeSessionReplay.podspec +++ b/packages/react-native-session-replay/DatadogSDKReactNativeSessionReplay.podspec @@ -28,23 +28,25 @@ Pod::Spec.new do |s| test_spec.platforms = { :ios => "13.4", :tvos => "13.4" } end + header_paths = %W[ + $(inherited) + $(PODS_ROOT)/React-RCTFabric/** + $(PODS_ROOT)/React-FabricComponents/** + $(PODS_CONFIGURATION_BUILD_DIR)/React-FabricComponents/React_FabricComponents.framework/Headers/** + $(PODS_CONFIGURATION_BUILD_DIR)/React-FabricComponents/React_FabricComponents.framework/Headers/react/renderer/components/text/platform/cxx/** + ${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_RCTFabric.framework/Headers/** + ${PODS_CONFIGURATION_BUILD_DIR}/React-FabricComponents/** + $(PODS_CONFIGURATION_BUILD_DIR)/React-timing/React_timing.framework/Headers/** + ].join(' ') xcconfig = { - "HEADER_SEARCH_PATHS" => "$(inherited) " + - "$(PODS_ROOT)/React-RCTFabric/** " + - "$(PODS_ROOT)/React-FabricComponents/** " + - "${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_RCTFabric.framework/Headers/** " + - "$(PODS_CONFIGURATION_BUILD_DIR)/React-FabricComponents/React_FabricComponents.framework/Headers/**", - "USER_HEADER_SEARCH_PATHS" => "$(inherited) " + - "$(PODS_ROOT)/React-RCTFabric/** " + - "$(PODS_ROOT)/React-FabricComponents/** " + - "${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_RCTFabric.framework/Headers/** " + - "$(PODS_CONFIGURATION_BUILD_DIR)/React-FabricComponents/React_FabricComponents.framework/Headers/**" + 'HEADER_SEARCH_PATHS' => header_paths, + 'USER_HEADER_SEARCH_PATHS' => header_paths, } if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1" - + xcconfig.merge!({ "DEFINES_MODULE" => "YES", "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" @@ -55,8 +57,5 @@ Pod::Spec.new do |s| if respond_to?(:install_modules_dependencies, true) install_modules_dependencies(s) - # else - # s.dependency "React-Core" end - end From 3810a0e06fdfcf0f15959a5b81e343d4707ec5d3 Mon Sep 17 00:00:00 2001 From: Marco Saia Date: Mon, 13 Oct 2025 22:45:10 +0200 Subject: [PATCH 5/5] Migrated detekt plugin to 1.23.8 --- packages/core/android/build.gradle | 6 +- packages/core/android/detekt.yml | 323 +++++++++++++----- .../datadog/reactnative/DatadogSDKWrapper.kt | 1 + .../reactnative/DdLogsImplementation.kt | 2 +- .../reactnative/DdRumImplementation.kt | 2 +- .../reactnative/DdSdkConfigurationExt.kt | 6 +- .../reactnative/DdSdkImplementation.kt | 3 +- .../reactnative/DdSdkNativeInitialization.kt | 3 +- .../reactnative/DdTraceImplementation.kt | 2 +- .../android/build.gradle | 6 +- .../internal-testing-tools/android/detekt.yml | 323 +++++++++++++----- .../DdInternalTestingImplementation.kt | 2 +- .../android/build.gradle | 7 +- .../android/detekt.yml | 323 +++++++++++++----- .../DdSessionReplayImplementation.kt | 2 +- .../SessionReplayPrivacySettings.kt | 8 +- .../react-native-webview/android/build.gradle | 4 + .../react-native-webview/android/detekt.yml | 323 +++++++++++++----- 18 files changed, 980 insertions(+), 366 deletions(-) diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle index 6824b4467..c7c6300ef 100644 --- a/packages/core/android/build.gradle +++ b/packages/core/android/build.gradle @@ -1,6 +1,8 @@ import java.nio.file.Paths import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +apply plugin: "io.gitlab.arturbosch.detekt" + buildscript { // Buildscript is evaluated before everything else so we can't use getExtOrDefault def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['DdSdkReactNative_kotlinVersion'] @@ -36,7 +38,7 @@ if (isNewArchitectureEnabled()) { } apply plugin: 'kotlin-android' apply plugin: 'org.jlleitschuh.gradle.ktlint' -apply plugin: "io.gitlab.arturbosch.detekt" + /** * Finds the path of the installed npm package with the given name using Node's @@ -224,6 +226,8 @@ dependencies { testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" unmock 'org.robolectric:android-all:4.4_r1-robolectric-r2' + detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.23.8" + detektPlugins "io.gitlab.arturbosch.detekt:detekt-rules-libraries:1.23.8" } unMock { diff --git a/packages/core/android/detekt.yml b/packages/core/android/detekt.yml index c1376f3bf..08074aa73 100644 --- a/packages/core/android/detekt.yml +++ b/packages/core/android/detekt.yml @@ -1,14 +1,13 @@ build: maxIssues: 0 - weights: - # complexity: 2 - # LongParameterList: 1 - # style: 1 - # comments: 1 + +libraries: + LibraryCodeMustSpecifyReturnType: + active: true processors: active: true - exclude: + exclude: [] # - 'DetektProgressListener' # - 'FunctionCountProcessor' # - 'PropertyCountProcessor' @@ -23,7 +22,7 @@ console-reports: # - 'ComplexityReport' # - 'NotificationReport' # - 'FindingsReport' - - 'FileBasedFindingsReport' + - "FileBasedFindingsReport" # - 'BuildFailureReport' comments: @@ -37,17 +36,38 @@ comments: endOfSentenceFormat: ([.?!][ \t\n\r\f<])|([.?!:]$) UndocumentedPublicClass: active: true - excludes: [ "**/test/**","**/androidTest/**","**/*.Test.kt","**/*.Spec.kt","**/*.Spek.kt" ] + excludes: + [ + "**/test/**", + "**/androidTest/**", + "**/*.Test.kt", + "**/*.Spec.kt", + "**/*.Spek.kt", + ] searchInNestedClass: true searchInInnerClass: true searchInInnerObject: true searchInInnerInterface: true UndocumentedPublicFunction: active: true - excludes: [ "**/test/**","**/androidTest/**","**/*.Test.kt","**/*.Spec.kt","**/*.Spek.kt" ] + excludes: + [ + "**/test/**", + "**/androidTest/**", + "**/*.Test.kt", + "**/*.Spec.kt", + "**/*.Spek.kt", + ] UndocumentedPublicProperty: active: true - excludes: [ "**/test/**","**/androidTest/**","**/*.Test.kt","**/*.Spec.kt","**/*.Spek.kt" ] + excludes: + [ + "**/test/**", + "**/androidTest/**", + "**/*.Test.kt", + "**/*.Spec.kt", + "**/*.Spek.kt", + ] complexity: active: true @@ -58,14 +78,14 @@ complexity: active: true threshold: 10 includeStaticDeclarations: false - ComplexMethod: + CyclomaticComplexMethod: active: true threshold: 10 ignoreSingleWhenExpression: true ignoreSimpleWhenEntries: true LabeledExpression: active: true - ignoredLabels: "" + ignoredLabels: [] LargeClass: active: true threshold: 600 @@ -74,7 +94,8 @@ complexity: threshold: 60 LongParameterList: active: true - threshold: 6 + functionThreshold: 6 + constructorThreshold: 6 ignoreDefaultParameters: true MethodOverloading: active: true @@ -84,14 +105,24 @@ complexity: threshold: 4 StringLiteralDuplication: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" threshold: 3 ignoreAnnotation: true excludeStringsWithLessThan5Characters: true - ignoreStringsRegex: '$^' + ignoreStringsRegex: "$^" TooManyFunctions: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" thresholdInFiles: 11 thresholdInClasses: 11 thresholdInInterfaces: 11 @@ -99,7 +130,6 @@ complexity: thresholdInEnums: 11 ignoreDeprecated: true ignorePrivate: true - ignoreOverridden: true empty-blocks: active: true @@ -138,10 +168,19 @@ exceptions: active: true ExceptionRaisedInUnexpectedLocation: active: true - methodNames: 'toString,hashCode,equals,finalize' + methodNames: + - toString + - hashCode + - equals + - finalize InstanceOfCheckForException: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" NotImplementedDeclaration: active: true PrintStackTrace: @@ -153,7 +192,11 @@ exceptions: ignoreLabeled: true SwallowedException: active: true - ignoredExceptionTypes: 'InterruptedException,NumberFormatException,ParseException,MalformedURLException' + ignoredExceptionTypes: + - InterruptedException + - NumberFormatException + - ParseException + - MalformedURLException allowedExceptionNameRegex: "^(_|(ignore|expected).*)" ThrowingExceptionFromFinally: active: true @@ -161,12 +204,20 @@ exceptions: active: true ThrowingExceptionsWithoutMessageOrCause: active: true - exceptions: 'IllegalArgumentException,IllegalStateException,IOException' + exceptions: + - IllegalArgumentException + - IllegalStateException + - IOException ThrowingNewInstanceOfSameException: active: true TooGenericExceptionCaught: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" exceptionNames: - ArrayIndexOutOfBoundsException - Error @@ -210,7 +261,6 @@ formatting: active: true autoCorrect: true indentSize: 4 - continuationIndentSize: 4 MaximumLineLength: active: true maxLineLength: 120 @@ -292,45 +342,85 @@ naming: active: true ClassNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - classPattern: '[A-Z$][a-zA-Z0-9$]*' + 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: '$^' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + parameterPattern: "[a-z][A-Za-z0-9]*" + privateParameterPattern: "[a-z][A-Za-z0-9]*" + excludeClassPattern: "$^" EnumNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + enumEntryPattern: "^[A-Z][_a-zA-Z0-9]*" ForbiddenClassName: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - forbiddenName: '' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + forbiddenName: [] FunctionMaxLength: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" maximumFunctionNameLength: 30 FunctionMinLength: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + 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 + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + functionPattern: "^([a-z$][a-zA-Z$0-9]*)|(`.*`)$" + excludeClassPattern: "$^" + FunctionParameterNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - parameterPattern: '[a-z][A-Za-z0-9]*' - excludeClassPattern: '$^' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + parameterPattern: "[a-z][A-Za-z0-9]*" + excludeClassPattern: "$^" ignoreOverridden: true InvalidPackageDeclaration: active: true - rootPackage: '' + rootPackage: "" MatchingDeclarationName: active: true MemberNameEqualsClassName: @@ -338,35 +428,64 @@ naming: ignoreOverridden: 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]*' + 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" + 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]*' + 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: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" maximumVariableNameLength: 64 VariableMinLength: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + 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 + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + variablePattern: "[a-z][A-Za-z0-9]*" + privateVariablePattern: "(_)?[a-z][A-Za-z0-9]*" + excludeClassPattern: "$^" performance: active: true @@ -374,10 +493,20 @@ performance: active: true ForEachOnRange: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" SpreadOperator: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" UnnecessaryTemporaryInstantiation: active: true @@ -385,8 +514,6 @@ potential-bugs: active: true Deprecation: active: true - DuplicateCaseInWhenExpression: - active: true EqualsAlwaysReturnsTrueOrFalse: active: true EqualsWithHashCodeExist: @@ -403,13 +530,14 @@ potential-bugs: active: true LateinitUsage: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - excludeAnnotatedProperties: "" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + ignoreAnnotated: [] ignoreOnClassesPattern: "" - MissingWhenCase: - active: true - RedundantElseInWhen: - active: true UnconditionalJumpStatementInLoop: active: true UnreachableCode: @@ -429,7 +557,7 @@ style: active: true DataClassContainsFunctions: active: true - conversionFunctionPrefix: 'to' + conversionFunctionPrefix: ["to"] DataClassShouldBeImmutable: active: true EqualsNullCall: @@ -443,11 +571,17 @@ style: includeLineWrapping: false ForbiddenComment: active: true - values: 'TODO:,FIXME:,STOPSHIP:' + comments: + - reason: "Forbidden FIXME todo marker in comment, please fix the problem." + value: "FIXME:" + - reason: "Forbidden STOPSHIP todo marker in comment, please address the problem before shipping the code." + value: "STOPSHIP:" + - reason: "Forbidden TODO todo marker in comment, please do the changes, or add Jira ticket reference and suppress the warning." + value: "TODO:" allowedPatterns: "" ForbiddenImport: active: true - imports: '' + imports: [] forbiddenPatterns: "" ForbiddenVoid: active: true @@ -456,17 +590,24 @@ style: FunctionOnlyReturningConstant: active: true ignoreOverridableFunction: true - excludedFunctions: 'describeContents' - excludeAnnotatedFunction: "dagger.Provides" - LibraryCodeMustSpecifyReturnType: - active: true + excludedFunctions: ["describeContents"] + ignoreAnnotated: ["dagger.Provides"] LoopWithTooManyJumpStatements: active: true maxJumpCount: 1 MagicNumber: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - ignoreNumbers: '-1,0,1,2' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + ignoreNumbers: + - "-1" + - "0" + - "1" + - "2" ignoreHashCodeFunction: true ignorePropertyDeclaration: false ignoreConstantDeclaration: true @@ -475,8 +616,9 @@ style: ignoreNamedArgument: true ignoreEnums: false ignoreRanges: false - MandatoryBracesIfStatements: - active: true + BracesOnIfStatements: + singleLine: consistent + multiLine: always MaxLineLength: active: true maxLineLength: 120 @@ -497,7 +639,7 @@ style: active: true OptionalUnit: active: true - OptionalWhenBraces: + BracesOnWhenStatements: active: true PreferToOverPairSyntax: active: true @@ -510,7 +652,7 @@ style: ReturnCount: active: true max: 2 - excludedFunctions: "equals" + excludedFunctions: ["equals"] excludeLabeled: false excludeReturnFromLambda: true excludeGuardClauses: true @@ -527,10 +669,10 @@ style: active: true UnderscoresInNumericLiterals: active: true - acceptableDecimalLength: 5 + acceptableLength: 5 UnnecessaryAbstractClass: active: true - excludeAnnotatedClasses: "dagger.Module" + ignoreAnnotated: ["dagger.Module"] UnnecessaryApply: active: true UnnecessaryInheritance: @@ -554,7 +696,7 @@ style: active: true UseDataClass: active: true - excludeAnnotatedClasses: "" + ignoreAnnotated: [""] allowVars: true UseIfInsteadOfWhen: active: true @@ -568,5 +710,12 @@ style: active: true WildcardImport: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - excludeImports: 'java.util.*,kotlinx.android.synthetic.*' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + excludeImports: + - java.util.* + - kotlinx.android.synthetic.* diff --git a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt index 7452c40ef..c9865a5d7 100644 --- a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +++ b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt @@ -3,6 +3,7 @@ * This product includes software developed at Datadog (https://www.datadoghq.com/). * Copyright 2016-Present Datadog, Inc. */ +@file:Suppress("TooManyFunctions") package com.datadog.reactnative diff --git a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdLogsImplementation.kt b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdLogsImplementation.kt index 7223a2c72..9a84496ec 100644 --- a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdLogsImplementation.kt +++ b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdLogsImplementation.kt @@ -226,7 +226,7 @@ class DdLogsImplementation( promise.resolve(null) } - companion object { + internal companion object { private const val SDK_NOT_INITIALIZED_MESSAGE = "DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT" internal const val NAME = "DdLogs" } diff --git a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt index 35471374e..013872c08 100644 --- a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +++ b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt @@ -356,7 +356,7 @@ class DdRumImplementation(private val datadog: DatadogWrapper = DatadogSDKWrappe } // endregion - + @Suppress("UndocumentedPublicClass") companion object { private const val MISSING_RESOURCE_SIZE = -1L internal const val NAME = "DdRum" diff --git a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt index bcffdbbf5..63a1b4ce7 100644 --- a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +++ b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt @@ -72,7 +72,7 @@ internal fun ReadableMap.asCustomEndpoints(): CustomEndpoints { ) } -@Suppress("ComplexMethod") +@Suppress("CyclomaticComplexMethod") internal fun ReadableMap.asProxyConfig(): Pair? { val address: String? = getString("address") @@ -142,7 +142,7 @@ internal object DefaultConfiguration { const val initialResourceThreshold = 0.1 } -@Suppress("ComplexMethod") +@Suppress("CyclomaticComplexMethod") internal fun JSONDdSdkConfiguration.asDdSdkConfiguration(): DdSdkConfiguration { return DdSdkConfiguration( this.clientToken, @@ -220,7 +220,7 @@ internal fun List.asTracingHeaderTypes(): Set { }.toSet() } -@Suppress("ComplexMethod") +@Suppress("CyclomaticComplexMethod") internal fun DdSdkConfiguration.toReadableMap(): ReadableMap { val map = WritableNativeMap() map.putString("clientToken", clientToken) diff --git a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt index 7705483b2..cdd6b0614 100644 --- a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +++ b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt @@ -270,8 +270,7 @@ class DdSdkImplementation( } // endregion - - companion object { + internal companion object { internal const val DEFAULT_APP_VERSION = "?" internal const val DD_VERSION = "_dd.version" internal const val DD_VERSION_SUFFIX = "_dd.version_suffix" diff --git a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt index 67450add7..9c8e8370d 100644 --- a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +++ b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt @@ -108,7 +108,7 @@ class DdSdkNativeInitialization internal constructor( ?: DdSdkImplementation.DEFAULT_APP_VERSION } - @Suppress("ComplexMethod") + @Suppress("CyclomaticComplexMethod") private fun buildRumConfiguration(configuration: DdSdkConfiguration): RumConfiguration { val configBuilder = RumConfiguration.Builder( @@ -365,6 +365,7 @@ class DdSdkNativeInitialization internal constructor( } } + @Suppress("UndocumentedPublicClass") companion object { /** * Initializes the Datadog React Native SDK from your MainApplication. diff --git a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdTraceImplementation.kt b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdTraceImplementation.kt index 224b6c994..901ec3f6a 100644 --- a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdTraceImplementation.kt +++ b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdTraceImplementation.kt @@ -93,7 +93,7 @@ class DdTraceImplementation( } } - companion object { + internal companion object { internal const val NAME = "DdTrace" } } diff --git a/packages/internal-testing-tools/android/build.gradle b/packages/internal-testing-tools/android/build.gradle index 026b92c15..d3763a64a 100644 --- a/packages/internal-testing-tools/android/build.gradle +++ b/packages/internal-testing-tools/android/build.gradle @@ -1,6 +1,8 @@ import java.nio.file.Paths import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +apply plugin: "io.gitlab.arturbosch.detekt" + buildscript { // Buildscript is evaluated before everything else so we can't use getExtOrDefault def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['DatadogInternalTesting_kotlinVersion'] @@ -31,7 +33,6 @@ if (isNewArchitectureEnabled()) { } apply plugin: 'kotlin-android' apply plugin: 'org.jlleitschuh.gradle.ktlint' -apply plugin: "io.gitlab.arturbosch.detekt" /** * Finds the path of the installed npm package with the given name using Node's @@ -202,6 +203,9 @@ dependencies { testImplementation "com.github.xgouchet.Elmyr:jvm:1.3.1" testImplementation "org.mockito.kotlin:mockito-kotlin:5.1.0" testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + + detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.23.8" + detektPlugins "io.gitlab.arturbosch.detekt:detekt-rules-libraries:1.23.8" } tasks.withType(Test) { diff --git a/packages/internal-testing-tools/android/detekt.yml b/packages/internal-testing-tools/android/detekt.yml index c1376f3bf..08074aa73 100644 --- a/packages/internal-testing-tools/android/detekt.yml +++ b/packages/internal-testing-tools/android/detekt.yml @@ -1,14 +1,13 @@ build: maxIssues: 0 - weights: - # complexity: 2 - # LongParameterList: 1 - # style: 1 - # comments: 1 + +libraries: + LibraryCodeMustSpecifyReturnType: + active: true processors: active: true - exclude: + exclude: [] # - 'DetektProgressListener' # - 'FunctionCountProcessor' # - 'PropertyCountProcessor' @@ -23,7 +22,7 @@ console-reports: # - 'ComplexityReport' # - 'NotificationReport' # - 'FindingsReport' - - 'FileBasedFindingsReport' + - "FileBasedFindingsReport" # - 'BuildFailureReport' comments: @@ -37,17 +36,38 @@ comments: endOfSentenceFormat: ([.?!][ \t\n\r\f<])|([.?!:]$) UndocumentedPublicClass: active: true - excludes: [ "**/test/**","**/androidTest/**","**/*.Test.kt","**/*.Spec.kt","**/*.Spek.kt" ] + excludes: + [ + "**/test/**", + "**/androidTest/**", + "**/*.Test.kt", + "**/*.Spec.kt", + "**/*.Spek.kt", + ] searchInNestedClass: true searchInInnerClass: true searchInInnerObject: true searchInInnerInterface: true UndocumentedPublicFunction: active: true - excludes: [ "**/test/**","**/androidTest/**","**/*.Test.kt","**/*.Spec.kt","**/*.Spek.kt" ] + excludes: + [ + "**/test/**", + "**/androidTest/**", + "**/*.Test.kt", + "**/*.Spec.kt", + "**/*.Spek.kt", + ] UndocumentedPublicProperty: active: true - excludes: [ "**/test/**","**/androidTest/**","**/*.Test.kt","**/*.Spec.kt","**/*.Spek.kt" ] + excludes: + [ + "**/test/**", + "**/androidTest/**", + "**/*.Test.kt", + "**/*.Spec.kt", + "**/*.Spek.kt", + ] complexity: active: true @@ -58,14 +78,14 @@ complexity: active: true threshold: 10 includeStaticDeclarations: false - ComplexMethod: + CyclomaticComplexMethod: active: true threshold: 10 ignoreSingleWhenExpression: true ignoreSimpleWhenEntries: true LabeledExpression: active: true - ignoredLabels: "" + ignoredLabels: [] LargeClass: active: true threshold: 600 @@ -74,7 +94,8 @@ complexity: threshold: 60 LongParameterList: active: true - threshold: 6 + functionThreshold: 6 + constructorThreshold: 6 ignoreDefaultParameters: true MethodOverloading: active: true @@ -84,14 +105,24 @@ complexity: threshold: 4 StringLiteralDuplication: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" threshold: 3 ignoreAnnotation: true excludeStringsWithLessThan5Characters: true - ignoreStringsRegex: '$^' + ignoreStringsRegex: "$^" TooManyFunctions: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" thresholdInFiles: 11 thresholdInClasses: 11 thresholdInInterfaces: 11 @@ -99,7 +130,6 @@ complexity: thresholdInEnums: 11 ignoreDeprecated: true ignorePrivate: true - ignoreOverridden: true empty-blocks: active: true @@ -138,10 +168,19 @@ exceptions: active: true ExceptionRaisedInUnexpectedLocation: active: true - methodNames: 'toString,hashCode,equals,finalize' + methodNames: + - toString + - hashCode + - equals + - finalize InstanceOfCheckForException: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" NotImplementedDeclaration: active: true PrintStackTrace: @@ -153,7 +192,11 @@ exceptions: ignoreLabeled: true SwallowedException: active: true - ignoredExceptionTypes: 'InterruptedException,NumberFormatException,ParseException,MalformedURLException' + ignoredExceptionTypes: + - InterruptedException + - NumberFormatException + - ParseException + - MalformedURLException allowedExceptionNameRegex: "^(_|(ignore|expected).*)" ThrowingExceptionFromFinally: active: true @@ -161,12 +204,20 @@ exceptions: active: true ThrowingExceptionsWithoutMessageOrCause: active: true - exceptions: 'IllegalArgumentException,IllegalStateException,IOException' + exceptions: + - IllegalArgumentException + - IllegalStateException + - IOException ThrowingNewInstanceOfSameException: active: true TooGenericExceptionCaught: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" exceptionNames: - ArrayIndexOutOfBoundsException - Error @@ -210,7 +261,6 @@ formatting: active: true autoCorrect: true indentSize: 4 - continuationIndentSize: 4 MaximumLineLength: active: true maxLineLength: 120 @@ -292,45 +342,85 @@ naming: active: true ClassNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - classPattern: '[A-Z$][a-zA-Z0-9$]*' + 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: '$^' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + parameterPattern: "[a-z][A-Za-z0-9]*" + privateParameterPattern: "[a-z][A-Za-z0-9]*" + excludeClassPattern: "$^" EnumNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + enumEntryPattern: "^[A-Z][_a-zA-Z0-9]*" ForbiddenClassName: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - forbiddenName: '' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + forbiddenName: [] FunctionMaxLength: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" maximumFunctionNameLength: 30 FunctionMinLength: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + 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 + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + functionPattern: "^([a-z$][a-zA-Z$0-9]*)|(`.*`)$" + excludeClassPattern: "$^" + FunctionParameterNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - parameterPattern: '[a-z][A-Za-z0-9]*' - excludeClassPattern: '$^' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + parameterPattern: "[a-z][A-Za-z0-9]*" + excludeClassPattern: "$^" ignoreOverridden: true InvalidPackageDeclaration: active: true - rootPackage: '' + rootPackage: "" MatchingDeclarationName: active: true MemberNameEqualsClassName: @@ -338,35 +428,64 @@ naming: ignoreOverridden: 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]*' + 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" + 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]*' + 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: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" maximumVariableNameLength: 64 VariableMinLength: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + 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 + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + variablePattern: "[a-z][A-Za-z0-9]*" + privateVariablePattern: "(_)?[a-z][A-Za-z0-9]*" + excludeClassPattern: "$^" performance: active: true @@ -374,10 +493,20 @@ performance: active: true ForEachOnRange: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" SpreadOperator: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" UnnecessaryTemporaryInstantiation: active: true @@ -385,8 +514,6 @@ potential-bugs: active: true Deprecation: active: true - DuplicateCaseInWhenExpression: - active: true EqualsAlwaysReturnsTrueOrFalse: active: true EqualsWithHashCodeExist: @@ -403,13 +530,14 @@ potential-bugs: active: true LateinitUsage: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - excludeAnnotatedProperties: "" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + ignoreAnnotated: [] ignoreOnClassesPattern: "" - MissingWhenCase: - active: true - RedundantElseInWhen: - active: true UnconditionalJumpStatementInLoop: active: true UnreachableCode: @@ -429,7 +557,7 @@ style: active: true DataClassContainsFunctions: active: true - conversionFunctionPrefix: 'to' + conversionFunctionPrefix: ["to"] DataClassShouldBeImmutable: active: true EqualsNullCall: @@ -443,11 +571,17 @@ style: includeLineWrapping: false ForbiddenComment: active: true - values: 'TODO:,FIXME:,STOPSHIP:' + comments: + - reason: "Forbidden FIXME todo marker in comment, please fix the problem." + value: "FIXME:" + - reason: "Forbidden STOPSHIP todo marker in comment, please address the problem before shipping the code." + value: "STOPSHIP:" + - reason: "Forbidden TODO todo marker in comment, please do the changes, or add Jira ticket reference and suppress the warning." + value: "TODO:" allowedPatterns: "" ForbiddenImport: active: true - imports: '' + imports: [] forbiddenPatterns: "" ForbiddenVoid: active: true @@ -456,17 +590,24 @@ style: FunctionOnlyReturningConstant: active: true ignoreOverridableFunction: true - excludedFunctions: 'describeContents' - excludeAnnotatedFunction: "dagger.Provides" - LibraryCodeMustSpecifyReturnType: - active: true + excludedFunctions: ["describeContents"] + ignoreAnnotated: ["dagger.Provides"] LoopWithTooManyJumpStatements: active: true maxJumpCount: 1 MagicNumber: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - ignoreNumbers: '-1,0,1,2' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + ignoreNumbers: + - "-1" + - "0" + - "1" + - "2" ignoreHashCodeFunction: true ignorePropertyDeclaration: false ignoreConstantDeclaration: true @@ -475,8 +616,9 @@ style: ignoreNamedArgument: true ignoreEnums: false ignoreRanges: false - MandatoryBracesIfStatements: - active: true + BracesOnIfStatements: + singleLine: consistent + multiLine: always MaxLineLength: active: true maxLineLength: 120 @@ -497,7 +639,7 @@ style: active: true OptionalUnit: active: true - OptionalWhenBraces: + BracesOnWhenStatements: active: true PreferToOverPairSyntax: active: true @@ -510,7 +652,7 @@ style: ReturnCount: active: true max: 2 - excludedFunctions: "equals" + excludedFunctions: ["equals"] excludeLabeled: false excludeReturnFromLambda: true excludeGuardClauses: true @@ -527,10 +669,10 @@ style: active: true UnderscoresInNumericLiterals: active: true - acceptableDecimalLength: 5 + acceptableLength: 5 UnnecessaryAbstractClass: active: true - excludeAnnotatedClasses: "dagger.Module" + ignoreAnnotated: ["dagger.Module"] UnnecessaryApply: active: true UnnecessaryInheritance: @@ -554,7 +696,7 @@ style: active: true UseDataClass: active: true - excludeAnnotatedClasses: "" + ignoreAnnotated: [""] allowVars: true UseIfInsteadOfWhen: active: true @@ -568,5 +710,12 @@ style: active: true WildcardImport: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - excludeImports: 'java.util.*,kotlinx.android.synthetic.*' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + excludeImports: + - java.util.* + - kotlinx.android.synthetic.* diff --git a/packages/internal-testing-tools/android/src/main/kotlin/com/datadog/reactnative/internaltesting/DdInternalTestingImplementation.kt b/packages/internal-testing-tools/android/src/main/kotlin/com/datadog/reactnative/internaltesting/DdInternalTestingImplementation.kt index ca143f18a..197a9df75 100644 --- a/packages/internal-testing-tools/android/src/main/kotlin/com/datadog/reactnative/internaltesting/DdInternalTestingImplementation.kt +++ b/packages/internal-testing-tools/android/src/main/kotlin/com/datadog/reactnative/internaltesting/DdInternalTestingImplementation.kt @@ -59,7 +59,7 @@ class DdInternalTestingImplementation { } - companion object { + internal companion object { internal const val NAME = "DdInternalTesting" } } diff --git a/packages/react-native-session-replay/android/build.gradle b/packages/react-native-session-replay/android/build.gradle index 0b6589abd..9cb376929 100644 --- a/packages/react-native-session-replay/android/build.gradle +++ b/packages/react-native-session-replay/android/build.gradle @@ -1,6 +1,8 @@ import java.nio.file.Paths import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +apply plugin: "io.gitlab.arturbosch.detekt" + buildscript { // Buildscript is evaluated before everything else so we can't use getExtOrDefault def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['DatadogSDKReactNativeSessionReplay_kotlinVersion'] @@ -34,7 +36,6 @@ if (isNewArchitectureEnabled()) { } apply plugin: 'kotlin-android' apply plugin: 'org.jlleitschuh.gradle.ktlint' -apply plugin: "io.gitlab.arturbosch.detekt" /** * Finds the path of the installed npm package with the given name using Node's @@ -228,6 +229,10 @@ dependencies { testImplementation "com.github.xgouchet.Elmyr:jvm:1.3.1" testImplementation "org.mockito.kotlin:mockito-kotlin:5.1.0" testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + + detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.23.8" + detektPlugins "io.gitlab.arturbosch.detekt:detekt-rules-libraries:1.23.8" + unmock 'org.robolectric:android-all:4.4_r1-robolectric-r2' } diff --git a/packages/react-native-session-replay/android/detekt.yml b/packages/react-native-session-replay/android/detekt.yml index c1376f3bf..08074aa73 100644 --- a/packages/react-native-session-replay/android/detekt.yml +++ b/packages/react-native-session-replay/android/detekt.yml @@ -1,14 +1,13 @@ build: maxIssues: 0 - weights: - # complexity: 2 - # LongParameterList: 1 - # style: 1 - # comments: 1 + +libraries: + LibraryCodeMustSpecifyReturnType: + active: true processors: active: true - exclude: + exclude: [] # - 'DetektProgressListener' # - 'FunctionCountProcessor' # - 'PropertyCountProcessor' @@ -23,7 +22,7 @@ console-reports: # - 'ComplexityReport' # - 'NotificationReport' # - 'FindingsReport' - - 'FileBasedFindingsReport' + - "FileBasedFindingsReport" # - 'BuildFailureReport' comments: @@ -37,17 +36,38 @@ comments: endOfSentenceFormat: ([.?!][ \t\n\r\f<])|([.?!:]$) UndocumentedPublicClass: active: true - excludes: [ "**/test/**","**/androidTest/**","**/*.Test.kt","**/*.Spec.kt","**/*.Spek.kt" ] + excludes: + [ + "**/test/**", + "**/androidTest/**", + "**/*.Test.kt", + "**/*.Spec.kt", + "**/*.Spek.kt", + ] searchInNestedClass: true searchInInnerClass: true searchInInnerObject: true searchInInnerInterface: true UndocumentedPublicFunction: active: true - excludes: [ "**/test/**","**/androidTest/**","**/*.Test.kt","**/*.Spec.kt","**/*.Spek.kt" ] + excludes: + [ + "**/test/**", + "**/androidTest/**", + "**/*.Test.kt", + "**/*.Spec.kt", + "**/*.Spek.kt", + ] UndocumentedPublicProperty: active: true - excludes: [ "**/test/**","**/androidTest/**","**/*.Test.kt","**/*.Spec.kt","**/*.Spek.kt" ] + excludes: + [ + "**/test/**", + "**/androidTest/**", + "**/*.Test.kt", + "**/*.Spec.kt", + "**/*.Spek.kt", + ] complexity: active: true @@ -58,14 +78,14 @@ complexity: active: true threshold: 10 includeStaticDeclarations: false - ComplexMethod: + CyclomaticComplexMethod: active: true threshold: 10 ignoreSingleWhenExpression: true ignoreSimpleWhenEntries: true LabeledExpression: active: true - ignoredLabels: "" + ignoredLabels: [] LargeClass: active: true threshold: 600 @@ -74,7 +94,8 @@ complexity: threshold: 60 LongParameterList: active: true - threshold: 6 + functionThreshold: 6 + constructorThreshold: 6 ignoreDefaultParameters: true MethodOverloading: active: true @@ -84,14 +105,24 @@ complexity: threshold: 4 StringLiteralDuplication: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" threshold: 3 ignoreAnnotation: true excludeStringsWithLessThan5Characters: true - ignoreStringsRegex: '$^' + ignoreStringsRegex: "$^" TooManyFunctions: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" thresholdInFiles: 11 thresholdInClasses: 11 thresholdInInterfaces: 11 @@ -99,7 +130,6 @@ complexity: thresholdInEnums: 11 ignoreDeprecated: true ignorePrivate: true - ignoreOverridden: true empty-blocks: active: true @@ -138,10 +168,19 @@ exceptions: active: true ExceptionRaisedInUnexpectedLocation: active: true - methodNames: 'toString,hashCode,equals,finalize' + methodNames: + - toString + - hashCode + - equals + - finalize InstanceOfCheckForException: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" NotImplementedDeclaration: active: true PrintStackTrace: @@ -153,7 +192,11 @@ exceptions: ignoreLabeled: true SwallowedException: active: true - ignoredExceptionTypes: 'InterruptedException,NumberFormatException,ParseException,MalformedURLException' + ignoredExceptionTypes: + - InterruptedException + - NumberFormatException + - ParseException + - MalformedURLException allowedExceptionNameRegex: "^(_|(ignore|expected).*)" ThrowingExceptionFromFinally: active: true @@ -161,12 +204,20 @@ exceptions: active: true ThrowingExceptionsWithoutMessageOrCause: active: true - exceptions: 'IllegalArgumentException,IllegalStateException,IOException' + exceptions: + - IllegalArgumentException + - IllegalStateException + - IOException ThrowingNewInstanceOfSameException: active: true TooGenericExceptionCaught: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" exceptionNames: - ArrayIndexOutOfBoundsException - Error @@ -210,7 +261,6 @@ formatting: active: true autoCorrect: true indentSize: 4 - continuationIndentSize: 4 MaximumLineLength: active: true maxLineLength: 120 @@ -292,45 +342,85 @@ naming: active: true ClassNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - classPattern: '[A-Z$][a-zA-Z0-9$]*' + 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: '$^' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + parameterPattern: "[a-z][A-Za-z0-9]*" + privateParameterPattern: "[a-z][A-Za-z0-9]*" + excludeClassPattern: "$^" EnumNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + enumEntryPattern: "^[A-Z][_a-zA-Z0-9]*" ForbiddenClassName: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - forbiddenName: '' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + forbiddenName: [] FunctionMaxLength: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" maximumFunctionNameLength: 30 FunctionMinLength: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + 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 + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + functionPattern: "^([a-z$][a-zA-Z$0-9]*)|(`.*`)$" + excludeClassPattern: "$^" + FunctionParameterNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - parameterPattern: '[a-z][A-Za-z0-9]*' - excludeClassPattern: '$^' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + parameterPattern: "[a-z][A-Za-z0-9]*" + excludeClassPattern: "$^" ignoreOverridden: true InvalidPackageDeclaration: active: true - rootPackage: '' + rootPackage: "" MatchingDeclarationName: active: true MemberNameEqualsClassName: @@ -338,35 +428,64 @@ naming: ignoreOverridden: 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]*' + 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" + 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]*' + 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: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" maximumVariableNameLength: 64 VariableMinLength: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + 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 + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + variablePattern: "[a-z][A-Za-z0-9]*" + privateVariablePattern: "(_)?[a-z][A-Za-z0-9]*" + excludeClassPattern: "$^" performance: active: true @@ -374,10 +493,20 @@ performance: active: true ForEachOnRange: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" SpreadOperator: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" UnnecessaryTemporaryInstantiation: active: true @@ -385,8 +514,6 @@ potential-bugs: active: true Deprecation: active: true - DuplicateCaseInWhenExpression: - active: true EqualsAlwaysReturnsTrueOrFalse: active: true EqualsWithHashCodeExist: @@ -403,13 +530,14 @@ potential-bugs: active: true LateinitUsage: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - excludeAnnotatedProperties: "" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + ignoreAnnotated: [] ignoreOnClassesPattern: "" - MissingWhenCase: - active: true - RedundantElseInWhen: - active: true UnconditionalJumpStatementInLoop: active: true UnreachableCode: @@ -429,7 +557,7 @@ style: active: true DataClassContainsFunctions: active: true - conversionFunctionPrefix: 'to' + conversionFunctionPrefix: ["to"] DataClassShouldBeImmutable: active: true EqualsNullCall: @@ -443,11 +571,17 @@ style: includeLineWrapping: false ForbiddenComment: active: true - values: 'TODO:,FIXME:,STOPSHIP:' + comments: + - reason: "Forbidden FIXME todo marker in comment, please fix the problem." + value: "FIXME:" + - reason: "Forbidden STOPSHIP todo marker in comment, please address the problem before shipping the code." + value: "STOPSHIP:" + - reason: "Forbidden TODO todo marker in comment, please do the changes, or add Jira ticket reference and suppress the warning." + value: "TODO:" allowedPatterns: "" ForbiddenImport: active: true - imports: '' + imports: [] forbiddenPatterns: "" ForbiddenVoid: active: true @@ -456,17 +590,24 @@ style: FunctionOnlyReturningConstant: active: true ignoreOverridableFunction: true - excludedFunctions: 'describeContents' - excludeAnnotatedFunction: "dagger.Provides" - LibraryCodeMustSpecifyReturnType: - active: true + excludedFunctions: ["describeContents"] + ignoreAnnotated: ["dagger.Provides"] LoopWithTooManyJumpStatements: active: true maxJumpCount: 1 MagicNumber: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - ignoreNumbers: '-1,0,1,2' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + ignoreNumbers: + - "-1" + - "0" + - "1" + - "2" ignoreHashCodeFunction: true ignorePropertyDeclaration: false ignoreConstantDeclaration: true @@ -475,8 +616,9 @@ style: ignoreNamedArgument: true ignoreEnums: false ignoreRanges: false - MandatoryBracesIfStatements: - active: true + BracesOnIfStatements: + singleLine: consistent + multiLine: always MaxLineLength: active: true maxLineLength: 120 @@ -497,7 +639,7 @@ style: active: true OptionalUnit: active: true - OptionalWhenBraces: + BracesOnWhenStatements: active: true PreferToOverPairSyntax: active: true @@ -510,7 +652,7 @@ style: ReturnCount: active: true max: 2 - excludedFunctions: "equals" + excludedFunctions: ["equals"] excludeLabeled: false excludeReturnFromLambda: true excludeGuardClauses: true @@ -527,10 +669,10 @@ style: active: true UnderscoresInNumericLiterals: active: true - acceptableDecimalLength: 5 + acceptableLength: 5 UnnecessaryAbstractClass: active: true - excludeAnnotatedClasses: "dagger.Module" + ignoreAnnotated: ["dagger.Module"] UnnecessaryApply: active: true UnnecessaryInheritance: @@ -554,7 +696,7 @@ style: active: true UseDataClass: active: true - excludeAnnotatedClasses: "" + ignoreAnnotated: [""] allowVars: true UseIfInsteadOfWhen: active: true @@ -568,5 +710,12 @@ style: active: true WildcardImport: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - excludeImports: 'java.util.*,kotlinx.android.synthetic.*' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + excludeImports: + - java.util.* + - kotlinx.android.synthetic.* diff --git a/packages/react-native-session-replay/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementation.kt b/packages/react-native-session-replay/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementation.kt index acf13120a..9a6c1b3c5 100644 --- a/packages/react-native-session-replay/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementation.kt +++ b/packages/react-native-session-replay/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementation.kt @@ -83,7 +83,7 @@ class DdSessionReplayImplementation( promise.resolve(null) } - companion object { + internal companion object { internal const val NAME = "DdSessionReplay" } } diff --git a/packages/react-native-session-replay/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplayPrivacySettings.kt b/packages/react-native-session-replay/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplayPrivacySettings.kt index 5af4819fe..c38784b4d 100644 --- a/packages/react-native-session-replay/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplayPrivacySettings.kt +++ b/packages/react-native-session-replay/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplayPrivacySettings.kt @@ -39,8 +39,8 @@ class SessionReplayPrivacySettings( */ val textAndInputPrivacyLevel = getTextAndInputPrivacy(textAndInputPrivacyLevel) - companion object { - internal fun getImagePrivacy(imagePrivacyLevel: String): ImagePrivacy { + internal companion object { + fun getImagePrivacy(imagePrivacyLevel: String): ImagePrivacy { return when (imagePrivacyLevel) { "MASK_NON_BUNDLED_ONLY" -> ImagePrivacy.MASK_LARGE_ONLY "MASK_ALL" -> ImagePrivacy.MASK_ALL @@ -56,7 +56,7 @@ class SessionReplayPrivacySettings( } } - internal fun getTouchPrivacy(touchPrivacyLevel: String): TouchPrivacy { + fun getTouchPrivacy(touchPrivacyLevel: String): TouchPrivacy { return when (touchPrivacyLevel) { "SHOW" -> TouchPrivacy.SHOW "HIDE" -> TouchPrivacy.HIDE @@ -71,7 +71,7 @@ class SessionReplayPrivacySettings( } } - internal fun getTextAndInputPrivacy(textAndInputPrivacyLevel: String): TextAndInputPrivacy { + fun getTextAndInputPrivacy(textAndInputPrivacyLevel: String): TextAndInputPrivacy { return when (textAndInputPrivacyLevel) { "MASK_SENSITIVE_INPUTS" -> TextAndInputPrivacy.MASK_SENSITIVE_INPUTS "MASK_ALL_INPUTS" -> TextAndInputPrivacy.MASK_ALL_INPUTS diff --git a/packages/react-native-webview/android/build.gradle b/packages/react-native-webview/android/build.gradle index faad9d68f..145cb1528 100644 --- a/packages/react-native-webview/android/build.gradle +++ b/packages/react-native-webview/android/build.gradle @@ -208,6 +208,10 @@ dependencies { testImplementation "com.github.xgouchet.Elmyr:jvm:1.3.1" testImplementation "org.mockito.kotlin:mockito-kotlin:5.1.0" testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + + detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.23.8" + detektPlugins "io.gitlab.arturbosch.detekt:detekt-rules-libraries:1.23.8" + unmock 'org.robolectric:android-all:4.4_r1-robolectric-r2' } diff --git a/packages/react-native-webview/android/detekt.yml b/packages/react-native-webview/android/detekt.yml index c1376f3bf..08074aa73 100644 --- a/packages/react-native-webview/android/detekt.yml +++ b/packages/react-native-webview/android/detekt.yml @@ -1,14 +1,13 @@ build: maxIssues: 0 - weights: - # complexity: 2 - # LongParameterList: 1 - # style: 1 - # comments: 1 + +libraries: + LibraryCodeMustSpecifyReturnType: + active: true processors: active: true - exclude: + exclude: [] # - 'DetektProgressListener' # - 'FunctionCountProcessor' # - 'PropertyCountProcessor' @@ -23,7 +22,7 @@ console-reports: # - 'ComplexityReport' # - 'NotificationReport' # - 'FindingsReport' - - 'FileBasedFindingsReport' + - "FileBasedFindingsReport" # - 'BuildFailureReport' comments: @@ -37,17 +36,38 @@ comments: endOfSentenceFormat: ([.?!][ \t\n\r\f<])|([.?!:]$) UndocumentedPublicClass: active: true - excludes: [ "**/test/**","**/androidTest/**","**/*.Test.kt","**/*.Spec.kt","**/*.Spek.kt" ] + excludes: + [ + "**/test/**", + "**/androidTest/**", + "**/*.Test.kt", + "**/*.Spec.kt", + "**/*.Spek.kt", + ] searchInNestedClass: true searchInInnerClass: true searchInInnerObject: true searchInInnerInterface: true UndocumentedPublicFunction: active: true - excludes: [ "**/test/**","**/androidTest/**","**/*.Test.kt","**/*.Spec.kt","**/*.Spek.kt" ] + excludes: + [ + "**/test/**", + "**/androidTest/**", + "**/*.Test.kt", + "**/*.Spec.kt", + "**/*.Spek.kt", + ] UndocumentedPublicProperty: active: true - excludes: [ "**/test/**","**/androidTest/**","**/*.Test.kt","**/*.Spec.kt","**/*.Spek.kt" ] + excludes: + [ + "**/test/**", + "**/androidTest/**", + "**/*.Test.kt", + "**/*.Spec.kt", + "**/*.Spek.kt", + ] complexity: active: true @@ -58,14 +78,14 @@ complexity: active: true threshold: 10 includeStaticDeclarations: false - ComplexMethod: + CyclomaticComplexMethod: active: true threshold: 10 ignoreSingleWhenExpression: true ignoreSimpleWhenEntries: true LabeledExpression: active: true - ignoredLabels: "" + ignoredLabels: [] LargeClass: active: true threshold: 600 @@ -74,7 +94,8 @@ complexity: threshold: 60 LongParameterList: active: true - threshold: 6 + functionThreshold: 6 + constructorThreshold: 6 ignoreDefaultParameters: true MethodOverloading: active: true @@ -84,14 +105,24 @@ complexity: threshold: 4 StringLiteralDuplication: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" threshold: 3 ignoreAnnotation: true excludeStringsWithLessThan5Characters: true - ignoreStringsRegex: '$^' + ignoreStringsRegex: "$^" TooManyFunctions: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" thresholdInFiles: 11 thresholdInClasses: 11 thresholdInInterfaces: 11 @@ -99,7 +130,6 @@ complexity: thresholdInEnums: 11 ignoreDeprecated: true ignorePrivate: true - ignoreOverridden: true empty-blocks: active: true @@ -138,10 +168,19 @@ exceptions: active: true ExceptionRaisedInUnexpectedLocation: active: true - methodNames: 'toString,hashCode,equals,finalize' + methodNames: + - toString + - hashCode + - equals + - finalize InstanceOfCheckForException: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" NotImplementedDeclaration: active: true PrintStackTrace: @@ -153,7 +192,11 @@ exceptions: ignoreLabeled: true SwallowedException: active: true - ignoredExceptionTypes: 'InterruptedException,NumberFormatException,ParseException,MalformedURLException' + ignoredExceptionTypes: + - InterruptedException + - NumberFormatException + - ParseException + - MalformedURLException allowedExceptionNameRegex: "^(_|(ignore|expected).*)" ThrowingExceptionFromFinally: active: true @@ -161,12 +204,20 @@ exceptions: active: true ThrowingExceptionsWithoutMessageOrCause: active: true - exceptions: 'IllegalArgumentException,IllegalStateException,IOException' + exceptions: + - IllegalArgumentException + - IllegalStateException + - IOException ThrowingNewInstanceOfSameException: active: true TooGenericExceptionCaught: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" exceptionNames: - ArrayIndexOutOfBoundsException - Error @@ -210,7 +261,6 @@ formatting: active: true autoCorrect: true indentSize: 4 - continuationIndentSize: 4 MaximumLineLength: active: true maxLineLength: 120 @@ -292,45 +342,85 @@ naming: active: true ClassNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - classPattern: '[A-Z$][a-zA-Z0-9$]*' + 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: '$^' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + parameterPattern: "[a-z][A-Za-z0-9]*" + privateParameterPattern: "[a-z][A-Za-z0-9]*" + excludeClassPattern: "$^" EnumNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + enumEntryPattern: "^[A-Z][_a-zA-Z0-9]*" ForbiddenClassName: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - forbiddenName: '' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + forbiddenName: [] FunctionMaxLength: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" maximumFunctionNameLength: 30 FunctionMinLength: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + 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 + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + functionPattern: "^([a-z$][a-zA-Z$0-9]*)|(`.*`)$" + excludeClassPattern: "$^" + FunctionParameterNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - parameterPattern: '[a-z][A-Za-z0-9]*' - excludeClassPattern: '$^' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + parameterPattern: "[a-z][A-Za-z0-9]*" + excludeClassPattern: "$^" ignoreOverridden: true InvalidPackageDeclaration: active: true - rootPackage: '' + rootPackage: "" MatchingDeclarationName: active: true MemberNameEqualsClassName: @@ -338,35 +428,64 @@ naming: ignoreOverridden: 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]*' + 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" + 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]*' + 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: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" maximumVariableNameLength: 64 VariableMinLength: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + 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 + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + variablePattern: "[a-z][A-Za-z0-9]*" + privateVariablePattern: "(_)?[a-z][A-Za-z0-9]*" + excludeClassPattern: "$^" performance: active: true @@ -374,10 +493,20 @@ performance: active: true ForEachOnRange: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" SpreadOperator: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" UnnecessaryTemporaryInstantiation: active: true @@ -385,8 +514,6 @@ potential-bugs: active: true Deprecation: active: true - DuplicateCaseInWhenExpression: - active: true EqualsAlwaysReturnsTrueOrFalse: active: true EqualsWithHashCodeExist: @@ -403,13 +530,14 @@ potential-bugs: active: true LateinitUsage: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - excludeAnnotatedProperties: "" + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + ignoreAnnotated: [] ignoreOnClassesPattern: "" - MissingWhenCase: - active: true - RedundantElseInWhen: - active: true UnconditionalJumpStatementInLoop: active: true UnreachableCode: @@ -429,7 +557,7 @@ style: active: true DataClassContainsFunctions: active: true - conversionFunctionPrefix: 'to' + conversionFunctionPrefix: ["to"] DataClassShouldBeImmutable: active: true EqualsNullCall: @@ -443,11 +571,17 @@ style: includeLineWrapping: false ForbiddenComment: active: true - values: 'TODO:,FIXME:,STOPSHIP:' + comments: + - reason: "Forbidden FIXME todo marker in comment, please fix the problem." + value: "FIXME:" + - reason: "Forbidden STOPSHIP todo marker in comment, please address the problem before shipping the code." + value: "STOPSHIP:" + - reason: "Forbidden TODO todo marker in comment, please do the changes, or add Jira ticket reference and suppress the warning." + value: "TODO:" allowedPatterns: "" ForbiddenImport: active: true - imports: '' + imports: [] forbiddenPatterns: "" ForbiddenVoid: active: true @@ -456,17 +590,24 @@ style: FunctionOnlyReturningConstant: active: true ignoreOverridableFunction: true - excludedFunctions: 'describeContents' - excludeAnnotatedFunction: "dagger.Provides" - LibraryCodeMustSpecifyReturnType: - active: true + excludedFunctions: ["describeContents"] + ignoreAnnotated: ["dagger.Provides"] LoopWithTooManyJumpStatements: active: true maxJumpCount: 1 MagicNumber: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - ignoreNumbers: '-1,0,1,2' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + ignoreNumbers: + - "-1" + - "0" + - "1" + - "2" ignoreHashCodeFunction: true ignorePropertyDeclaration: false ignoreConstantDeclaration: true @@ -475,8 +616,9 @@ style: ignoreNamedArgument: true ignoreEnums: false ignoreRanges: false - MandatoryBracesIfStatements: - active: true + BracesOnIfStatements: + singleLine: consistent + multiLine: always MaxLineLength: active: true maxLineLength: 120 @@ -497,7 +639,7 @@ style: active: true OptionalUnit: active: true - OptionalWhenBraces: + BracesOnWhenStatements: active: true PreferToOverPairSyntax: active: true @@ -510,7 +652,7 @@ style: ReturnCount: active: true max: 2 - excludedFunctions: "equals" + excludedFunctions: ["equals"] excludeLabeled: false excludeReturnFromLambda: true excludeGuardClauses: true @@ -527,10 +669,10 @@ style: active: true UnderscoresInNumericLiterals: active: true - acceptableDecimalLength: 5 + acceptableLength: 5 UnnecessaryAbstractClass: active: true - excludeAnnotatedClasses: "dagger.Module" + ignoreAnnotated: ["dagger.Module"] UnnecessaryApply: active: true UnnecessaryInheritance: @@ -554,7 +696,7 @@ style: active: true UseDataClass: active: true - excludeAnnotatedClasses: "" + ignoreAnnotated: [""] allowVars: true UseIfInsteadOfWhen: active: true @@ -568,5 +710,12 @@ style: active: true WildcardImport: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - excludeImports: 'java.util.*,kotlinx.android.synthetic.*' + excludes: + - "**/test/**" + - "**/androidTest/**" + - "**/*.Test.kt" + - "**/*.Spec.kt" + - "**/*.Spek.kt" + excludeImports: + - java.util.* + - kotlinx.android.synthetic.*