838 Commits

Author SHA1 Message Date
Patrick Linnane
cb15b67b8e
various: correct Style/CollectionQuerying
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2025-07-11 10:43:00 -07:00
Issy Long
7f333ab6ec
Merge pull request #20235 from Homebrew/slash-not-plus-in-paths
rubocops/text: Prefer `lib/"string"` over `lib+"string"`
2025-07-11 12:56:54 +00:00
Issy Long
d4d1b4a22a
rubocops/text: Prefer lib/"string" over lib+"string"
- I found a few occurrences of this pattern from
  https://github.com/orgs/Homebrew/projects/5?pane=issue&itemId=97021840,
  that is an automated style request for:
  `core: use / instead of + operator in e.g. (lib+"lv").install "lv.hlp"`.
- Upon adding tests I realised that there's also the `prefix + "bin"`
  case that's already handled differently, so let's combine the handling
  given it's the same `+` that's wrong.
2025-07-11 13:41:58 +01:00
Mike McQuaid
71bab462e1
Add ZeroZeroZeroZero cop
Add a new RuboCop to detect the use of 0.0.0.0 in formulae which
indicates binding to all network interfaces, internally or externally,
so is a bad default and potentially a security risk.

Co-authored-by: Issy Long <me@issylong.com>
2025-07-11 08:24:19 +01:00
Mike McQuaid
d661cffc1f
Switch to using main as the default branch
Homebrew/brew has moved to a `main` default branch so we can more move
references from `master` to `main`.
2025-06-24 11:14:57 +01:00
Mike McQuaid
afa5d50b36
rubocops/caveats: only apply dynamic logic check to core.
This doesn't really matter for non-API taps.
2025-06-23 08:58:34 +01:00
Mike McQuaid
f77c9861de
rubocops/caveats: check for dynamic caveats.
This will avoid issues with the JSON API.
2025-06-19 10:13:32 +01:00
botantony
aecdcd4840
rubocops: add no_autobump! rubocop
Signed-off-by: botantony <antonsm21@gmail.com>
2025-06-18 16:16:12 +02:00
Eric Knibbe
ea8152757e
rubocops/cask/no_overrides: avoid nested depends_on macos: 2025-06-10 14:31:58 -04:00
Eric Knibbe
c75122c694
rubocops/cask/url: put keyword parameters on a new line 2025-06-05 10:53:34 -04:00
Eric Knibbe
cd6777fc73
audits: quote and reword problem description text 2025-05-30 23:49:26 -04:00
Colin Dean
d5b3ae095c
Prohibit non-ASCII characters in URLs, nudge toward punycode
Inspired by curl's blog post, [Detecting malicious Unicode][1], this likely captures most if not all cases and nudges the user toward supplying IDNs with punycode.

A possible improvement would be telling the user exactly what punycode domain to use instead, but that may require another library as I can't quickly find something built into the Ruby stdlib that handles punycode encoding.

[1]: https://daniel.haxx.se/blog/2025/05/16/detecting-malicious-unicode/

Co-authored-by: Štefan Baebler <319826+stefanb@users.noreply.github.com>
2025-05-21 12:42:07 +01:00
Sean Molenaar
107120e4d8
Merge pull request #19880 from Moisan/audit_bitbucket_patch
patches audit: bitbucket patches should use api
2025-05-15 12:45:30 +00:00
Eric Knibbe
0838ceda90
cask: document shell completion stanzas
Also, allow them to be given a `target:` parameter.
2025-05-09 14:47:26 -04:00
Thierry Moisan
84704c5587
patches audit: bitbucket patches should use api 2025-05-01 22:53:42 -04:00
Mike McQuaid
c9a7b62b1d
Homebrew 4.5 deprecations/disables/removals
The usual cycle of deprecating, disabling, and removing things in
Homebrew major/minor releases.
2025-04-22 17:15:23 +01:00
Carlo Cabrera
ab59e2d5dc
Merge branch 'master' into arm64-linux-bottle-blocks 2025-03-18 17:25:00 +08:00
Carlo Cabrera
11827656a9
Fix bottle block generation and audit for arm64 Linux
Before this change, `brew bottle` would add the `:arm64_linux` bottle
lines last. This would make `brew style` complain because it wants the
`arm64_*` bottles listed first.

Let's fix this by retaining the existing style as closely as possible:
- macOS bottles are listed first
- for each OS, arm64 bottles are listed first (just as we do on macOS)

