851 Commits

Author SHA1 Message Date
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
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
Branch Vincent
1771bf1bbb
rubocops/lines: audit std_npm_args usage 2024-08-03 20:28:38 -07:00
Klaus Hipp
f036c2cc1d
rubocops/shared/url_helper: update url audit 2024-08-02 20:00:10 +02:00
Issy Long
870b3423bc
Merge pull request #17937 from khipp/fix-url-audit
rubocops/shared/url_helper: fix url audit
2024-08-02 17:01:06 +01:00
Klaus Hipp
6e1ff402f0
rubocops/shared/url_helper: fix url audit 2024-08-02 17:48:00 +02: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
0872966c27
Avoid double parentheses for eg. (path/here/).rmtree corrections 2024-08-01 18:28:01 +01:00
Issy Long
7404735654
rubocops/no_fileutils_rmrf: Fix rmtree on a method returning Pathname
- Tidy up the node matchers. Either `FileUtils.rm_rf` or `rm_rf` on a
  `Pathname` instance or `self`.
2024-08-01 18:28:01 +01:00
Issy Long
83e21fba11
rubocop/no_fileutils_rmrf: Handle rmtree as an instance method 2024-08-01 18:28:00 +01:00
Issy Long
0889df837a
Casks use FileUtils.rm_rf & Pathname.rmtree still 2024-08-01 18:28:00 +01:00
Issy Long
99c5cc99b5
rubocop/no_fileutils_rmrf: Scope to just formulae and casks 2024-08-01 18:28:00 +01:00
Issy Long
14dd3592dc
rubocop/no_fileutils_rmrf: Discourage Pathname#rmtree too
- This [seems to be](https://ruby-doc.org/3.3.4/exts/pathname/Pathname.html#method-i-rmtree)
  equivalent to `FileUtils#rm_r`, so replace it with that.
2024-08-01 18:28:00 +01:00
Issy Long
ebd9d183dc
rubocop/no_fileutils_rmrf: Extend to cover FileUtils#rmtree too 2024-08-01 18:28:00 +01:00
Issy Long
f4e4808553
rubocop/no_fileutils_rmrf: Extend to cover FileUtils#rm_f too 2024-08-01 18:28:00 +01:00
Issy Long
e6976ae3d1
rubocop: Discourage the use of FileUtils.rm_rf
- This cop checks for the use of `FileUtils.rm_rf` and suggests using
  `FileUtils.rm_r` because we should know if we couldn't delete a
  thing for some reason, not just force it.
2024-08-01 18:27:59 +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
Branch Vincent
5304b70c92
rubocops/lines: remove existing npm audit 2024-07-26 05:41:57 -07:00
Branch Vincent
88aed13958
rubocops/lines: rustup-init -> rustup 2024-07-25 19:26:59 -07: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
Ruoyu Zhong
5fc0fe21a7
Add a RuboCop for shell command stubs 2024-07-15 14:49:25 -04:00
BrewTestBot
456677a3f2
sorbet: Autobump sigils via Spoom
Autogenerated by the [sorbet](https://github.com/Homebrew/brew/blob/master/.github/workflows/sorbet.yml) workflow.
2024-07-14 00:24:16 +00: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
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
Alexander Bayandin
65885590ca rubocops/class: allow disabled formulae to be without a test block 2024-07-03 10:25:26 +01:00
Sean Molenaar
48134ab674 feat: use shared checks for URL cop 2024-06-25 16:13:17 +02:00
Sean Molenaar
bbd73a7243 feat: add shared checks for casks and formulae 2024-06-16 17:24:31 +02:00
Bo Anderson
b2e837f94d
rubocops/shared/desc_helper: fix autocorrect infinite loop 2024-05-21 23:55:26 +01:00
Eric Knibbe
4932fb7fd0
rubocops/urls: remove dead link 2024-05-06 22:57:23 -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
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Mike McQuaid
97ad3567d1
Optimise more command handling/speed
- in `brew.sh` split the `case` into those cases that take a single or
  no arguments and those that take multiple arguments or handle
  multiple commands. This considerably speeds up the
  `brew shellenv bash` case that wasn't being handled here before.
- add `setup-ruby` to the list of commands that can be called quickly
  by `brew.sh` without additional setup. This speeds up the
  `brew setup-ruby` no-op case by ~10x.
- add a parameter to `setup-ruby` to avoid running Bundler if the
  command doesn't need it. This makes many more cases for
  `brew setup-ruby` to be no-op cases.
- Remove the (now) unused `HOMEBREW_RUBY3` check in `setup-ruby`.
- Improve argument handling in `command_path.sh` to allow it to be
  used as a function in `setup-ruby.sh`.
- Add a new RuboCop to check usage of `install_bundler_gems!` is only
  inside `dev-cmd` (or a few other acceptable places).
- Use new `processed_source.file_path` API in `formula_cop.rb`
2024-04-30 12:48:29 +01:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Justin Krehel
36cc201616
rubocops/cask/array_alphabetization: skip blank lines when sorting 2024-04-17 14:22:48 -04:00