fix(#1336): report exact physical line of too-wide line in multi-line comments - #1339
fix(#1336): report exact physical line of too-wide line in multi-line comments#1339yegor256 wants to merge 2 commits into
Conversation
… comments comment-is-too-wide.xsl now computes each offending line's real line number as the comment's start @line plus its offset within the tokenized text, instead of always reporting the comment block's start line. This also removes the duplicated multi-line/single-line branches in favor of one loop. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BtgvknNrK4TEQvMPqP7E7p
There was a problem hiding this comment.
🟡 Changes recommended
The updated XSL now feeds eo:defect-context(.) a tokenized string (not the original <comment> node) and bypasses the existing eo:lineno(@line) helper before doing arithmetic, which is inconsistent with established patterns and can reduce output quality/robustness when @line is absent or non-numeric.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates the comment-is-too-wide lint to report the physical line number of an offending too-wide line within multi-line comments, and aligns the related fixture to assert the new, precise location.
Changes:
- Compute
defect/@lineascomment @line + (position() - 1)while iterating tokenized comment lines. - Remove the resolved
@todopuzzle by restructuring into a single per-line loop. - Update the multiline fixture to assert
@line='2'(the actual offending line).
File summaries
| File | Description |
|---|---|
| src/main/resources/org/eolang/lints/comments/comment-is-too-wide.xsl | Computes per-line line-number offsets when emitting defects for too-wide comment lines. |
| src/test/resources/org/eolang/lints/packs/single/comment-is-too-wide/catches-multiline-wide-comment.yaml | Updates expected defect line number to match the new precise reporting. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… defect-context Address Copilot review feedback on PR #1339: use the shared eo:lineno(@line) helper (consistent with comment-too-short.xsl and others) instead of a manual '0'-fallback that doesn't guard against a non-numeric @line, and pass the original <comment> node to eo:defect-context instead of the tokenized line string so the serialized context stays consistent with other lints. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BtgvknNrK4TEQvMPqP7E7p
|
This PR now has merge conflicts and needs a rebase before it can go in. Assigning to @yegor256 for a look. Generated by Claude Code |
|
Thanks for the fix — the per-line offset calculation is a clean improvement over the previous single-line-only reporting, and all checks are green. @rultor merge Generated by Claude Code |
|
CI is fully green on this one, but GitHub reports the branch as no longer mergeable cleanly against Generated by Claude Code |
|
@yegor256 It is not a good idea to name Git branches the way you named this one: " |
|
CI is green but this PR now has a merge conflict with master (GitHub reports it as not mergeable/"dirty"). Needs a rebase before it can be merged. Generated by Claude Code |
|
CI is green here, but GitHub is reporting this branch as conflicted with master right now, so it can't be squash-merged as is. Requesting a look/rebase before merging. Generated by Claude Code |
|
This PR now has merge conflicts with master (likely from other recently merged fixes touching nearby files) and can't be merged as-is. Needs a rebase before it can go in. Generated by Claude Code |
Fixes #1336.
Summary
comment-is-too-wide.xslused to report every offending line inside a multi-line comment with the comment block's own start@line, since the XSL had no way to compute the offset of a line within the tokenized comment text.Now each defect's
@lineis computed as the comment's start@lineplus that line's offset within the tokenized text (position() - 1), so the reported location points at the actual offending physical line instead of always the first line of the comment.As part of this fix, the previously duplicated multi-line/single-line
xsl:choosebranches were merged into a single loop over the tokenized lines, since the offset computation subsumes both cases (a single-line comment simply has an offset of 0).Changes
src/main/resources/org/eolang/lints/comments/comment-is-too-wide.xsl: compute per-line offset and remove the resolved@todopuzzle.src/test/resources/org/eolang/lints/packs/single/comment-is-too-wide/catches-multiline-wide-comment.yaml: assert on line2(the actual offending line) instead of line1.Test plan
mvn test -Dtest=LtByXslTestpasses (463 tests, 0 failures) — includes allcomment-is-too-widefixtures plus structural checks (XSL@idchecks, motive presence, schema validation).<comment @line="N">node containing real newlines, confirming the offset approach is correct.🤖 Generated with Claude Code
https://claude.ai/code/session_01BtgvknNrK4TEQvMPqP7E7p
Generated by Claude Code