Skip to content

Conversation

@zoeyul
Copy link

@zoeyul zoeyul commented Nov 13, 2025

Description

Fixes Android barcode scanning returning empty array despite successful detection.

Problem

Arguments.fromList() does not properly handle List<WritableMap>, causing it to return an empty array even when barcodes are successfully detected on Android.

Solution

Changed to use Arguments.createArray() with pushMap() to properly handle WritableMap objects, which is the correct way to pass complex objects through the React Native bridge.

Changes

  • Modified ImageCodeScannerModule.kt lines 253-254
  • Replaced Arguments.fromList(codes) with Arguments.createArray() + forEach loop with pushMap()

Summary by CodeRabbit

  • Refactor
    • Optimized internal barcode result processing in the image scanner module for improved performance.

…ection

Arguments.fromList() does not properly handle List<WritableMap>,
causing it to return an empty array even when barcodes are
successfully detected on Android.

Changed to use Arguments.createArray() with pushMap() to properly
handle WritableMap objects.

Fixes barcode results not being returned on Android.
@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Walkthrough

Modified array result construction in ImageCodeScannerModule.kt, changing from Arguments.fromList() to manual array creation via Arguments.createArray() with iterative pushMap() calls for each barcode mapping.

Changes

Cohort / File(s) Summary
Array Construction Refactoring
android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt
Replaced Arguments.fromList(codes) with manual array construction: Arguments.createArray() followed by iterative pushMap(code) for each barcode result entry

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify that manual pushMap() iteration produces functionally identical results to the original fromList() approach
  • Confirm no subtle differences in array serialization or barcode mapping between the two methods

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main fix: replacing Arguments.fromList() with Arguments.createArray() and pushMap() to resolve the Android barcode scanning bug that returned empty arrays.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt (2)

251-251: Consider removing redundant null filter.

The .filter { it != null } is unnecessary since mapNotNull on Line 226 already filters out null values by design.

Apply this diff to simplify the code:

                  }
-                  .filter { it != null }

209-210: Consider using consistent array creation pattern.

For consistency with the fix on lines 253-254, consider using Arguments.createArray() directly instead of Arguments.fromList(emptyList()).

Apply this diff for consistency:

-          val arr = Arguments.fromList(emptyList<String>())
+          val arr = Arguments.createArray()
           promise.resolve(arr)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09068fa and 2f01cb7.

📒 Files selected for processing (1)
  • android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt (1 hunks)
🔇 Additional comments (1)
android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt (1)

253-254: LGTM! Proper fix for WritableMap array serialization.

The change correctly addresses the bug where Arguments.fromList() doesn't handle List<WritableMap> properly. Using Arguments.createArray() with pushMap() is the standard React Native pattern for passing arrays of maps through the bridge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant