Skip to content

Conversation

@marysieek
Copy link

@marysieek marysieek commented Jan 15, 2026

Summary

  • adjust JavaScript header comment removal to use parser-provided comment positions instead of raw string replacement
  • add a regression test covering header comments that end with the character p

Testing

  • mvn -pl wss-agent-hash-calculator test (fails: cannot resolve org.sonatype.central:central-publishing-maven-plugin:0.9.0)

Codex Task

Summary by CodeRabbit

  • Tests

    • Added test validation for header comment removal in JavaScript files.
  • Refactor

    • Improved robustness of header comment removal logic with enhanced boundary checking and safety validation.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

📝 Walkthrough

Walkthrough

The JavaScriptParser class is refactored to replace content-based header-comment removal with an index-based traversal approach. The new implementation tracks position through file content using comment absolute positions and lengths, includes boundary checks for malformed comments, and advances past trailing whitespace. StringUtils dependency is removed. A corresponding test case is added to validate header comment removal for comments ending with specific patterns.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: reworking header comment removal in JavaScriptParser to fix an edge case by switching from content-based to index-based approach.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

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

📒 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/hash/JavaScriptHashCalculatorTest.java
🧰 Additional context used
📓 Path-based instructions (1)
**/*

⚙️ CodeRabbit configuration file

**/*: - Feedback will only be given on issues that could cause bugs or involve very bad practices.

  • Comments will be kept concise and focused on critical areas.

Files:

  • wss-agent-hash-calculator/src/test/java/org/whitesource/agent/hash/JavaScriptHashCalculatorTest.java
  • wss-agent-hash-calculator/src/main/java/org/whitesource/agent/parser/JavaScriptParser.java
🔇 Additional comments (2)
wss-agent-hash-calculator/src/main/java/org/whitesource/agent/parser/JavaScriptParser.java (1)

72-105: LGTM!

The index-based approach correctly handles sequential header comments by tracking position through absolute positions and lengths. The boundary checks for malformed comments and whitespace skipping are appropriate safeguards.

wss-agent-hash-calculator/src/test/java/org/whitesource/agent/hash/JavaScriptHashCalculatorTest.java (1)

63-70: LGTM!

The test correctly validates the edge case where a file contains only a single-line header comment (ending with 'p' as noted in the PR). Asserting both non-null and zero length appropriately covers the expected behavior.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants