Class: Homebrew::DevCmd::Typecheck Private

Inherits:
AbstractCommand show all
Includes:
FileUtils
Defined in:
sorbet/rbi/dsl/homebrew/dev_cmd/typecheck.rbi,
dev-cmd/typecheck.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

DO NOT EDIT MANUALLY This is an autogenerated file for dynamic methods in Homebrew::DevCmd::Typecheck. Please instead update this file by running bin/tapioca dsl Homebrew::DevCmd::Typecheck.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::DevCmd::Typecheck::Args

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



9
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/typecheck.rbi', line 9

def args; end

#runvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



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
89
90
91
92
93
94
95
# File 'dev-cmd/typecheck.rb', line 41

def run
  update = args.update? || args.update_all?
  groups = update ? Homebrew.valid_gem_groups : ["typecheck"]
  Homebrew.install_bundler_gems!(groups:)

  # Sorbet doesn't use bash privileged mode so we align EUID and UID here.
  Process::UID.change_privilege(Process.euid) if Process.euid != Process.uid

  HOMEBREW_LIBRARY_PATH.cd do
    if update
      workers = args.debug? ? ["--workers=1"] : []
      safe_system "bundle", "exec", "tapioca", "dsl", *workers
      # Prefer adding args here: Library/Homebrew/sorbet/tapioca/config.yml
      tapioca_args = args.update_all? ? ["--all"] : []

      ohai "Updating Tapioca RBI files..."
      safe_system "bundle", "exec", "tapioca", "gem", *tapioca_args
      safe_system "bundle", "exec", "parlour"

      if args.suggest_typed?
        ohai "Bumping Sorbet `typed` sigils..."
        # --sorbet needed because of https://github.com/Shopify/spoom/issues/488
        safe_system "bundle", "exec", "spoom", "srb", "bump", "--dry", "--sorbet",
                    "#{Gem.bin_path("sorbet", "srb")} tc"
      end

      return
    end

    srb_exec = %w[bundle exec srb tc]

    srb_exec << "--quiet" if args.quiet?

    if args.fix?
      # Auto-correcting method names is almost always wrong.
      srb_exec << "--suppress-error-code" << "7003"

      srb_exec << "--autocorrect"
    end

    srb_exec += ["--ignore", args.ignore] if args.ignore.present?
    if args.file.present? || args.dir.present?
      cd("sorbet") do
        srb_exec += ["--file", "../#{args.file}"] if args.file
        srb_exec += ["--dir", "../#{args.dir}"] if args.dir
      end
    end
    success = system(*srb_exec)
    return if success

    $stderr.puts "Check #{Formatter.url("https://docs.brew.sh/Typechecking")} for " \
                 "more information on how to resolve these errors."
    Homebrew.failed = true
  end
end