122 Commits

Author SHA1 Message Date
Bo Anderson
2dfb8c0b76
style: run shfmt on real brew 2025-07-07 17:28:31 +01:00
Patrick Linnane
9821a7e896
fix new offenses
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2025-03-27 03:38:09 +00:00
Mike McQuaid
7a5d4256e5
Fix Rubocop warnings (without brew style --fix) 2025-02-28 09:59:32 +00:00
Mike McQuaid
e9b4979f40
Add support for Homebrew wrappers
Allow the ability for a system administrator to use
`HOMEBREW_BREW_WRAPPER` and `HOMEBREW_FORCE_BREW_WRAPPER` variables to
enforce the usage of a particular `brew` command for non-trivial (e.g.
`brew --prefix` is considered trivial, it doesn't need to write to the
prefix) Homebrew commands.

This also introduces a `HOMEBREW_ORIGINAL_BREW_FILE` variable for some
internal usage; `HOMEBREW_BREW_FILE` was being used internally for
both "how should we shell out to Homebrew" and "what should we use
to check permissions on Homebrew". `HOMEBREW_ORIGINAL_BREW_FILE` is
now used just for the latter case.

Inspired by conversation in
https://github.com/Homebrew/homebrew-bundle/pull/1551 which suggested
this was worth fixing in wider than just `brew bundle`.
2025-01-07 17:40:18 +00:00
Carlo Cabrera
53f6e46eb3
style: skip actionlint checks if an actionlint workflow is present
Fixes #18382.
2024-09-27 15:29:07 +08:00
notfirefox
bb4208ebf1 style: resolve symblic links in HOMEBREW_CACHE
On Linux HOMEBREW_CACHE may be set to `$HOME/.cache/Homebrew`. Some
systems, like Fedora Silverblue, have `/home` set up to be a symbolic
link to `/var/home`. While Homebrew generally seems to work fine on
Fedora Silverblue, rubocop causes the `brew style` command to emit
a lot of warnings because of the symbolic link[1]. This can be resolved
by looking up the real path of HOMEBREW_CACHE before passing it to rubocop.

[1] https://github.com/rubocop/rubocop/issues/6228

Co-authored-by: Bo Anderson <mail@boanderson.me>
2024-09-16 09:50:48 +02: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
Patrick Linnane
5466d6a57a
Replace deprecated Cop.registry with Registry.global
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-07-10 13:07:02 -07:00
Bo Anderson
1de1be8937
style: chdir before running rubocop 2024-06-30 01:51:56 +01:00
Mike McQuaid
214359316f
Merge pull request #17506 from shivammathur/actionlint 2024-06-14 18:38:46 +01:00
Shivam Mathur
dbb2bb9fb9 style: ignore runner labels 2024-06-14 17:28:06 +00:00
Mike McQuaid
dcc5659a70
style: reject *.sh directories.
Otherwise silly things happen like thinking formulae.brew.sh directories
are files.
2024-06-14 16:09:21 +01:00
Mike McQuaid
a707c708c1
Fix/reenable brew style docs
- start running this check again
- check the `docs` basename correctly
- use a different name (to a symlink) for the docs rubocop
  configuration so that path relativity is done correctly:
  https://docs.rubocop.org/rubocop/configuration.html#path-relativity
