Skip to content

SCA-5117 fix hash-calculator bug causing source file mapping collision#124

Open
amaybaum wants to merge 1 commit intomasterfrom
SCA-5117
Open

SCA-5117 fix hash-calculator bug causing source file mapping collision#124
amaybaum wants to merge 1 commit intomasterfrom
SCA-5117

Conversation

@amaybaum
Copy link
Copy Markdown
Member

@amaybaum amaybaum commented May 7, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced JavaScript and HTML file parsing to more robustly strip leading header comments, properly handling edge cases in comment detection and removal while preventing truncation issues.
  • Tests

    • Added comprehensive unit tests to verify correct header comment removal across various scenarios, including stacked headers, mixed header types, duplicated header patterns, and edge cases.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 532497a8-4a24-454c-9dad-543d286b2cf8

📥 Commits

Reviewing files that changed from the base of the PR and between 49b956d and f35375e.

📒 Files selected for processing (2)
  • wss-agent-hash-calculator/src/main/java/org/whitesource/agent/parser/JavaScriptParser.java
  • wss-agent-hash-calculator/src/test/java/org/whitesource/agent/parser/JavaScriptParserTest.java

📝 Walkthrough

Walkthrough

JavaScriptParser was refactored to improve header comment stripping by replacing regex-based removal with anchored sequential detection. The implementation now uses Rhino Token.CommentType to distinguish line-style comments (//, <!--) from block comments (/* */), iteratively removes leading headers anchored at content start, and strips leading whitespace after each removal until body code is reached. Helper methods detect comment delimiters and locate line terminators without relying on potentially truncated comment values. A new test class validates the implementation against multiple header forms, stacked headers, and cases where identical text appears later in the file body.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 change: fixing a hash-calculator bug that causes source file mapping collisions. The implementation updates JavaScriptParser to robustly strip header comments, which is the root cause fix for the collision issue.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch SCA-5117

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant