14 Commits

Author SHA1 Message Date
Issy Long
867e982300
T.cast some Nodes to SendNodes
- In these cases we've already checked it's not a BlockNode,
  so we can safely cast to a SendNode and use `SendNode` methods.
2025-01-25 22:34:10 +00:00
Issy Long
94085ebb57
Bump more RuboCops to Sorbet typed: strict 2025-01-06 00:09:53 +00:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- 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 https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- 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
```
2024-08-12 15:24:27 +01:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Markus Reiter
02dbeb62fc
Refactor RuboCop tests. 2023-05-09 04:28:25 +02:00
Issy Long
2aeeaf706e
Merge pull request #14891 from issyl0/cask-rubocops-unnecessary-requires 2023-03-06 12:23:49 +00:00
Issy Long
1d65c942c3
rubocops/cask: Clean up unnecessary requires
- I suspect these were copy-pasted from other cops, like I did in
  https://github.com/Homebrew/brew/pull/14886#discussion_r1125569999.
- The "forwardable" require is unnecesary if the cop doesn't
  `extend Forwardable` and use `def_delegator`.
- The "uri" require is unnecessary if the cop doesn't call `URI` methods.
2023-03-05 17:13:46 +00:00
Issy Long
f4a0bc7af3
rubocops/cask: Appease Sorbet with the correct inheritance
- The `on_url_stanza` method is now used in two cops, `Url` and
  `UrlLegacyCommaSeparators`. Make the latter inherit from the former
  to make Sorbet happy.
- The style and typecheck checks now pass fine.
2023-03-05 16:33:11 +00:00
Bevan Kay
8c82ec964f
Update Library/Homebrew/rubocops/cask/url_legacy_comma_separators.rb
Co-authored-by: Issy Long <issyl0@github.com>
2022-01-12 10:40:22 +11:00
Bevan Kay
d371547d5a
fix tests 2022-01-12 10:39:38 +11:00
Bevan Kay
7e24930e4e
Update Library/Homebrew/rubocops/cask/url_legacy_comma_separators.rb
Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2022-01-11 01:22:22 +11:00
Bevan Kay
22d68fb99b
fix style offences 2022-01-10 21:34:51 +11:00
Bevan Kay
cc2b99c8cf
Add check for url :block 2022-01-10 21:27:20 +11:00
Bevan Kay
d5448ff54a
rubocops (cask/url): add rubocop to use csv instead of before_comma and after_comma in cask 2021-12-31 11:08:47 +11:00