- add more wildcards to fix docs rubocop exclusions
2024-06-13 12:31:47 +01:00
Mike McQuaid
349627e3dd
style: ignore actionlint false-positive. 2024-06-13 09:55:30 +01:00
Mike McQuaid
9e863aa4a9
style: fix path checking.
Add all necessary files to the path, using globs when necessary.
2024-06-13 09:26:41 +01:00
Sam Ford
af02d94f73
style: fix tap checking
`brew style` tap support was broken in 7d0ac4d (#17357), so now
something like `brew style homebrew/core` exits without checking
anything. This happens because the new file-handling logic doesn't
do anything with a tap path. Previously, a tap path would be added
to `ruby_files` but now it isn't added to any of the arrays of files
to check.

This fixes the issue by adding some logic to add the path to the
`ruby_files` array if it's a tap.
2024-06-13 09:26:41 +01:00
Mike McQuaid
dfe2b5b2ca
style: tweak style.
Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
2024-06-13 08:47:59 +01:00
Mike McQuaid
ed0d6b7f61
docs: fix brew style 2024-06-12 19:17:17 +01:00
Mike McQuaid
7d0ac4dd4b
style: run actionlint.
It feels nice to also be running this as part of `brew style` checks
and, indirectly, `brew test-bot` tap syntax checks.

Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2024-05-27 15:30:04 +01:00
Mike McQuaid
16901a674f
extend/kernel: make opoo/odie/etc. print GitHub Actions notes.
We already do this for deprecations but these may make warnings
and errors from Homebrew easier to spot in GitHub Actions logs.

While we're here, cleanup other cases that should have used
`GitHub::Actions::Annotation` but didn't and provide some helpers and
tweaks there necessary for our use case here.
2024-05-09 14:43:53 +01:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Mike McQuaid
aa6ea4be83
Call Homebrew.install_bundler_gems! more consistently.
- Call `Homebrew.install_bundler_gems!` as early as possible
- Always call `Homebrew.install_bundler_gems!` in `dev-cmd` rather than
  in `Library/Homebrew` helpers method (to ensure we don't accidentally
  call this for non-dev-cmd commands)
2024-04-30 10:39:35 +01:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Issy Long
06028c204a
Merge pull request #16518 from issyl0/rubocop-md
rubocop: Try out `rubocop-md` for linting the code in our docs
2024-02-02 15:49:46 +00:00
Douglas Eichelberger
eb7c3e52a0 Require SystemInclude only where needed 2024-01-31 11:42:01 -08:00
Issy Long
00b47d1fec
Teach brew style about docs/.rubocop.yml
- Yes, we have yet another `.rubocop.yml` but in-line exclusions in
  `<span class="display:none;">` in the Markdown seemed more ugly.
- This needed tweaks to `brew style` to make it read the new config
  file when we're scanning docs.
2024-01-24 00:01:45 +00:00
Bo Anderson
3b1c171184
Further split up Gemfile into groups 2023-09-27 17:33:44 +01:00
Markus Reiter
813e639678
Add cask URL location to audit problems. 2023-05-21 16:17:16 +02:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Issy Long
41466025cc
dev-cmd/style: Properly clean up the --display-cop-names option
- I remember making these changes as part of the RuboCop bump
  Dependabot PR (15136), but I must have not actually pushed them. Odd.
2023-04-11 00:19:09 +01:00
Douglas Eichelberger
b8aa619f2f brew style --fix 2023-03-15 18:21:41 -07:00
Douglas Eichelberger
827fc87cde Enable more typing 2023-03-15 14:29:15 -07:00
Douglas Eichelberger
ed8363fd72 Consolidate some rubocop configurations 2023-02-21 16:50:29 -08:00
Sean Molenaar
f30779c6bf
Update package/scripts/postinstall 2022-12-23 19:36:13 +01:00
Mike McQuaid
a92c9eed82
style: check more shell scripts.
We were missing a few here so add them. Also, fix the changes in
`on-create-command.sh` that this catches.
2022-11-09 17:29:38 +00:00
Bo Anderson
e03548fc7a
style: use HOMEBREW_RUBY_EXEC_ARGS 2022-11-05 04:18:10 +00:00
Bo Anderson
a776d5f02b
Workaround macOS system Ruby issue picking incorrect native gem archs 2022-10-14 01:30:38 +01:00
Mike McQuaid
6b697470fd
brew style --fix
For https://github.com/Homebrew/brew/pull/13671
2022-08-10 14:19:33 +01:00
Bo Anderson
f804a22dc0
style: use new autocorrect flag 2022-06-17 19:47:57 +01:00
Mike McQuaid
bf34f21065
style: use long shfmt arguments.
This allows removing documentation explaining them.
2022-05-16 17:19:16 -04:00
Bryce Glover
1763beb8f6
Revert "Enable .rubocop.yml in taps" 2022-03-28 20:11:04 -04:00
danielbayley
59885d7719 Enable .rubocop.yml in taps 2022-03-24 20:28:50 +00:00
Xuehai Pan
2466353415 style: use short flags for patch command for compatibility 2022-01-03 22:13:32 +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
d749173adc utils: mark reason as keyword argument in ensure_formula_installed! 2021-11-23 23:31:22 +08:00
XuehaiPan
3376479e95 utils: add method ensure_formula_installed! 2021-11-23 22:48:39 +08:00
Mike McQuaid
e38e25dfd1
Merge pull request #12397 from XuehaiPan/shellcheckrc
.shellcheckrc: disable unneeded check SC2310-SC2312 globally
2021-11-08 16:15:21 +00:00
XuehaiPan
d78c11361a .shellcheckrc: disable unneeded check SC2310-SC2312 globally 2021-11-08 23:50:54 +08:00