20 Commits

Author SHA1 Message Date
Issy Long
0fc1eb534b
More Sorbet typed: strict RuboCops
- Some of these I bumped to `typed: strict`, some of them I added
  intermediary type signatures to some of the methods to make my life
  easier in the (near, hopefully) future.
- Turns out that RuboCop node matchers that end in `?`
  can return `nil` if they don't match anything, not `false`.
2025-02-08 23:38:12 +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
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Justin Krehel
36cc201616
rubocops/cask/array_alphabetization: skip blank lines when sorting 2024-04-17 14:22:48 -04:00
Issy Long
f4218a6316
Fix RuboCop Performance/MapCompact offenses
- Rename an iterator variable since it would make the line too long.
2024-02-25 22:59:59 +00:00
Issy Long
693a27d48b
Treat zap and uninstall the same
- Since `zap` can have more than just `trash`.
2024-01-21 19:48:30 +00:00
Issy Long
d5f9eef1b5
Empty line after guard clause, gah 2024-01-21 12:47:33 +00:00
Issy Long
458844af44
Move multi-line comments with the code they're 'attached' to
Co-authored-by: Bevan J. Kay <email@bevankay.me>
2024-01-21 12:42:22 +00:00
Issy Long
eec7a96fbe
Use Ruby 3.1's intersect\? method 2024-01-20 00:38:34 +00:00
Issy Long
e9bcb64000
Double quotes not single 2024-01-20 00:35:40 +00:00
Bevan J. Kay
779f1bba7d
Move comments in tandem with the lines they belong to 2024-01-20 00:03:34 +00:00
Issy Long
dae9b0cd53
very wip and bad comment handling 2024-01-18 12:53:23 +00:00
Issy Long
338e30ff9b
There are more arrays that contain non-alphabetizeable commands 2024-01-14 20:55:51 +00:00
Issy Long
6a1cb62b42
Appease RuboCop 2024-01-14 20:55:22 +00:00
Issy Long
9070f6d829
Check uninstall too, avoiding arrays containing commands 2024-01-02 23:31:13 +00:00
Issy Long
fb124f92ed
Ignore non-zap trash methods 2023-12-22 00:41:56 +00:00
Issy Long
b9f13fc35d
Better detection and replacement of non-alphabetized arrays
- Use `sort_by` to sort the array, rather than comparing each element
  to the next.
- This doesn't error with complaints about clobbering at all when run on
  `homebrew/cask`, hurray. And it also handles interpolations correctly,
  rather than ignoring them.

Co-authored-by: Bevan Kay <email@bevankay.me>
2023-12-22 00:26:38 +00:00
Issy Long
f4754baa00
Ignore zap trash stanzas with interpolation
- Interpolating the version into a path is a common pattern, but the interpolations
  trip up the alphabetization autocorrect quite spectacularly, so let's
  ignore them (for now?).
2023-12-22 00:19:03 +00:00
Issy Long
73b3ace77c
Apparently N is alphabetically before c; downcase the comparison 2023-12-21 01:25:18 +00:00
Issy Long
8cf58e36e6
Add a new RuboCop for alphabetizing zap trash array elements
- Part of issue 16323.
- Previously this was being done manually by Cask maintainers.
- While we're here, enforce that the `zap trash` path is not in `[]` if
  it only contains a single element.
- This is buggy on actual Casks, hence the draft PR.
2023-12-19 23:42:08 +00:00