Skip to content

Commit 1867624

Browse files
committed
Deprecate --[no-]exit-error-on-syntax-error option
1 parent 4890879 commit 1867624

2 files changed

Lines changed: 6 additions & 22 deletions

File tree

lib/rbs/cli/validate.rb

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,18 @@ module RBS
44
class CLI
55
class Validate
66
class Errors
7-
def initialize(limit:, exit_error:)
7+
def initialize(limit:)
88
@limit = limit
9-
@exit_error = exit_error
109
@errors = []
11-
@has_syntax_error = false
1210
end
1311

1412
def add(error)
15-
if error.instance_of?(WillSyntaxError)
16-
RBS.logger.warn(build_message(error))
17-
@has_syntax_error = true
18-
else
19-
@errors << error
20-
end
13+
@errors << error
2114
finish if @limit == 1
2215
end
2316

2417
def finish
25-
if @errors.empty?
26-
if @exit_error && @has_syntax_error
27-
exit 1
28-
else
29-
# success
30-
end
31-
else
18+
unless @errors.empty?
3219
@errors.each do |error|
3320
RBS.logger.error(build_message(error))
3421
end
@@ -53,7 +40,6 @@ def initialize(args:, options:)
5340
@env = Environment.from_loader(loader).resolve_type_names
5441
@builder = DefinitionBuilder.new(env: @env)
5542
@validator = Validator.new(env: @env)
56-
exit_error = false
5743
limit = nil #: Integer?
5844
OptionParser.new do |opts|
5945
opts.banner = <<EOU
@@ -70,14 +56,14 @@ def initialize(args:, options:)
7056
RBS.print_warning { "`--silent` option is deprecated because it's silent by default. You can use --log-level option of rbs command to display more information." }
7157
end
7258
opts.on("--[no-]exit-error-on-syntax-error", "exit(1) if syntax error is detected") {|bool|
73-
exit_error = bool
59+
RBS.print_warning { "`--[no-]exit-error-on-syntax-error` option is deprecated because it's built in during parsing." }
7460
}
7561
opts.on("--fail-fast", "Exit immediately as soon as a validation error is found.") do |arg|
7662
limit = 1
7763
end
7864
end.parse!(args)
7965

80-
@errors = Errors.new(limit: limit, exit_error: exit_error)
66+
@errors = Errors.new(limit: limit)
8167
end
8268

8369
def run

sig/cli/validate.rbs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ module RBS
33
class Validate
44
class Errors
55
@limit: Integer?
6-
@exit_error: boolish
7-
@has_syntax_error: bool
86
@errors: Array[BaseError]
97

10-
def initialize: (limit: Integer?, exit_error: boolish) -> void
8+
def initialize: (limit: Integer?) -> void
119

1210
def add: (BaseError) -> void
1311

0 commit comments

Comments
 (0)