Skip to content

Commit

Permalink
rubocop: Use Sorbet/StrictSigil as it's better than comments
Browse files Browse the repository at this point in the history
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in Homebrew#18018 (comment).

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
  • Loading branch information
issyl0 authored and ctaintor committed Sep 4, 2024
1 parent 2a8b98f commit eb73cce
Show file tree
Hide file tree
Showing 277 changed files with 284 additions and 280 deletions.
10 changes: 5 additions & 5 deletions Library/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,11 @@ Sorbet/RedundantExtendTSig:

Sorbet/StrictSigil:
Enabled: true
inherit_mode:
override:
- Include
Include:
- "**/*.rbi"
Exclude:
- "Taps/**/*"
- "/**/{Formula,Casks}/**/*.rb"
- "**/{Formula,Casks}/**/*.rb"
- "Homebrew/test/**/*.rb"

Sorbet/TrueSigil:
Enabled: true
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/PATH.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "forwardable"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/api.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "api/analytics"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/api/analytics.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

module Homebrew
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/api/cask.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "extend/cachable"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/api/download.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "downloadable"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/api/formula.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "extend/cachable"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/build.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

# This script is loaded by formula_installer as a separate instance.
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/build_environment.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

# Settings for the build environment.
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/build_options.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

# Options for a formula build.
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/bundle_version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "system_command"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cache_store.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "json"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/abstract_artifact.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "attrable"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/abstract_flight_block.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/artifact/abstract_artifact"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/abstract_uninstall.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "timeout"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/binary.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/artifact/symlinked"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/installer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/artifact/abstract_artifact"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/keyboard_layout.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/artifact/moved"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/manpage.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/artifact/symlinked"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/mdimporter.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/artifact/moved"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/moved.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/artifact/relocated"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/pkg.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "plist"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/qlplugin.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/artifact/moved"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/relocated.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/artifact/abstract_artifact"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/stage_only.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/artifact/abstract_artifact"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/symlinked.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/artifact/relocated"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/uninstall.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/artifact/abstract_uninstall"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/zap.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/artifact/abstract_uninstall"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact_set.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

module Cask
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/audit.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "attrable"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/auditor.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/audit"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/cask.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "attrable"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/cask_loader.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/cache"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/caskroom.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "utils/user"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/config.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "json"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/download.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "downloadable"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "attrable"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl/base.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/utils"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl/caveats.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "attrable"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl/conflicts_with.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "delegate"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl/container.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "unpack_strategy"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl/depends_on.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "delegate"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

module Cask
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/exceptions.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

module Cask
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/installer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "attrable"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/list.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/artifact/relocated"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/macos.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

module OS
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/metadata.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

module Cask
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/migrator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/cask_loader"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/pkg.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "cask/macos"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/quarantine.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "development_tools"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/reinstall.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

module Cask
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/staged.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "utils/user"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/tab.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "tab"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/uninstall.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

module Cask
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/url.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "source_location"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/utils.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "utils/user"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask_dependent.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "requirement"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/caveats.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "language/python"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cleaner.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

# Cleans a newly installed keg.
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cleanup.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "utils/bottles"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cli/args.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true # This cannot be `# typed: strict` due to the use of `undef`.
# typed: true # rubocop:disable Sorbet/StrictSigil
# frozen_string_literal: true

require "ostruct"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cli/named_args.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "delegate"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/deps.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

require "abstract_command"
Expand Down
Loading

0 comments on commit eb73cce

Please sign in to comment.