577 Commits

Author SHA1 Message Date
Douglas Eichelberger
936b9b5369
Move nil check inside demodulize 2025-02-24 11:57:20 -08:00
Kristján Oddsson
3b0794a884 implement fixes and comments for DisableComment rubocop 2025-01-29 09:17:11 +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
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
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Issy Long
921753cf84
Fix RuboCop Performance/BindCall offenses 2024-02-25 23:00:07 +00:00
Bo Anderson
5aebde3ffd Add consistent path validation 2024-01-01 18:37:47 +00:00
apainintheneck
1118a49d42 utils: Homebrew.system respect stderr
This caused some JSON output to break recently which is not ideal.

The change here is to check if the output should be diverted to
stderr based on the options passed to system. If `:out => :err`
is passed, then we should send any verbose output to stderr
as well.

```console
$ brew ruby -e 'Homebrew.system("ls", :out => :err)' 2>| wc -c
     105
$ brew ruby -e 'Homebrew.system("ls")' | wc -c
     105
```
2023-10-28 23:43:35 -07:00
apainintheneck
85bd4c7e1f utils/backtrace: scrub sorbet-runtime from backtrace
Ever since we started using this at runtime it's been polluting
the backtrace output. This makes it harder to debug errors and
increases the amount of info users have to paste into the box
when filing an issue.

This is a very direct approach. Essentially, we strip out
everything related to the `sorbet-runtime` gem whenever the top
line in the backtrace is unrelated to sorbet-runtime.

The hope is that this will allow errors related to sorbet to
be diagnosed easily while also reducing the backtrace size
for all other types of errors.

Sometimes it is useful to see the full backtrace though.
For those cases, we include the full backtrace when
`--verbose` is passed in and print a warning that the
Sorbet lines have been removed from the backtrace the
first time they are removed.

Note: This requires gems to be set up so that the call to
`Gem.paths.home` works correctly. For that reason, it must
be included after `utils/gems` which is included in
`standalone/load_path` already.
2023-09-21 21:07:22 -07:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Dustin Rodrigues
b776fb32de
change includecount to include_count for readability 2023-03-20 07:23:17 -04:00
Dustin Rodrigues
b68c955946
utils: add includecount argument to pluralize util 2023-03-19 23:35:40 -04:00
Douglas Eichelberger
a1748605ab Minor Kernel cleanup 2023-03-14 10:27:16 -07:00
Douglas Eichelberger
6cfab10e2b typecheck 2023-03-07 10:45:53 -08:00
Douglas Eichelberger
6ffda80a8a brew style 2023-03-07 10:14:57 -08:00
Douglas Eichelberger
544960b4fc Replace String#underscore with util 2023-03-07 10:13:38 -08:00
Douglas Eichelberger
d56e2884aa Enable typing in cmd/ 2023-03-06 15:01:08 -08:00
Douglas Eichelberger
d98b7845d3 Enable typing in misc files 2023-03-03 08:29:26 -08:00
Douglas Eichelberger
325994a60c Move inflection utils to Utils module 2023-02-27 20:20:56 -08:00
Douglas Eichelberger
0438a3a538 Draft implementation to replace ActiveSupport inflections 2023-02-27 20:17:33 -08:00
Douglas Eichelberger
2b4d4a3707 Isolate Kernel extensions 2023-02-27 11:22:10 -08:00
Douglas Eichelberger
901a179ba6 Set back utils.rb file 2023-02-27 11:19:11 -08:00
Douglas Eichelberger
ff48ce24c4 Copy utils.rb into extend/kernel.rb 2023-02-27 11:19:11 -08:00
Maxim Belkin
c9b289fc3d Use 'wslview' instead of 'xdg-open' on Windows 2023-02-27 14:39:56 +00:00
Mike McQuaid
aca3eead71
which_editor: remove Atom.
It's been deprecated. Make VSCode first because it's what we recommend.
2023-02-23 08:53:32 +00:00
apainintheneck
a7dbd738dd cmd/edit: stop double warning
When you don't have EDITOR or HOMEBREW_EDITOR
configured `brew edit` printed a double warning.

