_⚠️ Potential issue_ | _🟡 Minor_
**Lint failure: `Layout/SpaceInsideArrayLiteralBrackets` on lines 27–28.**
The CI lint check reports multiple `SpaceInsideArrayLiteralBrackets` violations. Add spaces inside the array brackets to satisfy the project's RuboCop config.
Additionally, the multi-key `.where.not(username: …, document: …, password: …)` negates the *conjunction*, so it matches items where **at least one** of the three fields is non-blank — not items where **all three** are present. This could return `true` for partially-configured items.
<details>
<summary>Proposed fix</summary>
```diff
def has_indexa_capital_credentials?
- indexa_capital_items.where.not(api_token: [nil, ""]).or(
- indexa_capital_items.where.not(username: [nil, ""], document: [nil, ""], password: [nil, ""])
- ).exists?
+ indexa_capital_items.where.not(api_token: [ nil, "" ]).or(
+ indexa_capital_items.where.not(username: [ nil, "" ])
+ .where.not(document: [ nil, "" ])
+ .where.not(password: [ nil, "" ])
+ ).exists?
end
PR #933 unaddressed review comments
Source: #933
Review comments (no replies)
chatgpt-codex-connector[bot]:
Handle zero balances when importing Indexa Capital accounts
Full comment
coderabbitai[bot]:⚠️ Potential issue | 🟠 Major
Full comment
🤖 Prompt for AI Agents
coderabbitai[bot]:⚠️ Potential issue | 🟠 Major
Full comment
In
@app/controllers/indexa_capital_items_controller.rbaround lines 347 - 379,fetch_accounts_synchronously currently does an N+1 by calling
provider.get_account_balance per account after provider.list_accounts; replace
this with a single batched retrieval (e.g. use a provider method like
batch_get_account_balances or get_accounts_balances that accepts an array of
account_numbers and returns a map of balances) and merge those balances into
accounts_data before upserting, or if the provider has no batch API, move the
per-account balance fetch into an async/background job (or use
parallel/concurrent requests) to avoid blocking the request thread; update
references to indexa_capital_item.indexa_capital_provider, list_accounts and
get_account_balance accordingly and remove the per-account rescue inside the
loop so errors are handled centrally (auth/API errors remain handled by the
existing rescue clauses).
coderabbitai[bot]:⚠️ Potential issue | 🟠 Major
Full comment
Repository: we-promise/sure
Length of output: 1195
🏁 Script executed:
Repository: we-promise/sure
Length of output: 1941
🏁 Script executed:
cat -n app/jobs/snaptrade_activities_fetch_job.rb | head -20Repository: we-promise/sure
Length of output: 941
🏁 Script executed:
Repository: we-promise/sure
Length of output: 686
Fix
lock_args_methodto extract the account ID for stable lock key.args.firstpasses the ActiveRecord object, whose stringification may be unstable. Extract the ID instead, following the pattern established insnaptrade_activities_fetch_job.rb:🤖 Prompt for AI Agents
coderabbitai[bot]:⚠️ Potential issue | 🔴 Critical
Full comment
Repository: we-promise/sure
Length of output: 2193
🏁 Script executed:
Repository: we-promise/sure
Length of output: 4464
🏁 Script executed:
Repository: we-promise/sure
Length of output: 2538
🏁 Script executed:
Repository: we-promise/sure
Length of output: 2130
Fix
find_byto include exchange when resolving securities.resolve_securitycallsSecurity.find_by(ticker: ticker)without consideringexchange_operating_mic, but the database allows multiple securities with the same ticker (one per exchange). The unique constraint is composite:[ticker, exchange_operating_mic]. This causes the code to return an arbitrary security when multiple exist with the same ticker, risking lookup of the wrong security.Update the lookup to:
exchange_operating_micin bothfind_bycalls (lines 66 and 91)tickeralone if single-ticker uniqueness is the intended design🤖 Prompt for AI Agents
coderabbitai[bot]:⚠️ Potential issue | 🔴 Critical
Full comment
🤖 Prompt for AI Agents
✅ Addressed in commit 98f1898
coderabbitai[bot]:⚠️ Potential issue | 🟠 Major
Full comment
📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit 98f1898
coderabbitai[bot]:⚠️ Potential issue | 🟠 Major
Full comment
🤖 Prompt for AI Agents
✅ Addressed in commit 98f1898
coderabbitai[bot]:⚠️ Potential issue | 🟠 Major
Full comment
Repository: we-promise/sure
Length of output: 92
🏁 Script executed:
Repository: we-promise/sure
Length of output: 2935
🏁 Script executed:
# Check the IndexaCapitalItem model for encryption declarations cat -n app/models/indexa_capital_item.rbRepository: we-promise/sure
Length of output: 7170
Encrypt
usernameanddocumentcredential fields alongsidepassword.The
passwordfield is correctly encrypted at the model level (line 19 ofapp/models/indexa_capital_item.rb). However,usernameanddocumentremain unencrypted despite being part of the credential set. Addencrypts :username, :document, deterministic: trueto the encryption block (lines 18-21) so all credentials are protected at rest.🤖 Prompt for AI Agents
coderabbitai[bot]:⚠️ Potential issue | 🟠 Major
Full comment
In
@test/models/indexa_capital_account/processor_test.rbaround lines 29 - 132,Unskip and activate the processor tests by wiring a real test fixture for
IndexaCapitalAccount used by tests like "processor initializes with
indexa_capital_account", "holdings processor creates holdings from raw payload",
and "activities processor creates trades from raw payload": in the test setup
create and assign
@indexa_capital_accountwith a linked Account andAccountProvider (or remove the link for the "skips processing when no linked
account" test), ensure
@accountexists, create any related Security records(e.g., ticker "AAPL") and set raw payloads on
@indexa_capital_account(raw_holdings_payload, raw_activities_payload) for HoldingsProcessor and
ActivitiesProcessor tests, then remove the skip calls and restore the commented
assertions so the tests instantiate IndexaCapitalAccount::Processor,
IndexaCapitalAccount::HoldingsProcessor, and
IndexaCapitalAccount::ActivitiesProcessor, call process, and assert expected
results (account balance, holding qty, created entry/trade, and no-op behaviors
when symbol or external_id are blank).
coderabbitai[bot]:⚠️ Potential issue | 🟡 Minor
Full comment
📝 Committable suggestion
🧰 Tools
🪛 GitHub Check: ci / lint
[failure] 28-28:
Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.
[failure] 28-28:
Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.
[failure] 28-28:
Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.
[failure] 28-28:
Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.
[failure] 28-28:
Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.
[failure] 28-28:
Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.
[failure] 27-27:
Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.
[failure] 27-27:
Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.
🤖 Prompt for AI Agents
✅ Addressed in commit b69d66d
coderabbitai[bot]:⚠️ Potential issue | 🟠 Major
Full comment
🤖 Prompt for AI Agents
✅ Addressed in commit b69d66d
coderabbitai[bot]:⚠️ Potential issue | 🟡 Minor
Full comment
If the security doesn't exist yet and that's expected, mock the security lookup or create the security in setup so the assertion is meaningful.
📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit b69d66d
coderabbitai[bot]:⚠️ Potential issue | 🟡 Minor
Full comment
🤖 Prompt for AI Agents
✅ Addressed in commit 5c91774
coderabbitai[bot]:⚠️ Potential issue | 🟡 Minor
Full comment
Alternatively, if the exact value isn't stable, set
balance: 0in setup for this test and assert it changed:🤖 Prompt for AI Agents
✅ Addressed in commit 5c91774
coderabbitai[bot]:⚠️ Potential issue | 🟡 Minor
Full comment
Then in
handle_response, before raising on 401, callinvalidate_token!so the next retry can re-authenticate. Alternatively, catchAuthenticationErrorinwith_retriesfor one re-auth attempt.🤖 Prompt for AI Agents