In particular, `brew bottle` will now insert `:arm64_linux` bottle lines
just above the `:x86_64_linux` bottle lines (but still below the macOS
bottle lines).

x86_64 may continue to be a more popular platform on Linux for quite
some time. However, users looking for those bottles can continue to look
in the same place as before this change (i.e., the last line of the
bottle block). Taking this together with the consistency on macOS
mentioned above, I think this is the right way forward here.

For concreteness, here are some examples of bottle blocks before and after
this change.

Before this change, immediately after `brew bottle`:

    bottle do
      sha256 arm64_sequoia: "1a57e04052f4bae4172d546a7927c645fc29d2ef5fafbec19d08ee1dddc542fb"
      sha256 arm64_sonoma:  "a58cf9af5d04d3d5709b5337f3793586087a79e178da51d1f3978c0c13b8cf34"
      sha256 ventura:       "6d8b90b2cbb31dcb78394c6540f5454cd57232fc309921173814f880e63718f0"
      sha256 x86_64_linux:  "cd5faac2834ba79e39429b9aac99e4f69d6e6023cbb1cbcd0b62e94cfc69bb2a"
      sha256 arm64_linux:   "457d3e9bd0c287483e27f29a488a18c90e1f55be076fc49b07942ef396c419be"
    end

Before this change, after doing `brew style --fix`:

    bottle do
      sha256 arm64_sequoia: "1a57e04052f4bae4172d546a7927c645fc29d2ef5fafbec19d08ee1dddc542fb"
      sha256 arm64_sonoma:  "a58cf9af5d04d3d5709b5337f3793586087a79e178da51d1f3978c0c13b8cf34"
      sha256 arm64_linux:   "457d3e9bd0c287483e27f29a488a18c90e1f55be076fc49b07942ef396c419be"
      sha256 ventura:       "6d8b90b2cbb31dcb78394c6540f5454cd57232fc309921173814f880e63718f0"
      sha256 x86_64_linux:  "cd5faac2834ba79e39429b9aac99e4f69d6e6023cbb1cbcd0b62e94cfc69bb2a"
    end

After this change:

    bottle do
      sha256 arm64_sequoia: "1a57e04052f4bae4172d546a7927c645fc29d2ef5fafbec19d08ee1dddc542fb"
      sha256 arm64_sonoma:  "a58cf9af5d04d3d5709b5337f3793586087a79e178da51d1f3978c0c13b8cf34"
      sha256 ventura:       "6d8b90b2cbb31dcb78394c6540f5454cd57232fc309921173814f880e63718f0"
      sha256 arm64_linux:   "457d3e9bd0c287483e27f29a488a18c90e1f55be076fc49b07942ef396c419be"
      sha256 x86_64_linux:  "cd5faac2834ba79e39429b9aac99e4f69d6e6023cbb1cbcd0b62e94cfc69bb2a"
    end
2025-03-18 16:10:43 +08:00
Issy Long
089680c76f
rubocops/cask/stanza_order: Ensure arch and os are adjacent
- Because Patrick wanted this to be codified.
2025-03-16 21:36:07 +00:00
Heath Stewart
42caf20fa4
Add PowerShell (pwsh) completion support
Resolves #19403
2025-03-02 18:17:38 -08:00
Nanda H Krishna
cf0b00a05c
rubocop/lines: prefer assert_path_exists and refute_path_exists 2025-02-18 10:52:32 -05:00
Patrick Linnane
797ccdd11c
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2025-02-12 21:49:12 -08:00
BrewTestBot
a82bd70ff6
sorbet: Autobump sigils via Spoom
Autogenerated by the [sorbet](https://github.com/Homebrew/brew/blob/master/.github/workflows/sorbet.yml) workflow.
2025-02-12 21:49:06 -08:00
Issy Long
bb56089fe7
Merge pull request #19277 from Homebrew/rm-old-todo
rubocops/lines: Clean up an old TODO
2025-02-11 11:00:03 +00:00
Issy Long
9359292db0
Retain the mis-ordered dependency case.
Co-authored-by: Carlo Cabrera <github@carlo.cab>
2025-02-11 10:28:52 +00:00
Issy Long
87b61a2317
Merge pull request #19195 from Homebrew/sorbet-strict-more-rubocops
More Sorbet `typed: strict` RuboCops
2025-02-10 22:37:56 +00:00
Issy Long
d9b376a9cd
rubocops/lines: Clean up an old TODO
- I considered writing a cop for this, but it's not worth it:
  there are no `[:test, :build]` occurrences in Core and this
  Rust rule only applies in Core formulae.
2025-02-09 18:33:27 +00:00
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
Kristján Oddsson
7b01442273 make sure disable comments have content 2025-01-31 20:38:21 +01:00
Kristján Oddsson
d7af1e3527 add missing } 2025-01-31 20:20:00 +01:00
Kristján Oddsson
4acdcfcb37
Add a DisableComment Cop
Co-authored-by: Issy Long <issyl0@github.com>
2025-01-31 15:39:17 +01:00
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
06441f1337
Generic RuboCop::AST::Node for stanza method nodes
- These can be either BlockNode, SendNode or AsgnNode,
  which are all a type of Node.
- This causes errors in other places because we call
  BlockNode or SendNode methods on a Node now. Still TODO.
2025-01-25 22:20:08 +00:00
Issy Long
9a97456767
Bump more Cask RuboCops to Sorbet typed: strict
- This includes a new Tapioca compiler for
  `RuboCop::Cask::AST::Stanza` dynamic methods like
  `caveats?`.
2025-01-25 18:45:24 +00:00
Issy Long
94085ebb57
Bump more RuboCops to Sorbet typed: strict 2025-01-06 00:09:53 +00:00
Rui Chen
79ed2c6e61
chore: fix typos
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-12-28 15:53:35 -05:00
Sam Ford
79e20b3512
Standardize livecheck block language formatting 2024-12-02 10:13:04 -05:00
Sam Ford
01cb74e525
livecheck: clarify livecheckable language
Formulae, casks, and resources have a `#livecheckable?` method that
indicates whether they contain a `livecheck` block. This is intended
to be read as "has a livecheckable?", not "is livecheckable?" (as
livecheck can find versions for some packages/resources without a
`livecheck` block). Unfortunately, correct understanding of this
method's behavior [outside of documentation] relies on historical
knowledge that few people possess, so this is often confusing to
anyone who hasn't been working on livecheck since 2020.

In the olden days, a "livecheckable" was a Ruby file containing a
`livecheck` block (originally a hash) with a filename that
corresponded to a related formula. The `livecheck` blocks in
livecheckable files were integrated into their respective formulae in
August 2020, so [first-party] livecheckables ceased to exist at that
time. From that point forward, we simply referred to these as
`livecheck` blocks.

With that in mind, this clarifies the situation by replacing
"livecheckable" language. This includes renaming `#livecheckable?` to
`#livecheck_defined?`, replacing usage of "livecheckable" as a noun
with "`livecheck` block", replacing "livecheckable" as a boolean with
"livecheck_defined", and replacing incorrect usage of "livecheckable"
as an adjective with "checkable".
2024-12-02 10:13:03 -05:00
Michael Cho
8e3f2cea06
rubocops/uses_from_macos: allow using Sequoia jq 2024-11-26 11:05:05 -05:00
Issy Long
f923ac574f
sorbet: Bump some Cask files to typed: strict 2024-11-26 00:25:06 +00:00
Bo Anderson
3292dc3543
rubocops/shared/url_helper: tweak SourceForge handling 2024-10-24 20:40:32 +01:00
apainintheneck
7aee21ca8b Fix RuboCop::Cop::FormulaAudit::ShellVariables autocorrect
It used to leave out the parenthesis which could result in invalid
Ruby syntax. Now it always parenthesis here.
2024-10-17 23:46:40 -07:00
Douglas Eichelberger
ced4a3a91f Migrate Parlour extensions to Tapioca compilers 2024-10-14 19:50:09 -07:00
Rylan Polster
18147a6a1e
style: forbid url do blocks in homebrew/cask 2024-09-24 22:45:00 -04:00
Douglas Eichelberger
c354377f3e Exclude sorbet assignments from Style/MutableConstant cop 2024-09-20 10:45:26 -07:00
Michael Cho
834c2b1094
rubocops: xcodebuild needs an Xcode dependency 2024-09-17 20:41:31 -04:00
Michael Cho
fcf05d1b21
rubocops/uses_from_macos: remove gnu-getopt and rpcgen
Also add `bc-gh` which is the version of bc provided by Ventura and
newer macOS. Other `bc` (GNU bc) was provided until Monterey
2024-09-06 09:14:22 -04:00
Bo Anderson
3627cca066
Remove some unnecessary include Kernel 2024-08-20 04:16:18 +01: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
1e560120a6
Merge pull request #17867 from branchvincent/std_npm_args 2024-08-05 08:52:07 +01:00