32 Commits

Author SHA1 Message Date
Mike McQuaid
7173f1fb60
utils/spdx: do case insensitive comparison.
Various places that use SPDX licenses specify them as downcased strings
so let's be more permissive in our comparisons/validations.
2025-05-20 12:12:55 +01:00
Issy Long
975a707b3c
Bump some utils/ files to Sorbet typed: strict 2025-01-22 22:01:34 +00:00
Douglas Eichelberger
521c463e36
Manually resolve Style/SafeNavigationChainLength violations 2024-11-05 16:44:12 +00:00
Michael Cho
82fbbcc88b
utils/spdx: fix invalid SPDX syntax for symbols
Also use more common uppercase operators for backwards compatibility
2024-08-26 13:55:37 -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
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
Issy Long
f4218a6316
Fix RuboCop Performance/MapCompact offenses
- Rename an iterator variable since it would make the line too long.
2024-02-25 22:59:59 +00:00
Bo Anderson
5692c8ecbf
Fix style violations under newer RuboCop 2023-12-14 05:47:12 +00: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
Douglas Eichelberger
08af78a2a5 brew style --fix 2023-04-25 09:26:24 -07:00
Douglas Eichelberger
7f3593e12d inline titleize 2023-02-27 20:18:10 -08:00
Bo Anderson
83b23e6d5e
Fix license handling for API formulae 2023-02-06 10:09:40 +00:00
Sam Ford
3f7d9f82fc
#curl_download: default try_partial to false
When its `try_partial` argument is `true`, `#curl_download` makes a
`HEAD` request before downloading the file using `#curl`. Currently
`try_partial` defaults to `true`, so any `#curl_download` call that
doesn't explicitly specify `try_partial: false` will make a `HEAD`
request first. This can potentially involve several requests if the
URL redirects, so it can be a bit of unnecessary overhead when a
partial download isn't needed.

Partial downloads are generally only useful when we're working with
larger files, however there's currently only one place in brew where
`#curl_download` is used and this is the case:
`CurlDownloadStrategy`. The other `#curl_download` calls are fetching
smaller [text] files and don't need to support partial downloads.

This commit changes the default `try_partial` value to `false`,
making partial downloads opt-in rather than opt-out.

We want `try_partial` to continue to default to `true` in
`CurlDownloadStrategy` and there are various ways to accomplish this.
In this commit, I've chosen to update its `#initialize` method to
accept a `try_partial` argument that defaults to `true`, as this
value can also be used in classes that inherit from
`CurlDownloadStrategy` (e.g., `HomebrewCurlDownloadStrategy`). This
instance variable is passed to `#curl_download` in related methods,
effectively maintaining the previous `try_partial: true` value, while
also allowing this value to be overridden when necessary.

Other uses of `#curl_download` in brew are
`Formulary::FromUrlLoader#load_file` and
`Cask::CaskLoader::FromURILoader#load`, which did not provide a
`try_partial` argument but should have been using
`try_partial: false`. With the `try_partial: false` default in this
commit, these calls are now fine without a `try_partial` argument.

The only other use of `#curl_download` in brew is
`SPDX#download_latest_license_data!`. These calls were previously
using `try_partial: false` but we can now omit this argument with
the new `false` default (aligning with the above).
2022-04-22 14:23:08 -04:00
cnnrmnn
b406e0b35a Update call sites 2021-05-14 09:53:29 -04:00
Kenneth Chew
edead95768
utils/spdx: correctly detect non-deprecated licenses with plus 2021-02-23 16:28:24 -05:00
Nanda H Krishna
7dc8025934
Merge pull request #10626 from nandahkrishna/refactor-github-api
utils/github: split GitHub module
2021-02-18 01:20:01 +05:30
nandahkrishna
f7c8810214
utils/github/api: remove 'api' from method names 2021-02-17 23:47:05 +05:30
Mike McQuaid
c13d7e6723
Fix brew style 2021-02-16 09:25:34 +00:00
nandahkrishna
56e0c3d9e8
Update GitHub API usage 2021-02-15 22:38:27 +05:30
Mike McQuaid
4c1b2630dc
Fix sorbet errors. 2020-12-28 13:34:07 +00:00
Rylan Polster
24523f8225 utils/spdx: allow other license symbols 2020-10-22 10:01:40 -04:00
Markus Reiter
12e173cd50 Inline type annotations for SPDX. 2020-10-10 15:33:15 +02:00
Markus Reiter
ff653571b1 Create Utils::Curl module and explicitly include it. 2020-10-10 15:23:03 +02:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
8b07c0ef12 Document SPDX. 2020-08-26 09:16:05 +02:00
Rylan Polster
6eb07d70f0 formula: convert license array to hash 2020-08-20 10:26:37 -04:00
Rylan Polster
1a321dab62 keep license array support 2020-08-19 12:48:50 -04:00
Rylan Polster
90d9454d1e utils/spdx: add support for complex expressions
Co-authored-by: Seeker <meaningseeking@protonmail.com>
2020-08-19 12:47:58 -04:00
Seeker
f345f554c8 update-license-data: fix latest_tag error
Add latest_tag method to utils/spdx
2020-08-10 11:32:07 -07:00
Seeker
6ecef73131 test: add spdx spec 2020-08-06 11:14:24 -07:00
Seeker
753b8621df utils: add SPDX module 2020-08-06 10:16:23 -07:00