31 Commits

Author SHA1 Message Date
Douglas Eichelberger
004c0a2a6c
Refactor exec.rb type fixes 2025-06-29 09:02:24 -07:00
Michael Cho
1c9f084bcc
PATH: typed: strict 2024-09-26 16:19:11 -04:00
Douglas Eichelberger
eeb31d3050 Fix violations 2024-09-20 11:07:00 -07: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
c5dbd3ca24
Rearrange requires
This improves the load time of most brew commands. For an example of
one of the simplest commands this speeds up:

Without Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     525.0 ms ±  35.8 ms    [User: 229.9 ms, System: 113.1 ms]
  Range (min … max):   465.3 ms … 576.6 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     383.3 ms ±  25.1 ms    [User: 133.0 ms, System: 72.1 ms]
  Range (min … max):   353.0 ms … 443.6 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.37 ± 0.13 times faster than git checkout master; brew help
```

With Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     386.0 ms ±  30.9 ms    [User: 130.2 ms, System: 93.8 ms]
  Range (min … max):   359.5 ms … 469.3 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     330.2 ms ±  32.4 ms    [User: 93.4 ms, System: 73.0 ms]
  Range (min … max):   302.9 ms … 413.9 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.17 ± 0.15 times faster than git checkout master; brew help
```
2024-07-14 08:49:39 -04:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Markus Reiter
c76170a456
Hide #to_s in docs. 2024-04-26 14:04:55 +02:00
Douglas Eichelberger
c4db19232d git grep -lE '\(\&[A-Za-z._]+method\(:' | xargs gsed -i -E 's|\(\&([A-Za-z._]+)method\(:([a-z?_]+)\)\)| { \1\2(_1) }|g' 2024-03-03 18:55:56 -08:00
Issy Long
149b0e4f31
Fix new Style/MutableConstant RuboCop offenses for Ruby 3.1
- A follow-up to de592af20bbff5bcb548d2474f0722e59ff1129a, resetting the previous disabled comments too.
2023-12-16 11:57:06 +00:00
Issy Long
de592af20b
rubocop: Set TargetRubyVersion to 3.1 & disable all cops that fail
- As discussed in
  https://github.com/Homebrew/brew/pull/16337#issuecomment-1855668516,
  then we won't have the chicken/egg problem of fixing cops for syntax
  that's unsupported on Ruby 2.6 _before_ we set the TargetRubyVersion
  to 3.1, but if we set it too early then all the taps will fail.
2023-12-14 23:19:43 +00:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Dustin Rodrigues
eb1fbab729
minor typo fixes 2022-11-06 22:50:07 -05:00
Markus Reiter
1690f064a2 Add types for Formula. 2020-11-25 17:36:52 +01:00
Markus Reiter
1b732ec7b2 Fix RuboCop offenses. 2020-11-16 02:05:29 +01:00
Rylan Polster
50890ebd51 fix Lint/DuplicateBranch style 2020-11-16 02:02:52 +01:00
Markus Reiter
a582b6e371 Add type signatures for PATH. 2020-10-19 22:10:21 +02:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Mike McQuaid
8b97c27c21 brew style manual fixes 2020-09-01 14:26:45 +01:00
Markus Reiter
a231116252 Document PATH. 2020-08-26 03:13:58 +02:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Markus Reiter
9f1b64a9d4 Add additional specs for PATH. 2018-04-20 19:11:22 +02:00
Markus Reiter
1be5eeec26 Add test and comment for PATH#existing. 2017-04-30 21:23:12 +02:00
Markus Reiter
005f165dcb Simplify PATH#parse. 2017-04-30 21:11:49 +02:00
Markus Reiter
4d5d6a65e3 Rename PATH#validate to PATH#existing. 2017-04-30 21:11:28 +02:00
Markus Reiter
22f624b373 Make PATH enumerable. 2017-04-30 21:11:28 +02:00
Markus Reiter
e70f2ec332 Make sure duplicates are remove from PATH. 2017-04-30 21:11:28 +02:00
Markus Reiter
0bb9b4918e Remove PATH#inspect. 2017-04-30 21:11:28 +02:00
Markus Reiter
d552ff316d Make PATH#validate return nil if empty. 2017-04-30 21:11:28 +02:00
Markus Reiter
cb1ac3f998 Don’t implement PATH#eql?. 2017-04-30 21:11:27 +02:00
Markus Reiter
a16746906d Add PATH class. 2017-04-30 21:11:27 +02:00