Skip to content

Fix lint error formatting for errors at end of line#6717

Merged
bentsherman merged 3 commits intomasterfrom
fix/lint-error-formatting
Jan 13, 2026
Merged

Fix lint error formatting for errors at end of line#6717
bentsherman merged 3 commits intomasterfrom
fix/lint-error-formatting

Conversation

@ewels
Copy link
Member

@ewels ewels commented Jan 13, 2026

Fixed bug in linting where errors that included EOL characters couldn't be printed and triggered an error.

Before (nf-core/seqinspector):

CleanShot 2026-01-13 at 14 59 13@2x

After:

CleanShot 2026-01-13 at 14 59 32@2x

Solution:

  • Fix StringIndexOutOfBoundsException in nextflow lint when errors occur at end-of-line positions
  • Add proper bounds checking for start/end positions in printCodeBlock() method
Details

Problem

When running nextflow lint on files with syntax errors at positions beyond the actual line length (e.g., "Unexpected input: '\n'" errors at end of line), the output would show:

ERROR ~ begin 44, end 45, length 44

instead of properly formatted error descriptions with code context.

Solution

Added bounds checking in ErrorListener.printCodeBlock() to ensure start, end, adjStart, and adjEnd values stay within the line length.

Test plan

  • Run nextflow lint . in test/seqinspector/ directory
  • Verify errors in conf/modules.config and nf-test.config display properly formatted messages
  • Verify JSON output still works correctly

🤖 Generated with Claude Code

When syntax errors occur at positions beyond the actual line length
(e.g., at end-of-line for "Unexpected input: '\n'" errors), the
substring operations in printCodeBlock() would throw a
StringIndexOutOfBoundsException, resulting in unhelpful error messages
like "ERROR ~ begin 44, end 45, length 44".

This fix adds proper bounds checking for start/end positions and their
adjusted values to ensure they stay within the line length.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
@netlify
Copy link

netlify bot commented Jan 13, 2026

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 218896e
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/69667cdb484c90000806b632

@bentsherman bentsherman linked an issue Jan 13, 2026 that may be closed by this pull request
@bentsherman
Copy link
Member

The error shown in the PR description is from nf-core/seqinspector:

https://github.com/nf-core/seqinspector/blob/a4ba47c71a2f15f92b340b37b2dd2358df54d0cc/conf/modules.config#L123

It is the same kind of error reported in #6664 , which this PR fixes. I will add a unit test for that and then merge.

Signed-off-by: Ben Sherman <bentshermann@gmail.com>
@bentsherman bentsherman merged commit 51e0e03 into master Jan 13, 2026
24 checks passed
@bentsherman bentsherman deleted the fix/lint-error-formatting branch January 13, 2026 17:29
pditommaso pushed a commit that referenced this pull request Jan 16, 2026
Co-authored-by: Ben Sherman <bentshermann@gmail.com>
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.

nextflow lint breaks when reporting certain syntax errors

2 participants