From 295d60b3a25cdf230f0c71f12be81f373ecb1662 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Tue, 11 Oct 2022 00:38:07 +0100 Subject: [PATCH] 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. --- Library/Homebrew/Gemfile | 1 + Library/Homebrew/Gemfile.lock | 1 + Library/Homebrew/dev-cmd/typecheck.rb | 31 ++------------------------- 3 files changed, 4 insertions(+), 29 deletions(-) diff --git a/Library/Homebrew/Gemfile b/Library/Homebrew/Gemfile index 4b844fe8f5..917b7b6309 100644 --- a/Library/Homebrew/Gemfile +++ b/Library/Homebrew/Gemfile @@ -34,6 +34,7 @@ gem "warning", require: false group :sorbet, optional: true do gem "parlour", require: false gem "sorbet-static-and-runtime", require: false + gem "spoom", require: false gem "tapioca", require: false end diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index abb5a04223..023ede5ef4 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -236,6 +236,7 @@ DEPENDENCIES simplecov-cobertura sorbet-runtime sorbet-static-and-runtime + spoom tapioca warning diff --git a/Library/Homebrew/dev-cmd/typecheck.rb b/Library/Homebrew/dev-cmd/typecheck.rb index 3fc3a290ad..1a56d766e9 100644 --- a/Library/Homebrew/dev-cmd/typecheck.rb +++ b/Library/Homebrew/dev-cmd/typecheck.rb @@ -70,35 +70,8 @@ module Homebrew safe_system "bundle", "exec", "tapioca", "todo" if args.suggest_typed? - result = system_command( - "bundle", - 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 + ohai "Bumping Sorbet `typed` sigils..." + safe_system "bundle", "exec", "spoom", "bump" end return