Skip to content

Commit

Permalink
refactor(options): Define default options as an explicit instance. (#34)
Browse files Browse the repository at this point in the history
This simplifies option parsing logic a bit, and sets us up to add a flag
to override the default options
(#35).

I also tweaked most of the tests in keep_sorted_test to not rely on the
default options at all and instead be more explicit about the behavior
they need to pass.
  • Loading branch information
JeffFaer authored Apr 9, 2024
1 parent 08685ef commit 0b7d0f8
Show file tree
Hide file tree
Showing 3 changed files with 240 additions and 236 deletions.
2 changes: 1 addition & 1 deletion keepsorted/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (f *Fixer) newBlocks(lines []string, offset int, include func(start, end in
continue
}

opts, err := f.parseBlockOptions(start.line)
opts, err := f.parseBlockOptions(start.line, defaultOptions)
if err != nil {
// TODO(b/250608236): Is there a better way to surface this error?
log.Err(fmt.Errorf("keep-sorted block at index %d had bad start directive: %w", start.index+offset, err)).Msg("")
Expand Down
Loading

0 comments on commit 0b7d0f8

Please sign in to comment.