Class: Sorbet::Private::SuggestTyped

Inherits:
Object
  • Object
show all
Includes:
StepInterface
Defined in:
lib/suggest-typed.rb

Class Method Summary collapse

Class Method Details

.mainObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/suggest-typed.rb', line 11

def self.main
  count = 0
  while count < 100
    count += 1
    if suggest_typed
      return true
    end

    if count == 50
      puts "Adding `typed:` sigils did not converge after 50 tries."
      STDOUT.write("Would you like to continue anyway? [Y/n] ")
      if STDIN.isatty && STDOUT.isatty
        begin
          input = STDIN.gets&.strip
          if input.nil? || (input != '' && input != 'y' && input != 'Y')
            return false
          end
        rescue Interrupt
          return false
        end
      else
        puts "Not running interactively, continuing."
      end
    end
  end

  puts "Adding `typed:` sigils did not converge after 100 tries."
  false
end

.output_fileObject



52
53
54
# File 'lib/suggest-typed.rb', line 52

def self.output_file
  nil
end

.suggest_typedObject



41
42
43
44
45
46
47
48
49
50
# File 'lib/suggest-typed.rb', line 41

def self.suggest_typed
  IO.popen(
    [File.realpath("#{__dir__}/../bin/srb"), 'tc', '--suggest-typed', '--error-white-list=7022', '--typed=strict', '--silence-dev-message', '-a'],
    err: [:child, :out],
  ) do |io|
    out = io.read
    return true if out == "No errors! Great job.\n"
  end
  false
end