class Rails::Tc::TypeChecker
Constants
- ERROR_LINE_REGEX
Public Class Methods
new(ignored_errors = [], ignored_patterns = [])
click to toggle source
# File lib/rails/tc/type_checker.rb, line 15 def initialize(ignored_errors = [], ignored_patterns = []) @ignored_errors = ignored_errors @ignored_patterns = ignored_patterns end
set_up?()
click to toggle source
# File lib/rails/tc/type_checker.rb, line 11 def self.set_up? File.exist?(Rails.root.join("sorbet/config")) end
Public Instance Methods
errors()
click to toggle source
# File lib/rails/tc/type_checker.rb, line 20 def errors @errors ||= run end
Protected Instance Methods
run()
click to toggle source
# File lib/rails/tc/type_checker.rb, line 26 def run errors = [] current = T.let(nil, T.nilable(TypeCheckerError)) CommandRunner.type_check.split("\n", -1).each do |line| result = line.scan ERROR_LINE_REGEX if result.any? current = TypeCheckerError.new( result.first[0], result.first[1].to_i, result.first[3].to_i, result.first[2] ) errors.push current elsif result.empty? && !current.nil? && line.start_with?(" ") current.notes.push line end end errors.reject do |error| @ignored_errors.include?(error.code) || @ignored_patterns.any? { |pattern| File.fnmatch?(pattern, error.filename) } end end