60 Commits

Author SHA1 Message Date
Eric Knibbe
cd6777fc73
audits: quote and reword problem description text 2025-05-30 23:49:26 -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
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
Michael Cho
834c2b1094
rubocops: xcodebuild needs an Xcode dependency 2024-09-17 20:41:31 -04: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
Issy Long
cb8769c2a0
rubocops/text: Allow bin interpolation inside word arrays
- We discovered that the following syntax in the formula `sqlsmith`
  should actually be OK because the `\n` is like whitespace.

```ruby
cmd = %W[
  #{bin}/sqlsmith
  --threads=4
  --timeout=10
]
shell_output(cmd)
```
2024-08-04 23:45:34 +01:00
Issy Long
7bf7030db8
Add autocorrection for the interpolated bin audit
- I got bored doing them manually.
- Also now more people can help with letters of the alphabet using `brew style --only=FormulaAuditStrict/Text --fix homebrew/core`.
2024-08-01 22:41:04 +01:00
Issy Long
f0084e611a
rubocops/text: Allow all "#{bin}/foo" interpolated strings with spaces
- This was complaining about `shell_output("#{bin}/abricate-get_db --help 2>&1")` which it shouldn't have.
2024-07-28 17:18:35 +01:00
Issy Long
38bb463aad
Interpolated shell_output("#{bin}/foo -v"), for example, is fine
- This would be weird to change because it's a string not a pathname passed to `shell_output`.
- I had misunderstood https://github.com/Homebrew/brew/pull/17826#discussion_r1690806375.
2024-07-25 13:28:00 +01:00
Issy Long
ace23ce735
Make the bin starts_with method its own thing as it needs more args
- I couldn't get
  https://docs.rubocop.org/rubocop-ast/node_pattern.html#param_name-for-named-parameters
  to work like it said it should (bad syntax in the node_matcher, apart
  from with `bin = false` which RuboCop complained about boolean args not
  being named), so here's a workaround.
2024-07-24 22:41:26 +01:00
Issy Long
3713939e0d
rubocops/text: Include dashed binaries in bin/ interpolation check
- Previously this only included the formula name.
- But, for example in tests, we have "#{bin}/ansible-test",
  not just "#{bin}/ansible". So handle that too.
- I decided to make the error message better by extracting the
  binary name from the interpolation, but I'm not sure it was worth it.

```
$ brew audit --strict ansible
ansible
  * line 580, col 29: Use `bin/"ansible-test"` instead of `"#{bin}/ansible-test"`
Error: 1 problem in 1 formula detected.
```
2024-07-24 22:19:38 +01:00
Issy Long
96400e01e1
rubocops/text: Enforce bin/"formula" instead of "#{bin}/formula" 2024-07-23 12:43:15 +01:00
Sam Ford
17b0493e18
Use struct for #audit_formula args
Adding type signatures to `#audit_formula` methods in formula cops
would lead to verbose, repetitive signatures across the existing ~63
instances. This reworks `#audit_formula` to use a `T::Struct` for its
arguments, which allows us to use a one-line signature for these
methods.
2024-07-08 12:22:25 -04:00
Issy Long
9f915a6a62
Replace FormulaTextAuditor usage
- Only two audits were using this: `audit_keg_only_reason` and `audit_text`,
  and they weren't using any of its text processing methods, so there's little
  reason to keep it around.
- The "`keg_only_reason` shouldn't contain 'HOMEBREW_PREFIX'" audit can easily
  be replaced with a RuboCop since that's "just" text parsing.
- The "tests should invoke binaries with `bin/<command>`" audit had to stay as
  a FormulaAudit because it requires accessing attributes about the Formula
  like its name, aliases, which RuboCop can't get to, but it was easy to move the
  singular "read the text in the file" line from `FormulaTextAuditor`.
