Repository navigation
chore: allow use of for..of loop - #4676
Conversation
Summary by CodeRabbit
WalkthroughRemoved many inline ESLint-disable comments, standardized Node core imports to the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Suggestions: run full lint/CI to catch any regressions from removed disables and validate tests around the removed Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
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: 0
🧹 Nitpick comments (1)
src/v0/destinations/canny/transform.js (1)
107-116: Simplify by direct lookup and avoid scanning all keysYou can skip the outer loop and build promises directly from the mapped destination events. This is clearer and a bit cheaper.
- const responsePromises = []; - const configuredSourceEvents = Object.keys(configuredEventsMap); - for (const configuredSourceEvent of configuredSourceEvents) { - if (configuredSourceEvent === event) { - const destinationEvents = configuredEventsMap[event]; - for (const destinationEvent of destinationEvents) { - responsePromises.push(getTrackResponse(apiKey, message, destinationEvent, metadata)); - } - } - } - const responseArray = await Promise.all(responsePromises); + const destinationEvents = configuredEventsMap[event] || []; + const responseArray = await Promise.all( + destinationEvents.map((destinationEvent) => + getTrackResponse(apiKey, message, destinationEvent, metadata), + ), + );
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
.eslintrc.jsonis excluded by!**/*.json
📒 Files selected for processing (15)
scripts/common.ts(0 hunks)src/services/eventTest/eventTester.ts(0 hunks)src/testRouter.js(0 hunks)src/v0/destinations/active_campaign/transform.js(0 hunks)src/v0/destinations/am/utils.js(0 hunks)src/v0/destinations/bqstream/util.js(0 hunks)src/v0/destinations/branch/transform.js(0 hunks)src/v0/destinations/braze/util.js(0 hunks)src/v0/destinations/canny/transform.js(1 hunks)src/v0/destinations/clevertap/deleteUsers.js(0 hunks)src/v0/destinations/emarsys/deleteUsers.js(0 hunks)src/v0/destinations/hs/util.js(0 hunks)src/v0/destinations/monetate/utils.js(0 hunks)src/v0/destinations/sprig/deleteUsers.js(0 hunks)src/v0/util/index.js(0 hunks)
💤 Files with no reviewable changes (14)
- src/v0/destinations/active_campaign/transform.js
- src/testRouter.js
- src/v0/destinations/bqstream/util.js
- src/v0/destinations/branch/transform.js
- src/v0/destinations/clevertap/deleteUsers.js
- src/v0/destinations/braze/util.js
- src/v0/destinations/monetate/utils.js
- src/v0/destinations/sprig/deleteUsers.js
- src/v0/destinations/emarsys/deleteUsers.js
- src/v0/util/index.js
- scripts/common.ts
- src/services/eventTest/eventTester.ts
- src/v0/destinations/hs/util.js
- src/v0/destinations/am/utils.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js
⚙️ CodeRabbit configuration file
Focus on ESLint errors (max 3) and warnings (max 5).
Files:
src/v0/destinations/canny/transform.js
🧠 Learnings (1)
📚 Learning: 2025-08-13T04:47:19.615Z
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4497
File: src/v0/destinations/tiktok_ads/transformV2.js:422-435
Timestamp: 2025-08-13T04:47:19.615Z
Learning: The getSuccessRespEvents function in src/v0/util/index.js is designed to be flexible and can accept both single request objects and arrays as the first parameter (message). It simply assigns the input directly to the batchedRequest property without processing, allowing downstream consumers to handle the appropriate format.
Applied to files:
src/v0/destinations/canny/transform.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
src/v0/destinations/canny/transform.js (1)
118-120: LGTM: concurrent aggregation with Promise.all improves latency and removes no-await-in-loopOrder is preserved and this resolves the ESLint no-await-in-loop warning introduced by awaiting inside loops.
- Confirm that fail-fast semantics are desired (any single rejection fails the whole batch). If partial success is preferred, use Promise.allSettled and collect successes while surfacing failures.
- Confirm the Canny API (and retrieveUserId) tolerate the added concurrency without rate limiting; otherwise, cap concurrency (e.g., p-limit) or dedupe user lookup.
|
Allure Test reports for this run are available at:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4676 +/- ##
========================================
Coverage 91.79% 91.79%
========================================
Files 642 642
Lines 33998 34006 +8
Branches 8035 8042 +7
========================================
+ Hits 31207 31215 +8
+ Misses 2561 2539 -22
- Partials 230 252 +22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/v0/destinations/braze/util.js (2)
708-754: Numeric validation can falsely accept non-numeric stringsNumber.isNaN('abc') is false, so invalid numeric strings pass validation and later become NaN via Number.parseFloat/parseInt. Parse first, then validate the parsed values.
Apply this diff inside the products.forEach validation:
- if (Number.isNaN(price)) { - throw new InstrumentationError( - `Invalid Order Completed event: Price is not a number for product at index: ${products.indexOf( - product, - )}`, - ); - } + const parsedPrice = Number.parseFloat(price); + if (!Number.isFinite(parsedPrice)) { + throw new InstrumentationError( + `Invalid Order Completed event: Price is not a valid number for product at index: ${products.indexOf( + product, + )}`, + ); + } @@ - if (Number.isNaN(quantity)) { - throw new InstrumentationError( - `Invalid Order Completed event: Quantity is not a number for product at index: ${products.indexOf( - product, - )}`, - ); - } + const parsedQuantity = Number.parseInt(quantity, 10); + if (!Number.isSafeInteger(parsedQuantity)) { + throw new InstrumentationError( + `Invalid Order Completed event: Quantity is not a valid integer for product at index: ${products.indexOf( + product, + )}`, + ); + }Optionally, reuse the parsed values when constructing purchase objects to avoid double parsing:
- let purchaseObj = addMandatoryPurchaseProperties( - String(productId), - Number.parseFloat(price), - currencyCode || prodCur, - Number.parseInt(quantity, 10), - timestamp, - ); + const priceNum = Number.parseFloat(price); + const qtyNum = Number.parseInt(quantity, 10); + let purchaseObj = addMandatoryPurchaseProperties( + String(productId), + priceNum, + currencyCode || prodCur, + qtyNum, + timestamp, + );Also applies to: 765-772
257-261: Failure metric increments on success pathsbraze_lookup_failure_count is incremented unconditionally after the request. It should increment only for non-2xx responses.
Apply this diff:
- stats.counter('braze_lookup_failure_count', 1, { - http_status: lookUpResponse.status, - destination_id: destination.ID, - }); + if (!isHttpStatusSuccess(lookUpResponse.status)) { + stats.counter('braze_lookup_failure_count', 1, { + http_status: lookUpResponse.status, + destination_id: destination.ID, + }); + }
🧹 Nitpick comments (1)
src/v0/destinations/braze/util.js (1)
1-1: Prefer narrower ESLint disables to avoid masking future issuesFile-wide disable of no-param-reassign and @typescript-eslint/naming-convention can hide unintended violations. Consider scoping disables to the smallest regions that need them (specific functions/blocks) and re-enabling afterwards.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/v0/destinations/braze/util.js(6 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js
⚙️ CodeRabbit configuration file
Focus on ESLint errors (max 3) and warnings (max 5).
Files:
src/v0/destinations/braze/util.js
🧬 Code graph analysis (1)
src/v0/destinations/braze/util.js (2)
src/v0/destinations/braze/braze.util.test.js (5)
require(2-2)require(3-12)require(13-13)require(14-17)require(18-18)src/v0/destinations/braze/transform.js (12)
require(4-4)require(5-5)require(6-19)require(22-22)require(23-35)require(36-45)require(48-48)require(49-49)require(50-50)require(51-51)require(52-52)get(3-3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: get_workflow_url
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
src/v0/destinations/braze/util.js (2)
345-352: Set-based exclude list is a solid improvementSwitching from an Array to a Set for excludeKeys improves lookup performance and intent clarity.
366-366: Using Set.has instead of includes is correctThe filter now uses excludeKeys.has(key), matching the Set change and avoiding linear scans.
|
Allure Test reports for this run are available at:
|
|
@maheshkutty we can probably ignore those sonar issues as they are not directly related to this |
c2125c3 to
fa37887
Compare
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/v0/util/index.js (1)
1382-1385: Avoid per-call Set allocation for reserved keysMove the reserved-keys Set to module scope and reuse to reduce allocations; keep
isReservedWordshared.Apply within this function:
- // Define reserved words - const reservedWords = new Set(['__proto__', 'constructor', 'prototype']); - - const isReservedWord = (key) => reservedWords.has(key); + // Using module-scope isReservedWord to avoid per-call allocationsAdd once at module scope (above this function):
// Module-scope to avoid per-call allocations const RESERVED_OBJECT_KEYS = new Set(['__proto__', 'constructor', 'prototype']); const isReservedWord = (key) => RESERVED_OBJECT_KEYS.has(key);
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
.eslintrc.jsonis excluded by!**/*.json
📒 Files selected for processing (15)
scripts/common.ts(0 hunks)src/services/eventTest/eventTester.ts(0 hunks)src/testRouter.js(2 hunks)src/v0/destinations/active_campaign/transform.js(3 hunks)src/v0/destinations/am/utils.js(0 hunks)src/v0/destinations/bqstream/util.js(0 hunks)src/v0/destinations/branch/transform.js(0 hunks)src/v0/destinations/braze/util.js(6 hunks)src/v0/destinations/canny/transform.js(1 hunks)src/v0/destinations/clevertap/deleteUsers.js(0 hunks)src/v0/destinations/emarsys/deleteUsers.js(0 hunks)src/v0/destinations/hs/util.js(0 hunks)src/v0/destinations/monetate/utils.js(0 hunks)src/v0/destinations/sprig/deleteUsers.js(0 hunks)src/v0/util/index.js(5 hunks)
💤 Files with no reviewable changes (10)
- src/services/eventTest/eventTester.ts
- scripts/common.ts
- src/v0/destinations/monetate/utils.js
- src/v0/destinations/hs/util.js
- src/v0/destinations/branch/transform.js
- src/v0/destinations/sprig/deleteUsers.js
- src/v0/destinations/emarsys/deleteUsers.js
- src/v0/destinations/clevertap/deleteUsers.js
- src/v0/destinations/am/utils.js
- src/v0/destinations/bqstream/util.js
🚧 Files skipped from review as they are similar to previous changes (2)
- src/v0/destinations/braze/util.js
- src/v0/destinations/active_campaign/transform.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js
⚙️ CodeRabbit configuration file
Focus on ESLint errors (max 3) and warnings (max 5).
Files:
src/v0/destinations/canny/transform.jssrc/testRouter.jssrc/v0/util/index.js
🧠 Learnings (1)
📚 Learning: 2025-08-13T04:47:19.615Z
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4497
File: src/v0/destinations/tiktok_ads/transformV2.js:422-435
Timestamp: 2025-08-13T04:47:19.615Z
Learning: The getSuccessRespEvents function in src/v0/util/index.js is designed to be flexible and can accept both single request objects and arrays as the first parameter (message). It simply assigns the input directly to the batchedRequest property without processing, allowing downstream consumers to handle the appropriate format.
Applied to files:
src/v0/destinations/canny/transform.js
🧬 Code graph analysis (2)
src/testRouter.js (1)
src/v0/util/index.js (5)
fs(10-10)require(19-19)require(21-27)require(29-29)path(11-11)
src/v0/util/index.js (12)
src/testRouter.js (2)
fs(5-5)path(6-6)src/sources/braze/transform.js (2)
fs(4-4)path(3-3)src/sources/appsflyer/transform.js (2)
fs(2-2)path(1-1)src/sources/auth0/transform.js (2)
fs(2-2)path(1-1)src/sources/customerio/transform.js (2)
fs(2-2)path(1-1)src/sources/adjust/core.js (2)
fs(2-2)path(1-1)src/sources/appcenter/transform.js (2)
fs(2-2)path(1-1)src/sources/canny/util.js (2)
fs(2-2)path(1-1)src/v0/destinations/fb_custom_audience/util.js (1)
crypto(3-3)src/cdk/v2/destinations/emarsys/utils.test.js (1)
crypto(13-13)src/v0/destinations/twitter_ads/util.js (1)
crypto(1-1)src/util/customTransformer-faas.js (1)
crypto(2-2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Code Coverage
- GitHub Check: UT Tests
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: test_and_publish
🔇 Additional comments (6)
src/testRouter.js (2)
5-6: Node core module imports standardized nicely.Switching to the
node:specifiers keeps us aligned with the rest of the codebase. Looks good.
36-36: capitalize helper placement looks solid.Hoisting the helper keeps transformDestination lean and reuses the existing logic without behavior changes. All good here.
src/v0/util/index.js (4)
613-614: Numeric parsing modernization (Number.parseFloat) — LGTMMeets common lint rules (no-restricted-globals) and keeps behavior unchanged.
806-811: toFloat/toInt updated to Number.parseFloat/Number.parseInt — LGTMClearer intent and avoids global parse functions.
856-861: isFloat uses Number.parseFloat — LGTMConsistent with other numeric parsing updates.
10-11: Adoptnode:specifiers—confirm engine & linter support
Ensure your project’s declared Node version (package.jsonengines.node) and ESLint/config plugins acceptrequire('node:…'). Several files still use bare core imports (fs,path,crypto); consider a repo-wide sweep to standardize.
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|



What are the changes introduced in this PR?
This pull request updates ESLint configuration and removes unnecessary inline
eslint-disable-next-line no-restricted-syntaxcomments throughout the codebase. The primary change is to restrict onlyForInStatementusage via ESLint, allowing other modern loop constructs without manual comment overrides. This results in cleaner code and more precise linting.ESLint configuration update:
.eslintrc.json: Changes theno-restricted-syntaxrule to only restrictForInStatement, allowing other loop types without lint overrides.Code cleanup (removal of unnecessary lint comments):
scripts/common.ts,src/services/eventTest/eventTester.ts,src/testRouter.js,src/v0/destinations/active_campaign/transform.js,src/v0/destinations/am/utils.js,src/v0/destinations/bqstream/util.js,src/v0/destinations/branch/transform.js,src/v0/destinations/braze/util.js,src/v0/destinations/canny/transform.js,src/v0/destinations/clevertap/deleteUsers.js,src/v0/destinations/emarsys/deleteUsers.js,src/v0/destinations/hs/util.js,src/v0/destinations/monetate/utils.js,src/v0/destinations/sprig/deleteUsers.js,src/v0/util/index.js): Removeseslint-disable-next-line no-restricted-syntaxcomments from allfor...ofand similar loops, as these are now allowed by the updated ESLint rule. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21]Minor refactor for performance:
src/v0/destinations/canny/transform.js: Refactors event response building to usePromise.allfor parallelization instead of awaiting inside a loop, improving performance.What is the related Linear task?
Resolves INT-4184
Please explain the objectives of your changes below
Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here
Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
N/A
Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
N/A
Any technical or performance related pointers to consider with the change?
N/A
@coderabbitai review
Developer checklist
My code follows the style guidelines of this project
No breaking changes are being introduced.
All related docs linked with the PR?
All changes manually tested?
Any documentation changes needed with this change?
Is the PR limited to 10 file changes?
Is the PR limited to one linear task?
Are relevant unit and component test-cases added in new readability format?
Reviewer checklist
Is the type of change in the PR title appropriate as per the changes?
Verified that there are no credentials or confidential data exposed with the changes.