76 Commits

Author SHA1 Message Date
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
Issy Long
268f801038
Bump more files to Sorbet typed: strict 2025-01-11 00:11:27 +00: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
Sam Ford
11d6785bea
Add utils/backtrace requires
This is primarily intended to resolve the `uninitialized constant
Utils::Backtrace` error in `formula_versions.rb:60` but I expanded it
to try to cover all existing usage of `Utils::Backtrace`.

I've followed the existing pattern, where `utils/backtrace` is
required in the context of where it's used. Many of these cases use
`Backtrace` in a conditional manner, so I've tried to ensure that the
`require` follows suit.
2024-07-15 17:48:47 -04: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
apainintheneck
85bd4c7e1f utils/backtrace: scrub sorbet-runtime from backtrace
Ever since we started using this at runtime it's been polluting
the backtrace output. This makes it harder to debug errors and
increases the amount of info users have to paste into the box
when filing an issue.

This is a very direct approach. Essentially, we strip out
everything related to the `sorbet-runtime` gem whenever the top
line in the backtrace is unrelated to sorbet-runtime.

The hope is that this will allow errors related to sorbet to
be diagnosed easily while also reducing the backtrace size
for all other types of errors.

Sometimes it is useful to see the full backtrace though.
For those cases, we include the full backtrace when
`--verbose` is passed in and print a warning that the
Sorbet lines have been removed from the backtrace the
first time they are removed.

Note: This requires gems to be set up so that the call to
`Gem.paths.home` works correctly. For that reason, it must
be included after `utils/gems` which is included in
`standalone/load_path` already.
2023-09-21 21:07:22 -07:00
Mike McQuaid
b7114651ac
utils/curl: include or use explicitly.
Include or use `Utils::Curl` explicitly everywhere it is used.
2023-09-04 22:17:57 -04:00
Eric Knibbe
c1fe80ac82
utils/repology: update API URL 2023-08-02 09:02:44 -04:00
Douglas Eichelberger
09c679e75f Refactor module_function to reduce rbi need 2023-04-17 10:37:59 -07:00
Douglas Eichelberger
02fd0422aa Enable typing in a few more files 2023-03-09 13:42:06 -08:00
Douglas Eichelberger
2c5067ec77 Port dynamic invocation 2023-02-27 20:18:10 -08:00
EricFromCanada
415f05ca31
bump: resume checking for TLS 1.3 support
macOS 12.3's shipping curl now supports TLS 1.3.
2022-04-11 22:59:33 -04:00
Mike McQuaid
af6d995de8
dev-cmd/bump: add switch to open pull requests.
This enables the simplification of
https://github.com/Homebrew/actions/blob/master/bump-formulae/main.rb
and exposing this workflow to more Homebrew users.
2022-01-12 17:31:55 +00:00
Mike McQuaid
b09f421027
repology: always use Homebrew curl.
This seems to be required even with TLSv1.3 support now.

Also, while we're here, improve the error handling/output.
2022-01-03 13:17:12 +00:00
EricFromCanada
c952ea7358
bump: fix tests 2021-10-25 15:55:11 -04:00
EricFromCanada
811d0fa0bd
bump: add option to retrieve a subset of results
Plus a few fixes for output.
2021-10-19 20:14:39 -04:00
Mike McQuaid
41e94afda5
Fix brew style
Fixes for https://github.com/Homebrew/brew/pull/12152.

Extracted into a separate PR so this can be merged immediately.
2021-09-30 10:13:53 +01:00
Mike McQuaid
1680ddb267
utils/repology: temporarily disable functionality.
Doesn't work with system `curl` currently.
2021-06-30 09:20:56 +01:00
nandahkrishna
bf60e2da3d
utils/repology: add constants for repository names 2021-02-17 02:12:18 +05:30
nandahkrishna
24bb6040a7
dev-cmd/bump: add cask support 2021-02-17 00:42:07 +05:30
nandahkrishna
138f7de18f
Refactor brew bump: apply suggestions from code review
Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
2021-01-24 19:10:47 +05:30
nandahkrishna
4fa01fc8b7
utils/repology: use project-by tool to retrieve Formula data 2021-01-24 19:10:47 +05:30
nandahkrishna
e2ddf9894a
Refactor brew bump 2021-01-24 19:10:46 +05:30
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
e5a9072422 Document Repology. 2020-08-26 09:11:39 +02:00
Maxim Belkin
bbc7f175a1 utils/repology.rb: convert last_package_index to string when calling query_api 2020-08-19 17:59:38 +00:00
Elizabeth Tackett
e64af7c046 make repology api queries more efficient 2020-08-19 10:12:38 -05:00
Elizabeth Tackett
9904c862a1 do not paginate repology API more than required by limit 2020-08-19 09:10:57 -05:00
Baffour Adu Boampong
5d9e1f2bc7 filter out packages only when a limit is set 2020-08-18 22:37:28 +00:00
Baffour Adu Boampong
0021ed45d0 brew style fixes 2020-08-18 22:25:17 +00:00
Baffour Adu Boampong
27ee9cf7b9 Merge branch 'mlh-outdated-packages' of github.com:MLH-Fellowship/brew into mlh-outdated-packages 2020-08-18 22:19:32 +00:00
Baffour Adu Boampong
afe9a48373 Add limit to repology api 2020-08-18 22:18:03 +00:00
Elizabeth Tackett
647b229d3c display verification msg if parsing large amount of data 2020-08-18 09:42:32 -05:00
Baffour Adu Boampong
7982e6f3c0 Update response display 2020-08-18 13:29:36 +00:00
Baffour Adu Boampong
e4e0b16803
Update Library/Homebrew/utils/repology.rb
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2020-08-18 09:53:52 +00:00
Elizabeth Tackett
dc1bbe7f81 handle requests for multiple formulae 2020-08-16 20:38:03 -05:00
Elizabeth Tackett
388b0ae8ba show formula livecheck and brew data when repology response is nil 2020-08-16 19:22:24 -05:00
Elizabeth Tackett
9cae9f284c update argument handling and syntactical feedback changes 2020-08-16 18:45:50 -05:00
Elizabeth Tackett
ed23eb1fab update repology for changes to GitHub module 2020-08-13 09:56:41 -05:00
Elizabeth Tackett
a3278ad345 add bump spec 2020-08-05 10:10:05 -05:00
Elizabeth Tackett
db27f446d0 WIP repology module tests 2020-08-03 11:27:35 -05:00
Elizabeth Tackett
ce721f43a8 display version data when formula is up-to-date 2020-07-31 10:52:37 -05:00
Baffour Adu Boampong
82787c8499 Brew style fix 2020-07-30 22:59:54 +00:00
Baffour Adu Boampong
5f19a53195 Refactor bump.rb methods into seperate modules 2020-07-30 22:58:30 +00:00
Baffour Adu Boampong
e2c9bb8a96
Reword number of packages found sentence
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2020-07-29 13:40:25 +00:00
Elizabeth Tackett
2822a7b0c3 adapt output to adjust for single-formula queries 2020-07-28 12:56:19 -05:00
Elizabeth Tackett
1d328eb7e5 add --formula flag to allow user specific queries 2020-07-28 09:30:19 -05:00
Baffour Adu Boampong
7633991621 Remove exception handling in formula version vheck 2020-07-07 13:43:31 +00:00
Elizabeth Tackett
af37b76689 syntactical updates 2020-07-06 09:08:41 -05:00