This silences the first of those.
2023-02-11 00:16:11 -08:00
EricFromCanada
dfc9906184
internal messaging fixes 2023-02-10 23:17:16 -05:00
Mike McQuaid
6b4363092d
Revert "Merge pull request #14548 from Homebrew/revert-14382-deprecate-disable-remove"
This reverts commit 932d2cf3b77c9439a57b6a43577fc8d3b6399a62, reversing
changes made to f4e60482791d2ff628efadfdbf0d14d9237d2d29.
2023-02-07 19:25:51 +01:00
Mike McQuaid
6882ac17e7
Revert "Add deprecations and disables" 2023-02-07 15:13:19 +01:00
Mike McQuaid
59c03cb2a6
Add deprecations and disables
Do the usual dance:
- commented `odeprecated` to `odeprecated`
- `odeprecated` to `odisabled`
- `odisabled` removed
2023-02-03 10:48:43 +00:00
Caleb Xu
f6474c5048
utils: prepare for deprecation of Utils.gzip 2023-01-06 22:58:53 -05:00
EricFromCanada
76199ddd72
utils: prefer BBEdit over TextWrangler 2022-08-31 15:26:58 -04:00
fn ⌃ ⌥
a208ea9c92 info: highlight package name 2022-08-15 07:47:52 -07:00
Bo Anderson
02164a35db
Use ORIGINAL_PATHS over envs; reject nil PATH 2022-06-17 19:47:57 +01:00
Bo Anderson
8ada737d40
Encapsulate ENV["SHELL"] usage 2022-06-17 19:47:57 +01:00
Bo Anderson
e78665f4f7
Replace ENV["HOME"] with Dir.home 2022-06-17 19:47:57 +01:00
Bo Anderson
40bbdc659e
Fix some Style/FetchEnvVar offences 2022-06-17 19:47:57 +01:00
Mike McQuaid
04c8e02418
cmd/update-report: use better wording where appropriate.
From reading https://github.com/orgs/Homebrew/discussions/3328: I
initially thought we should just change "Updated" to "Modified" when
appropriate. After conversation with Bo98, though, I thought more and
saw that we're already checking for outdated formulae here so, rather
than ever traverse through the formula history, look at the outdated
formula and list them unless we've set
`HOMEBREW_UPDATE_REPORT_ALL_FORMULAE` in which case we show the
modifications.

While we're here, also do a bit of reformatting and renaming to better
clarify intent.
2022-06-03 19:23:38 +01:00
Bo Anderson
6ec9095946
utils: add disable_for_developers option for odeprecated 2022-04-18 16:41:58 +01:00
Adrian Ho
cbac7a3063 brew: keep DBus session address in env
Otherwise `brew deps --graph` will fail to launch Firefox on Linux.

Fixes https://github.com/Homebrew/brew/issues/12881.
2022-02-17 14:55:15 +08:00
Xuehai Pan
62a63063bb Apply suggestions from code review
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Signed-off-by: XuehaiPan <XuehaiPan@pku.edu.cn>
2021-11-24 01:06:27 +08:00
XuehaiPan
9ef52080e3 utils: extract common word "for" in reason 2021-11-23 23:59:09 +08:00
XuehaiPan
466f29a16a cmd/update-report: redirect stdout to stderr when it is not a TTY 2021-11-23 23:55:06 +08:00
XuehaiPan
c0826f1890 utils: add method ensure_executable! 2021-11-23 23:32:32 +08:00
XuehaiPan
d749173adc utils: mark reason as keyword argument in ensure_formula_installed! 2021-11-23 23:31:22 +08:00
XuehaiPan
7baaebe544 utils: send output to stderr by default for ensure_formula_installed! 2021-11-23 23:09:42 +08:00
XuehaiPan
3376479e95 utils: add method ensure_formula_installed! 2021-11-23 22:48:39 +08:00
XuehaiPan
687dbe5268 dev-cmd/cat: auto-install bat when running brew cat ... with HOMEBREW_BAT set 2021-11-23 15:20:57 +08:00
fn ⌃ ⌥
84a7c2ba7d
Add VS Code to list of fallback editors 2021-09-30 18:54:51 -07:00
Mike McQuaid
72c59c816f
Merge pull request #11548 from MikeMcQuaid/3_2_deprecate_disable_remove
Deprecate, disable, delete code for Homebrew 3.2.0
2021-06-18 14:34:10 +01:00