Skip to content

Commit 9978a57

Browse files
committed
Ignore comments and blank lines in sorbet/config files (fixes issue #93).
1 parent 50514e6 commit 9978a57

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

lib/spoom/sorbet/config.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ def parse_string(sorbet_config)
121121
state = :skip
122122
when /^-.*=?/
123123
next
124+
when /^#/
125+
next
126+
when /^$/
127+
next
124128
else
125129
case state
126130
when :ignore

test/spoom/sorbet/config_test.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,37 @@ def test_parses_a_config_string_with_mixed_options
124124
assert_empty(config.allowed_extensions)
125125
end
126126

127+
def test_parses_a_config_string_with_mixed_options_comments_and_empty_lines
128+
config = Spoom::Sorbet::Config.parse_string(<<~CONFIG)
129+
a
130+
--other=b
131+
# This is a comment.
132+
--file
133+
c
134+
135+
--d
136+
e
137+
--dir=f
138+
-g
139+
--dir
140+
141+
h
142+
--file=i
143+
--ignore
144+
# Comment in between.
145+
j
146+
--ignore=k
147+
l
148+
m
149+
-n
150+
--o
151+
p
152+
CONFIG
153+
assert_equal(['a', 'c', 'f', 'h', 'i', 'l', 'm'], config.paths)
154+
assert_equal(['j', 'k'], config.ignore)
155+
assert_empty(config.allowed_extensions)
156+
end
157+
127158
def test_parses_a_real_config_string
128159
config = Spoom::Sorbet::Config.parse_string(<<~CONFIG)
129160
.

0 commit comments

Comments
 (0)