818 Commits

Author SHA1 Message Date
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
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