2024-05-04 22:14:55 +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
Bo Anderson
b42256d286
Deprecate, disable & delete code for Homebrew 4.2.0 2023-12-07 23:42:13 +00:00
Issy Long
5ddebe1640
rubocops/text: Declare "revision 0" in formulae as unnecessary
- This came up in a user contribution recently so here's a RuboCop for it.
2023-10-04 23:28:30 +01:00
Dawid Dziurla
b4366b61ef
audit: check for cargo build only in install method 2023-08-18 11:20:56 +02:00
Douglas Eichelberger
08af78a2a5 brew style --fix 2023-04-25 09:26:24 -07:00
Douglas Eichelberger
387d2f859f Use exclude_from_registry instead 2023-02-20 18:14:47 -08:00
Douglas Eichelberger
d9db5e8825 Refactor FormulaCop as a mixin 2023-02-20 18:14:47 -08:00
Douglas Eichelberger
6c93f6fe91 Enable typing in rubocops 2023-02-16 15:51:20 -08:00
Bo Anderson
6ede5d2dd5
rubocops: handle empty formula body in various cops 2022-11-05 04:40:16 +00:00
Carlo Cabrera
f05e57f414
Merge pull request #12823 from carlocab/setuptools-audit
rubocops/text: remove `setuptools` audit
2022-02-01 16:57:57 +08:00
Carlo Cabrera
bc67c05528
rubocops/text: remove setuptools audit
This currently no longer applies, because we might sometimes need an
older `setuptools` than the one shipped with a Python formula.

This is needed for Homebrew/homebrew-core#93964.
2022-02-01 15:26:50 +08:00
Roland Crosby
d8df9c2ee9 Allow cargo build --lib
When building Rust packages that provide libraries but no executable
binaries, `cargo install` doesn't do anything; you need to use `cargo
build` and install any libraries manually. See e.g.
rust-lang/cargo#8294.

Unfortunately, Homebrew's Rubocop "use cargo install *std_cargo_args"
rule, as currently written, blocks all invocations of `cargo build`.
This commit changes that rule to exclude invocations of `cargo build`
that use the `--lib` argument (`--lib` specifies to Cargo that a
package's library targets should be built). This will enable library
packages to be built while retaining the "use cargo install
*std_cargo_args" message for the more common case when a Rust package
provides executable binaries.
2022-01-31 21:11:22 -05:00
Dawid Dziurla
55244c845b
rubocops/text: forbid "go get" only in install method 2021-11-14 14:04:14 +01:00
Dean M Greer
ceeb5ea9ec audit: Remove SYMROOT
SYMROOT is only a valid argument when -project is used.

xcodebuild has other uses than building Xcode projects.
2021-05-13 08:07:06 -04:00
nandahkrishna
8e5451df2f
style: use parentheses for assignment in conditions 2021-02-12 18:33:37 +05:30
Jonathan Chang
3bda457478 rubocops/text: use rubocop v1 API 2021-01-12 19:11:43 +11:00
Mike McQuaid
d496f5c121
Deprecations for Homebrew 2.6.0
Do the usual deprecate/disable dance for the Homebrew 2.6.0 release.

Not to be merged until the next release will definitely be 2.6.0.
2020-11-24 16:44:02 +00:00
EricFromCanada
3768b7a6e9 apidoc: update comment wording, punctuation, formatting 2020-11-06 00:21:02 -05:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
7719b4e1f0 Document FormulaAudit::Text. 2020-08-26 03:13:59 +02:00
Rylan Polster
936f4bbff4 refactor share path node matcher 2020-07-12 16:06:50 -04:00
Rylan Polster
d8fb850fa9 fix pkgshare missing slash issue 2020-07-12 14:20:50 -04:00
Rylan Polster
6119934efb style: refactor pkgshare cop 2020-07-12 12:12:36 -04:00
Rylan Polster
074f79840c style: refactor prefix path check 2020-07-12 12:12:36 -04:00
Rylan Polster
69e89d7a01 add TODOs for future refactoring 2020-07-10 15:08:20 -04:00
Rylan Polster
9e52712b08 style: don't need require "formula" 2020-07-10 11:17:37 -04:00
Rylan Polster
1859162735 style: use pkgshare instead of share/foo 2020-07-10 11:17:37 -04:00
Rylan Polster
792533462a style: don't use prefix + directory 2020-07-10 11:17:37 -04:00
Rylan Polster
b4a9565b8b style: require java dependency for JAVA_HOME 2020-07-10 11:17:37 -04:00
Rylan Polster
9ad342eba0 style: don't concatenate in string interpolation 2020-07-10 11:17:37 -04:00
Rylan Polster
63b81d847a style: env :userpaths is deprecated 2020-07-10 11:17:37 -04:00
Rylan Polster
1e943d7b6f style: env :std deprecated in homebrew-core 2020-07-10 11:17:37 -04:00
Rylan Polster
bd8805b14f style: separate make commands 2020-07-10 11:17:37 -04:00
Dario Vladovic
8a62f891e1
formula: add std_cargo_args 2020-06-22 14:39:49 +02:00
Mike McQuaid
604434566f
rubocops/text: whitelist goose. 2020-04-14 11:59:56 +01:00