Skip to content

Centralize comment delimiter in COMMENT_DELIMITER constant#289

Merged
soimkim merged 1 commit into
mainfrom
comm
Jul 3, 2026
Merged

Centralize comment delimiter in COMMENT_DELIMITER constant#289
soimkim merged 1 commit into
mainfrom
comm

Conversation

@soimkim

@soimkim soimkim commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Centralize comment delimiter in COMMENT_DELIMITER constant.

  • Improved consistency in how multiple comments are combined and separated, reducing formatting issues when viewing or editing comment text.

@soimkim soimkim self-assigned this Jul 3, 2026
@soimkim soimkim added the chore [PR/Issue] Refactoring, maintenance the code label Jul 3, 2026
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Introduces a new COMMENT_DELIMITER constant (" / ") in constant.py and replaces hardcoded comment separators in oss_item.py with this shared constant, applied consistently to OssItem.comment, FileItem.comment, and ScannerItem's cover comment set/get logic.

Changes

Comment delimiter unification

Layer / File(s) Summary
Shared delimiter constant and usage
src/fosslight_util/constant.py, src/fosslight_util/oss_item.py
Adds COMMENT_DELIMITER constant and replaces hardcoded delimiters when appending and splitting comment segments in OssItem, FileItem, and ScannerItem.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: consolidating the comment delimiter into a shared COMMENT_DELIMITER constant.
✨ 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 comm

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/fosslight_util/oss_item.py (1)

207-215: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Consider propagating COMMENT_DELIMITER to write_cyclonedx.py for full consistency.

write_cyclonedx.py still splits oss_item.comment on a bare '/' and matches exact tokens ('direct', 'transitive', 'root package') without stripping whitespace. The CycloneDX writer parses oss_item.comment by splitting on '/' and checks each segment for the exact token strings 'direct', 'transitive', and 'root package'. Since COMMENT_DELIMITER is " / " (with surrounding spaces), this split can produce tokens like " direct" that never match the exact-string check. This isn't a regression from this PR (the delimiter value is unchanged), but it undercuts the PR's stated goal of eliminating hardcoded delimiters and is worth aligning while the constant is being introduced.

♻️ Suggested fix in write_cyclonedx.py
-                                oss_comment = oss_item.comment.split('/')
+                                oss_comment = [c.strip() for c in oss_item.comment.split(COMMENT_DELIMITER)]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fosslight_util/oss_item.py` around lines 207 - 215, Align the CycloneDX
parsing in write_cyclonedx.py with COMMENT_DELIMITER so it no longer hardcodes
"/" and misses spaced tokens. Update the oss_item.comment handling where the
writer splits and checks for direct, transitive, and root package to use the
shared delimiter from fosslight_util/oss_item.py and normalize each segment with
trimming before comparing. Keep the logic in the CycloneDX writer consistent
with set_cover_comment/get_cover_comment so comment parsing works regardless of
surrounding whitespace.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/fosslight_util/oss_item.py`:
- Around line 207-215: Align the CycloneDX parsing in write_cyclonedx.py with
COMMENT_DELIMITER so it no longer hardcodes "/" and misses spaced tokens. Update
the oss_item.comment handling where the writer splits and checks for direct,
transitive, and root package to use the shared delimiter from
fosslight_util/oss_item.py and normalize each segment with trimming before
comparing. Keep the logic in the CycloneDX writer consistent with
set_cover_comment/get_cover_comment so comment parsing works regardless of
surrounding whitespace.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4d2d4dd1-91a0-4dd5-8af2-241bd083b6f9

📥 Commits

Reviewing files that changed from the base of the PR and between 5935171 and 00bc261.

📒 Files selected for processing (2)
  • src/fosslight_util/constant.py
  • src/fosslight_util/oss_item.py

@soimkim
soimkim merged commit 08fb981 into main Jul 3, 2026
8 checks passed
@soimkim
soimkim deleted the comm branch July 3, 2026 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore [PR/Issue] Refactoring, maintenance the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant