feat(lua): add sparse array encode controls#126
Conversation
|
Warning Review limit reached
More reviews will be available in 33 minutes and 3 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds a ChangesSparse-array Configuration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 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.
Actionable comments posted: 2
🤖 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.
Inline comments:
In `@docs/migrating-from-cjson.md`:
- Line 187: Update the phrasing in the sentence "qjson now supports lua-cjson
style sparse-array controls via" to hyphenate the compound modifier as
"lua-cjson-style" so it reads "qjson now supports lua-cjson-style sparse-array
controls via"; locate and replace that exact substring in the
docs/migrating-from-cjson.md content.
In `@lua/qjson/table.lua`:
- Around line 629-645: The setter _M.encode_sparse_array currently assigns
module-level flags (ENCODE_SPARSE_CONVERT, ENCODE_SPARSE_RATIO,
ENCODE_SPARSE_SAFE) before validating all inputs so a failing validation (e.g.
validate_non_negative_integer) can leave partial state changes; change the
implementation to stage incoming values into locals (e.g. local new_convert,
new_ratio, new_safe), run validate_non_negative_integer on new_ratio/new_safe as
needed, and only if all validations pass assign the staged locals back to the
module-level ENCODE_SPARSE_CONVERT, ENCODE_SPARSE_RATIO, ENCODE_SPARSE_SAFE;
keep the existing too-many-arguments check and behavior of convert defaulting to
true when not false.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4d85b9bb-7380-4e64-89fe-7c028248f7e0
📒 Files selected for processing (4)
docs/migrating-from-cjson.mdlua/qjson.lualua/qjson/table.luatests/lua/encode_cjson_compat_spec.lua
Summary
qjson.encode_sparse_array(convert, ratio, safe)as a lua-cjson compatible module-level getter/setterCloses #123
Tests
cargo test --releasecargo test --release --no-default-featurescargo test --features test-panic --releasemake lintDYLD_LIBRARY_PATH=$PWD/target/release LUA_PATH='./lua/?.lua;/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/?/init.lua;;' LUA_CPATH='./vendor/lua-cjson/?.so;./target/release/lib?.dylib;./target/release/lib?.so;./?.so;/usr/local/openresty/lualib/?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so' ~/.luarocks/bin/busted --lua=/opt/homebrew/bin/luajit tests/lua --lpath='./lua/?.lua'Summary by CodeRabbit
New Features
Documentation