46 Commits

Author SHA1 Message Date
Douglas Eichelberger
c48870080e
Incorporate feedback 2025-03-13 11:59:31 -07:00
Douglas Eichelberger
f183d0a398
Enable strict typing in Cask::URL 2025-03-12 19:09:52 -07:00
Douglas Eichelberger
1ca5299f40
refactor: Enable strict typing in download_strategy 2025-03-12 15:15:20 -07:00
zyoshoka
20e33166e1
cask/url: remove arch placeholder when checking if unversioned
This prevents casks whose `url` contains only `#{arch}` from passing
`audit_sha256_no_check_if_unversioned`.
2025-02-14 15:14:40 +09:00
Sam Ford
cf22382921
Curl: use typed: strict
This upgrades `utils/curl.rb` to `typed: strict`, which requires
a number of changes to pass `brew typecheck`. The most
straightforward are adding type signatures to methods, adding type
annotations (e.g., `T.let`) to variables that need them, and ensuring
that methods always use the expected return type.

I had to refactor areas where we call a `Utils::Curl` method and use
array destructuring on a `SystemCommand::Result` return value
(e.g., `output, errors, status = curl_output(...)`), as Sorbet
doesn't understand implicit array conversion. As suggested by Markus,
I've switched these areas to use `#stdout`, `#stderr`, and `#status`.
This requires the use of an intermediate variable (`result`) in some
cases but this was a fairly straightforward substitution.

I also had to refactor how `Cask::URL::BlockDSL::PageWithURL` works.
It currently uses `page.extend PageWithURL` to add a `url` attribute
but this reworks it to subclass `SimpleDelegator` and use an
`initialize` method instead. This achieves the same goal but in a way
that Sorbet can understand.
2025-01-14 08:14:39 -05:00
Patrick Linnane
d04430d1a5
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-11-26 14:09:13 -08:00
Douglas Eichelberger
ced4a3a91f Migrate Parlour extensions to Tapioca compilers 2024-10-14 19:50:09 -07:00
Douglas Eichelberger
6eaf122144 Add a Delegator DSL compiler 2024-10-05 19:36:54 -07:00
Mike McQuaid
5b46ec70e9
cask/url: deprecate url do blocks.
We're removing these in
https://github.com/Homebrew/homebrew-cask/pull/186501
so let's deprecate them too.
2024-09-26 14:05:25 +01:00
Douglas Eichelberger
fb2fdc5249 Minor type safety improvements 2024-08-18 18:16:39 -07: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
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02: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
Bevan Kay
5f79980938
cask/url headers parameter type fix 2023-11-09 10:23:13 +11:00
Douglas Eichelberger
0191af7899 resolve typecheck errors 2023-11-05 08:55:58 -08:00
Mike McQuaid
9ce19fc002
cask/url: full scope curl_output call. 2023-09-06 09:55:17 -04:00
Gibson Fahnestock
b4feaf27d9
cask/url: accept Class for using in Cask::URL#initialize
https://github.com/Homebrew/brew/pull/15754 fixed
`Cask::URL::DSL#initialize`, but we also need to fix
`Cask::URL#initialize` as that takes the same parameters.

Error:

```
Error: Cask 'mycask' definition is invalid: 'url' stanza failed
  with: Parameter 'using': Expected type T.nilable(Symbol), got type Class
  with value MyCustomDownloadStrategy
Caller:
  /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/sorbet-runtime-0.5.10461/lib/types/private/methods/call_validation.rb:113
```

Refs: https://github.com/Homebrew/brew/issues/15750
2023-09-04 08:46:22 +01:00
Mike McQuaid
7d153d34e9
cask/url: accept Class for using.
Fixes #15750.
2023-07-25 15:50:49 +01:00
Don Chea
907a9238c2 Always pass headers as array to downloader, if present
We still need to support it being named "header" in the Cask url stanza.
2023-06-28 11:37:15 -04:00
Don Chea
8f8d69a203 cask: url stanza support for multiple headers 2023-06-28 11:36:12 -04:00
Markus Reiter
813e639678
Add cask URL location to audit problems. 2023-05-21 16:17:16 +02:00
Markus Reiter
af1961d509
Fix type for nested url blocks. 2023-04-29 03:33:59 +02:00
Bo Anderson
44f058edb5
Refactor formula, cask and Ruby source downloads to use shared code 2023-04-27 23:23:07 +01:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Nanda H Krishna
fe0eb9b5b0
Fix style issues 2022-12-22 23:52:26 -05:00
Mike McQuaid
77c0d38c35
brew style --fix 2022-12-13 11:37:06 +00:00
Harry Marr
b11df3bef8
Singularise only_paths (now only_path) 2022-10-22 10:53:02 -04:00
Harry Marr
7df90eb7e1
Support git partial clones with sparse checkouts 2022-10-20 15:45:32 -04:00
Bo Anderson
eac32f0b20
Additional fixes for Ruby 3 compatibility 2022-10-18 01:54:59 +01:00
Bo Anderson
f5dc7a571f
Fix Style/ObjectThen offences 2022-06-17 19:47:55 +01:00
Markus Reiter
c8997a0d8b
Don't forward options if none are given. 2021-04-08 00:12:49 +02:00
Markus Reiter
0b6b05d1aa
Implement nested url do API. 2021-04-02 01:41:44 +02:00
Seeker
fbafaff4fe rubocop: require braces for Sorbet sig 2021-01-18 16:52:45 -08:00
Markus Reiter
6e5cf565e3 Ignore verified for url do blocks. 2020-12-12 06:01:26 +01:00
Markus Reiter
76a3c0338b Add unversioned? method to Cask::URL. 2020-12-07 21:40:47 +01:00
linzichao
058a1c3645 add verified parameter in url 2020-12-01 01:17:21 +01:00
Tie
aa979f0e31 add missing param header to url class 2020-10-27 16:47:07 -04:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
d36df37099 Replace custom stubs with sorbet-runtime-stub. 2020-10-09 16:45:13 +02:00
Markus Reiter
6f7b7cc699 Fix type-checking for URL. 2020-10-09 16:45:13 +02:00
Markus Reiter
b92f3a2e93 Document URL. 2020-08-26 03:13:59 +02:00
Mike McQuaid
f951ea83d4
Fix brew style. 2020-07-07 12:23:29 +01:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Mike McQuaid
90b3a13909
cask: move cask/lib/hbc/* to cask/*.
Fix the load path, requires and some filenames accordingly.
2018-09-04 09:56:57 +01:00