Skip to content

refactor(autoplay): move noise terms to JSON, add sped-up/slowed/reverb/8d-audio - #592

Merged
LucasSantana-Dev merged 5 commits into
mainfrom
fix/version-noise-patterns
Apr 13, 2026
Merged

LucasSantana-Dev merged 5 commits into
mainfrom
fix/version-noise-patterns

Conversation

@LucasSantana-Dev

@LucasSantana-Dev LucasSantana-Dev commented Apr 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • noiseTerms.json: new file holding version variant and bare-title noise as plain strings — add new terms by editing the JSON, no regex knowledge required
  • Adds: sped up, speed up, slowed, reverb, slowed reverb, 8d audio, bass boosted, original version
  • Removes hardcoded duplicate patterns that are now covered by JSON
  • Keeps complex accent-aware patterns (Brazilian Portuguese) and extended live-at-venue patterns inline — they can't be expressed as plain strings
  • Nightcore excluded — it's a genre (Nightcore - Song Name), not a version decorator

How 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\b are built automatically at startup.

Test plan

  • All 2181 tests pass
  • 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

    • Enhanced music search title normalization to better handle and remove common decorators such as speed variations, audio effects (reverb, 8D audio, bass boosted), and language-specific tags for more accurate search results.
  • Tests

    • Extended test coverage for additional title-cleaning patterns.

…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
@vercel

vercel Bot commented Apr 13, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lucky Ready Ready Preview, Comment Apr 13, 2026 8:10pm

@LucasSantana-Dev
LucasSantana-Dev enabled auto-merge (squash) April 13, 2026 19:51
@github-actions github-actions Bot added the bot label Apr 13, 2026
@coderabbitai

coderabbitai Bot commented Apr 13, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@LucasSantana-Dev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 40 minutes and 47 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 59d46839-664e-4922-a70c-1ef202e05381

📥 Commits

Reviewing files that changed from the base of the PR and between 39843cb and 44a66c1.

📒 Files selected for processing (1)
  • packages/bot/src/utils/music/searchQueryCleaner.ts
📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Configuration
packages/bot/src/utils/music/noiseTerms.json
New JSON configuration file defining versionVariants (speed/tempo variations, audio effects, release types) and bareTitleNoise (bare title tokens including Portuguese variants like "legendado" and "traduzido").
Test Coverage
packages/bot/src/utils/music/searchQueryCleaner.spec.ts
Added Jest test cases for cleanTitle covering removal of sped-up, slowed, reverb, 8D audio, bass-boosted tags and bare Portuguese language tokens.
Production Logic
packages/bot/src/utils/music/searchQueryCleaner.ts
Imported noiseTerms.json and refactored to dynamically generate regex patterns via helper functions (escapeRegex, termToWordBoundaryRe, termToParenRe, termToBracketRe). Replaced hardcoded version patterns with dynamic generation from configuration; removed previously hardcoded noise entries now sourced from config.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

bot, size/l

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main changes: refactoring noise terms into JSON and adding new noise pattern matching for sped-up, slowed, reverb, and 8d-audio variants.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/version-noise-patterns

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/bot/src/utils/music/searchQueryCleaner.ts (1)

23-26: Minor inconsistency in whitespace handling.

termToWordBoundaryRe uses \s{0,3} (allowing 0-3 whitespace), while DYNAMIC_VERSION_KEYWORD_RE (line 47) and DYNAMIC_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

📥 Commits

Reviewing files that changed from the base of the PR and between 7bc4c40 and 39843cb.

📒 Files selected for processing (3)
  • packages/bot/src/utils/music/noiseTerms.json
  • packages/bot/src/utils/music/searchQueryCleaner.spec.ts
  • packages/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) and bareTitleNoise (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:

  1. escapeRegex properly escapes all special characters before constructing patterns
  2. The quantifiers used (\s{0,3}, \s+) are bounded and non-overlapping
  3. Character classes like [^)]* and [^\]]* are linear-time matchers

For 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_PATTERNS array. The inline comment documenting the source is helpful for future maintainers.


160-164: LGTM!

Good approach assigning VERSION_KEYWORD_RE from the dynamically generated regex and extending HYPHENATED_VERSION_SUFFIXES with JSON-derived patterns. This maintains backward compatibility while enabling easy extensibility.

@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit 5ab8400 into main Apr 13, 2026
12 checks passed
@LucasSantana-Dev
LucasSantana-Dev deleted the fix/version-noise-patterns branch April 13, 2026 21:56
LucasSantana-Dev added a commit that referenced this pull request May 13, 2026
…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

This branch was successfully deployed

1 active deployment
Preview — 44a66c11 Deployed Apr 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant