Repository navigation
refactor(autoplay): move noise terms to JSON, add sped-up/slowed/reverb/8d-audio - #592
Conversation
…slowed/reverb - noiseTerms.json holds versionVariants and bareTitleNoise as plain strings - searchQueryCleaner builds parenthetical, bracket, and bare-word regex from JSON at init - no regex knowledge needed to add new dedup terms — just edit the JSON - adds: sped up, speed up, slowed, reverb, slowed reverb, nightcore, 8d audio, bass boosted - removes hardcoded duplicate patterns for terms now covered by JSON
… version decorator)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 40 minutes and 47 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR introduces a centralized JSON configuration file defining music noise terms (version variants and bare title noise tokens) and refactors the search query cleaner module to dynamically generate regex patterns from this configuration instead of maintaining hardcoded patterns. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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)
packages/bot/src/utils/music/searchQueryCleaner.ts (1)
23-26: Minor inconsistency in whitespace handling.
termToWordBoundaryReuses\s{0,3}(allowing 0-3 whitespace), whileDYNAMIC_VERSION_KEYWORD_RE(line 47) andDYNAMIC_HYPHENATED_SUFFIXES(line 52) use\s+(requiring at least 1 whitespace). This means:
- Bare word matching:
"spedup"would match (zero spaces allowed)- Version keyword matching:
"spedup"would not match (needs space)If this inconsistency is intentional (bare words being more permissive), the behavior is fine. Otherwise, consider aligning on
\s+for consistency.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/bot/src/utils/music/searchQueryCleaner.ts` around lines 23 - 26, termToWordBoundaryRe currently relaxes internal whitespace to '\s{0,3}' while DYNAMIC_VERSION_KEYWORD_RE and DYNAMIC_HYPHENATED_SUFFIXES use '\s+', causing inconsistent matching; update termToWordBoundaryRe (the function name) to replace internal whitespace with '\s+' instead of '\s{0,3}' so its output RegExp uses the same whitespace requirement as DYNAMIC_VERSION_KEYWORD_RE and DYNAMIC_HYPHENATED_SUFFIXES, ensuring consistent behavior across bare-word and version/hyphenated keyword matching.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/bot/src/utils/music/searchQueryCleaner.ts`:
- Around line 23-26: termToWordBoundaryRe currently relaxes internal whitespace
to '\s{0,3}' while DYNAMIC_VERSION_KEYWORD_RE and DYNAMIC_HYPHENATED_SUFFIXES
use '\s+', causing inconsistent matching; update termToWordBoundaryRe (the
function name) to replace internal whitespace with '\s+' instead of '\s{0,3}' so
its output RegExp uses the same whitespace requirement as
DYNAMIC_VERSION_KEYWORD_RE and DYNAMIC_HYPHENATED_SUFFIXES, ensuring consistent
behavior across bare-word and version/hyphenated keyword matching.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d1102953-10b0-453f-a653-fa2eb2f6d6a7
📒 Files selected for processing (3)
packages/bot/src/utils/music/noiseTerms.jsonpackages/bot/src/utils/music/searchQueryCleaner.spec.tspackages/bot/src/utils/music/searchQueryCleaner.ts
📜 Review details
⏰ 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). (2)
- GitHub Check: Quality Gates
- GitHub Check: SonarCloud Scan
🧰 Additional context used
🪛 ast-grep (0.42.1)
packages/bot/src/utils/music/searchQueryCleaner.ts
[warning] 24-24: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(\\b${inner}\\b, 'gi')
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html
(regexp-from-variable)
[warning] 29-29: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(\\(${inner}[^)]*\\), 'gi')
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html
(regexp-from-variable)
[warning] 34-34: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(\\[${inner}[^\\]]*\\], 'gi')
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html
(regexp-from-variable)
[warning] 45-48: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(
\\b(?:${noiseTerms.versionVariants.map((t) => escapeRegex(t).replaceAll(/\s+/g, '\\s+')).join('|')})\\b,
'i',
)
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html
(regexp-from-variable)
[warning] 51-51: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(^${escapeRegex(t).replaceAll(/\s+/g, '\\s+')}(?:\\s+(?:version|edit|mix))?$, 'i')
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html
(regexp-from-variable)
🔇 Additional comments (5)
packages/bot/src/utils/music/noiseTerms.json (1)
1-35: LGTM!The JSON structure is clean and well-organized. The separation of
versionVariants(for parenthetical/bracket/hyphenated patterns) andbareTitleNoise(for bare word matching) is a sensible design. The terms align with the test expectations and PR objectives.packages/bot/src/utils/music/searchQueryCleaner.spec.ts (1)
67-93: LGTM!The new test cases comprehensively cover the added noise patterns:
- Speed/tempo variants with parenthetical, bracket, and hyphenated forms
- Audio effect tags (reverb, 8D audio, bass boosted)
- Portuguese bare-word noise tokens
Good coverage that validates the dynamic regex generation from
noiseTerms.json.packages/bot/src/utils/music/searchQueryCleaner.ts (3)
17-53: Static analysis warnings are false positives in this context.The static analyzer flags ReDoS risks for regex constructed from variables, but here the input comes from a bundled JSON file (
noiseTerms.json), not user-supplied data. The patterns are safe because:
escapeRegexproperly escapes all special characters before constructing patterns- The quantifiers used (
\s{0,3},\s+) are bounded and non-overlapping- Character classes like
[^)]*and[^\]]*are linear-time matchersFor documentation purposes, consider adding a brief comment noting that these patterns are safe because the source is a trusted, bundled config file.
145-148: LGTM!Clean integration of dynamic patterns into the existing
NOISE_PATTERNSarray. The inline comment documenting the source is helpful for future maintainers.
160-164: LGTM!Good approach assigning
VERSION_KEYWORD_REfrom the dynamically generated regex and extendingHYPHENATED_VERSION_SUFFIXESwith JSON-derived patterns. This maintains backward compatibility while enabling easy extensibility.
…egexp construction
|
…rb/8d-audio (#592) * refactor(autoplay): move noise terms to noiseTerms.json, add sped-up/slowed/reverb - noiseTerms.json holds versionVariants and bareTitleNoise as plain strings - searchQueryCleaner builds parenthetical, bracket, and bare-word regex from JSON at init - no regex knowledge needed to add new dedup terms — just edit the JSON - adds: sped up, speed up, slowed, reverb, slowed reverb, nightcore, 8d audio, bass boosted - removes hardcoded duplicate patterns for terms now covered by JSON * fix(autoplay): remove nightcore from noise terms (it is a genre not a version decorator) * fix(ci): consolidate dynamic term builders, add nosonar for dynamic regexp construction



Summary
sped up,speed up,slowed,reverb,slowed reverb,8d audio,bass boosted,original versionHow to add new terms going forward
Edit
packages/bot/src/utils/music/noiseTerms.json:{ "versionVariants": ["sped up", "slowed", "your new term"], "bareTitleNoise": ["lyrics", "legendado", "your new noise word"] }Patterns for
(term...),[term...], and\bterm\bare built automatically at startup.Test plan
cleanTitle('Flowers (Sped Up)')→'Flowers'cleanTitle('Flowers [Slowed Reverb]')→'Flowers'cleanTitle('Flowers - Slowed')→'Flowers'cleanTitle('Flowers (Bass Boosted)')→'Flowers'Summary by CodeRabbit
Release Notes
New Features
Tests