Add configurable scanner preprocessing options#50
Conversation
|
Warning Review limit reached
Next review available in: 31 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR adds optional preprocessing flags to the JS scan API, forwards them to native Android and iOS implementations, and updates docs, build settings, and tooling to match the new behavior. ChangesPreprocessing Options Feature
Estimated code review effort: 3 (Moderate) | ~30 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt (1)
123-129: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider handling non-boolean values for cross-platform parity.
The iOS
boolOptionhelper (ImageCodeScanner.swift:114-123) falls back toNSNumber.boolValuewhen the value isn't aBool. The AndroidreadBooleanOptioncallsgetBooleandirectly, which throws if the bridge delivers a non-boolean (e.g., a number). For correct TypeScript usage this is a non-issue, but a JS caller bypassing types could seeIMAGE_LOAD_ERRORon Android while iOS silently coerces.♻️ Optional: add type-safe fallback
private fun readBooleanOption(options: ReadableMap, key: String, defaultValue: Boolean): Boolean { return if (options.hasKey(key) && !options.isNull(key)) { - options.getBoolean(key) + if (options.getType(key) == ReadableType.Boolean) { + options.getBoolean(key) + } else { + defaultValue + } } else { defaultValue } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt` around lines 123 - 129, The readBooleanOption helper in ImageCodeScannerModule.kt should mirror the iOS boolOption behavior by tolerating non-boolean bridge values instead of calling getBoolean directly. Update readBooleanOption to inspect the value from the ReadableMap and, when it is not a Boolean, fall back to a NSNumber-style boolean coercion equivalent for Android while preserving the defaultValue when the key is missing or null. Keep the change localized to readBooleanOption so callers continue using the same API without triggering IMAGE_LOAD_ERROR on coerced inputs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt`:
- Around line 123-129: The readBooleanOption helper in ImageCodeScannerModule.kt
should mirror the iOS boolOption behavior by tolerating non-boolean bridge
values instead of calling getBoolean directly. Update readBooleanOption to
inspect the value from the ReadableMap and, when it is not a Boolean, fall back
to a NSNumber-style boolean coercion equivalent for Android while preserving the
defaultValue when the key is missing or null. Keep the change localized to
readBooleanOption so callers continue using the same API without triggering
IMAGE_LOAD_ERROR on coerced inputs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ddf493ad-6b82-4327-8910-d100956d4cb0
📒 Files selected for processing (12)
COMPATIBILITY.mdREADME.mdandroid/gradle.propertiesandroid/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kteslint.config.mjsexample/package.jsonexample/tsconfig.jsonios/ImageCodeScanner.swiftpackage.jsonscripts/validate-package.jssrc/__tests__/index.test.tsxsrc/index.tsx
There was a problem hiding this comment.
🧹 Nitpick comments (1)
package.json (1)
66-67: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAlign version pinning for React Native tooling packages.
@react-native/babel-presetis pinned at0.79.2(no caret) while@react-native/eslint-configuses^0.79.2(with caret). Both are React Native 0.79.2 tooling packages — the caret on eslint-config could resolve to a newer version, causing drift from the pinnedreact-nativeandbabel-presetversions. Consider using a consistent strategy (either both pinned or both with caret) to avoid mismatched tooling behavior.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@package.json` around lines 66 - 67, The React Native tooling dependencies use inconsistent version pinning, with `@react-native/babel-preset` pinned exactly and `@react-native/eslint-config` using a caret. Update the dependency declarations in package.json to follow one consistent strategy for both packages, matching the version style already used for the other React Native tooling entries so they stay aligned with react-native and babel-preset.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@package.json`:
- Around line 66-67: The React Native tooling dependencies use inconsistent
version pinning, with `@react-native/babel-preset` pinned exactly and
`@react-native/eslint-config` using a caret. Update the dependency declarations in
package.json to follow one consistent strategy for both packages, matching the
version style already used for the other React Native tooling entries so they
stay aligned with react-native and babel-preset.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a7016315-08b4-415e-94dc-a9ac0de3acd6
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (3)
android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.ktios/ImageCodeScanner.swiftpackage.json
🚧 Files skipped from review as they are similar to previous changes (2)
- ios/ImageCodeScanner.swift
- android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt
Summary
Adds configurable image preprocessing options for scanner calls and improves local image path handling across platforms.
Changes
enhanceContrast,convertToGrayscale, andtryRotationsscan options, defaulting to the existing behavior.content://image URIs and safer percent-decoded file path handling.Verification
yarn typecheckyarn lintyarn test --runInBand --watchman=falseyarn buildnode scripts/validate-package.jsgit diff --checkNotes
yarn test --runInBandwithout--watchman=falsefailed in the sandbox because Watchman could not write its state file.Summary by CodeRabbit
enhanceContrast,convertToGrayscale, andtryRotations.content://URIs and iOS percent-encodedfile://paths.