22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/tapioca/helpers/rbi_helper.rb', line 22
def validate_rbi_files(command:, gem_dir:, dsl_dir:, auto_strictness:, gems: [], compilers: [])
error_url_base = Spoom::Sorbet::Errors::DEFAULT_ERROR_URL_BASE
say("Checking generated RBI files... ")
res = sorbet(
"--no-config",
"--error-url-base=#{error_url_base}",
"--stop-after namer",
dsl_dir,
gem_dir
)
say(" Done", :green)
errors = Spoom::Sorbet::Errors::Parser.parse_string(res.err)
if errors.empty?
say(" No errors found\n\n", [:green, :bold])
return
end
parse_errors = errors.select { |error| error.code < 4000 }
if parse_errors.any?
say_error("\n ##### INTERNAL ERROR #####\n\n There are parse errors in the generated RBI files.\n\n This seems related to a bug in Tapioca.\n Please open an issue at https://github.com/Shopify/tapioca/issues/new with the following information:\n\n Tapioca v\#{Tapioca::VERSION}\n\n Command:\n \#{command}\n\n ERR\n\n say_error(<<~ERR, :red) if gems.any?\n Gems:\n \#{gems.map { |gem| \" \#{gem.name} (\#{gem.version})\" }.join(\"\\n\")}\n\n ERR\n\n say_error(<<~ERR, :red) if compilers.any?\n Compilers:\n \#{compilers.map { |compiler| \" \#{compiler.name}\" }.join(\"\\n\")}\n\n ERR\n\n say_error(<<~ERR, :red)\n Errors:\n \#{parse_errors.map { |error| \" \#{error}\" }.join(\"\\n\")}\n\n ##########################\n\n ERR\n end\n\n if auto_strictness\n redef_errors = errors.select { |error| error.code == 4010 }\n update_gem_rbis_strictnesses(redef_errors, gem_dir)\n end\n\n Kernel.exit(1) if parse_errors.any?\nend\n", :red)
|