class RBS::CLI::Validate::Errors

Public Class Methods

new(limit:, exit_error:) click to toggle source
# File rbs-3.4.0/lib/rbs/cli/validate.rb, line 7
def initialize(limit:, exit_error:)
  @limit = limit
  @exit_error = exit_error
  @errors = []
  @has_syntax_error = false
end

Public Instance Methods

add(error) click to toggle source
# File rbs-3.4.0/lib/rbs/cli/validate.rb, line 14
def add(error)
  if error.instance_of?(WillSyntaxError)
    RBS.logger.warn(build_message(error))
    @has_syntax_error = true
  else
    @errors << error
  end
  finish if @limit == 1
end
finish() click to toggle source
# File rbs-3.4.0/lib/rbs/cli/validate.rb, line 24
def finish
  if @errors.empty?
    if @exit_error && @has_syntax_error
      exit 1
    else
      # success
    end
  else
    @errors.each do |error|
      RBS.logger.error(build_message(error))
    end
    exit 1
  end
end

Private Instance Methods

build_message(error) click to toggle source
# File rbs-3.4.0/lib/rbs/cli/validate.rb, line 41
def build_message(error)
  if error.respond_to?(:detailed_message)
    highlight = RBS.logger_output ? RBS.logger_output.tty? : true
    error.detailed_message(highlight: highlight)
  else
    "#{error.message} (#{error.class})"
  end
end