DataDog / dd-sdk-reactnative

Datadog SDK for ReactNative
Apache License 2.0
115 stars 41 forks source link

Build error caused by Lint rule ktlintMainSourceSetCheck #720

Open jayshah123 opened 2 weeks ago

jayshah123 commented 2 weeks ago

Describe the bug

Android build is affected by lint during RN build. Ideally check tasks do not make sense to run on a shipped library? esp like RN. We see build error on check tasks and that too of test files.

Reproduction steps

Run android build via npx react-native run-android

SDK logs

> Task :datadog_mobile-react-native:ktlintMainSourceSetCheck FAILED
/Users/jshah/workstuff/my-sample-app/node_modules/@datadog/mobile-react-native/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt:19:1 Unexpected indentation (4) (should be 2)
/Users/jshah/workstuff/my-sample-app/node_modules/@datadog/mobile-react-native/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt:20:1 Unexpected indentation (8) (should be 4)

...

> Task :app:bundleReleaseJsAndAssets
Execution optimizations have been disabled for task ':app:bundleReleaseJsAndAssets' to ensure correctness due to the following reasons:
  - Gradle detected a problem with the following location: '/Users/jshah/workstuff/my-sample-app'. Reason: Task ':app:bundleReleaseJsAndAssets' uses this output of task ':datadog_mobile-react-native:bundleDebugAar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.3.3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
  - Gradle detected a problem with the following location: '/Users/jshah/workstuff/my-sample-app'. Reason: Task ':app:bundleReleaseJsAndAssets' uses this output of task ':datadog_mobile-react-native:bundleLibCompileToJarDebug' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.3.3/userguide/validation_problems.html#implicit_dependency for more details about this problem.

...

> Task :datadog_mobile-react-native:ktlintTestSourceSetCheck FAILED
/Users/jshah/workstuff/my-sample-app/node_modules/@datadog/mobile-react-native/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt:38:1 Unexpected indentation (4) (should be 2)
/Users/jshah/workstuff/my-sample-app/node_modules/@datadog/mobile-react-native/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt:39:1 Unexpected indentation (4) (should be 2)

...
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':datadog_mobile-react-native:ktlintMainSourceSetCheck'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.ConsoleReportWorkAction
   > KtLint found code style violations. Please see the following reports:
     - /Users/jshah/workstuff/my-sample-app/node_modules/@datadog/mobile-react-native/android/build/reports/ktlint/ktlintMainSourceSetCheck/ktlintMainSourceSetCheck.txt

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

Expected behavior

No build error should be present

Affected SDK versions

"@datadog/mobile-react-native@1.7.1"

Latest working SDK version

"@datadog/mobile-react-native@1.7.1"

Did you confirm if the latest SDK version fixes the bug?

No, cannot easily upgrade

Integration Methods

Yarn

React Native Version

0.68.2

Package.json Contents

No response

iOS Setup

No response

Android Setup

No response

Device Information

Android emulator

Other relevant information

No response

marco-saia-datadog commented 1 week ago

Hi @jayshah123 👋

Thank you for reaching out! I see that you are using @datadog/mobile-react-native@1.7.1, which was released on Jun 8, 2023.

I would suggest updating to the latest version, where the problem should not persist. We will double check the issue in the meantime.

Is there anything blocking you from updating the SDK?

jayshah123 commented 1 week ago

I believe an RN upgrade might be needed. Is there a compatibility table available? Or all versions of your lib compatible with older versions of RN?

marco-saia-datadog commented 1 week ago

Our latest release supports v0.68.2, you can try updating and reach out if you encounter any issues.

If you have other Datadog packages installed, please make sure they have matching versions.