Gemfile*,dev-cmd/typecheck: Use Spoom for --suggest-typed
- Spoom is the gem that's recommended for automatically changing `typed` sigils in files now. It was recommended in the "migrate to Tapioca" guide at https://github.com/Shopify/tapioca/wiki/Migrating-to-Tapioca#things-that-do-not-need-to-happen.
This commit is contained in:
parent
84e83dd1ad
commit
295d60b3a2
@ -34,6 +34,7 @@ gem "warning", require: false
|
|||||||
group :sorbet, optional: true do
|
group :sorbet, optional: true do
|
||||||
gem "parlour", require: false
|
gem "parlour", require: false
|
||||||
gem "sorbet-static-and-runtime", require: false
|
gem "sorbet-static-and-runtime", require: false
|
||||||
|
gem "spoom", require: false
|
||||||
gem "tapioca", require: false
|
gem "tapioca", require: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -236,6 +236,7 @@ DEPENDENCIES
|
|||||||
simplecov-cobertura
|
simplecov-cobertura
|
||||||
sorbet-runtime
|
sorbet-runtime
|
||||||
sorbet-static-and-runtime
|
sorbet-static-and-runtime
|
||||||
|
spoom
|
||||||
tapioca
|
tapioca
|
||||||
warning
|
warning
|
||||||
|
|
||||||
|
@ -70,35 +70,8 @@ module Homebrew
|
|||||||
safe_system "bundle", "exec", "tapioca", "todo"
|
safe_system "bundle", "exec", "tapioca", "todo"
|
||||||
|
|
||||||
if args.suggest_typed?
|
if args.suggest_typed?
|
||||||
result = system_command(
|
ohai "Bumping Sorbet `typed` sigils..."
|
||||||
"bundle",
|
safe_system "bundle", "exec", "spoom", "bump"
|
||||||
args: ["exec", "--", "srb", "tc", "--suggest-typed", "--typed=strict",
|
|
||||||
"--isolate-error-code=7022"],
|
|
||||||
print_stderr: false,
|
|
||||||
)
|
|
||||||
|
|
||||||
allowed_changes = {
|
|
||||||
"false" => ["true", "strict"],
|
|
||||||
"true" => ["strict"],
|
|
||||||
}
|
|
||||||
|
|
||||||
# Workaround for `srb tc rbi suggest-typed`, which currently fails get to a converging state.
|
|
||||||
result.stderr.scan(/^(.*\.rb):\d+:\s+You could add `#\s*typed:\s*(.*?)`/).each do |path, new_level|
|
|
||||||
path = Pathname(path)
|
|
||||||
|
|
||||||
next unless path.file?
|
|
||||||
|
|
||||||
contents = path.read
|
|
||||||
|
|
||||||
next unless (match = contents.match(/\A\s*#\s*typed:\s*([^\s]+)/))
|
|
||||||
|
|
||||||
existing_level = match[1]
|
|
||||||
|
|
||||||
next unless allowed_changes.fetch(existing_level, []).include?(new_level)
|
|
||||||
|
|
||||||
puts "#{path}: #{existing_level} -> #{new_level}"
|
|
||||||
path.atomic_write contents.sub(/\A(\s*#\s*typed:\s*)(?:[^\s]+)/, "\\1#{new_level}")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user