Skip to content

feat: Add warning if skip_lines causes empty block#124

Merged
JeffFaer merged 3 commits intogoogle:mainfrom
willbeason:warn-if-empty
Mar 19, 2026
Merged

feat: Add warning if skip_lines causes empty block#124
JeffFaer merged 3 commits intogoogle:mainfrom
willbeason:warn-if-empty

Conversation

@willbeason
Copy link
Contributor

Fixes: #123

Specifically, this triggers if skip_lines causes the block's start to be at or after the block's end. So fully-empty blocks with no skip_lines (or no-op skip_lines, such as skip_lines=0,0) are still fine.

Modify tests in skip_lines golden test to show this behavior.

Modify how start and end are logged in cmd.go. As-is causes the slightly confusing behavior that "end" is always logged before start because it comes first alphabetically. Now these are logged as [start,end]=[x,y].

The warning for if start>=end shows both the original start/end and their offsets to make it more obvious how the values are arrived at. This helps finding the problematic lines, as otherwise you just see where the block start and end is, not where the directives are.

Specifically, this triggers if skip_lines causes the block's start to be at or
after the block's end. So fully-empty blocks with no skip_lines (or no-op
skip_lines, such as skip_lines=0,0) are still fine.

Modify tests in skip_lines golden test to show this behavior.

Modify how start and end are logged in cmd.go. As-is causes the slightly
confusing behavior that "end" is always logged before start because it comes
first alphabetically. Now these are logged as [start,end]=[x,y].

The warning for if start>=end shows both the original start/end and their
offsets to make it more obvious how the values are arrived at. This helps
finding the problematic lines, as otherwise you just see where the block start
and end is, not where the directives are.
@JeffFaer JeffFaer self-requested a review March 19, 2026 17:27
Co-authored-by: Jeffrey Faer <jeffrey.faer@gmail.com>
Now that we use the correct indices, these needed to be updated.
@willbeason
Copy link
Contributor Author

Okay, change made and regenerated test file.

@JeffFaer JeffFaer merged commit b8641a2 into google:main Mar 19, 2026
6 checks passed
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.

feat: Warn user if skip_lines causes entire block to be skipped

2 participants