173 Commits

Author SHA1 Message Date
Issy Long
b82c5f1d36
Fix detection of string interpolation
- This was almost there but not quite and the lack of tests lulled me into a false sense of security.
2023-03-22 19:13:47 +00:00
Issy Long
8091e603df
rubocops/cask: Ignore livecheck blocks within on_* blocks
- The Cask `sip`, to give a random example, was failing this RuboCop
  because it has a `livecheck` block within an `on_*` block and the
  livecheck block and the top-level Cask both have `url` stanzas. This
  is a legitimate use of `livecheck` blocks because the cask software
  download URL and the livecheck version check URL are not the same
  thing, so let's skip over `livecheck` blocks and their contents.
2023-03-21 23:49:54 +00:00
Issy Long
794cd37dbb
Remove unnecessary skip since toplevel_stanzas doesn't look in blocks
Co-authored-by: Markus Reiter <me@reitermark.us>
2023-03-21 22:51:28 +00:00
Issy Long
7a4a579847
rubocops/cask: Run on_system_stanzas(on_block) once in the beginning
Co-authored-by: Markus Reiter <me@reitermark.us>
2023-03-21 22:51:27 +00:00
Issy Long
c337dc4c81
rubocops/cask: Skip string interpolations when determining inner stanzas
- Otherwise syntax like this, where `#{arch}` is an interpolation,
  causes an offense:

```ruby
cask "transcribe" do
  arch arm: "_arm"

  on_catalina :or_older do
    version "8.75.2"
    sha256 "f01781100cd3b9987c8f8892145a2eaa358df07b92e10e26f30b6a877f5b352c"

    url "https://www.seventhstring.com/xscribe/downmo/transcribe#{version.no_dots}.dmg"

    livecheck_version = "10"
  end
  on_big_sur :or_newer do
    livecheck_version = "11"

    version "9.21"
    sha256 :no_check

    url "https://www.seventhstring.com/xscribe/transcribe#{arch}.dmg"
  end
  [...]
end
```

```
Casks/transcribe.rb:2:3: C: Cask/NoOverrides: Do not use a top-level arch stanza as the default. Add it to an on_{system} block instead.
Use :or_older or :or_newer to specify a range of macOS versions.

  arch arm: "_arm"
  ^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected
```
2023-03-21 22:51:26 +00:00
Markus Reiter
e04101007f
Fix check for Set. 2023-03-21 22:51:25 +00:00
Issy Long
deb8a13a73
rubocops/cask: Make names, the list of method names in on_*, a Set
Co-authored-by: Markus Reiter <me@reitermark.us>
2023-03-21 22:51:24 +00:00
Issy Long
0b7bd81959
rubocops/cask: No need for the first return if, [].each works OK 2023-03-21 22:51:24 +00:00
Issy Long
35cd764261
rubocops/cask: Tweak offense message to read better 2023-03-21 22:51:20 +00:00
Issy Long
2c5165850a
rubocops/cask: Check ON_SYSTEM_METHODS instead of STANZA_ORDER
- This is already here and used in multiple places. Continuing to use
  `STANZA_ORDER` will break this cop when we add `ON_SYSTEM_METHODS`
  to that list.
2023-03-21 22:51:19 +00:00
Issy Long
ff2fad6bcf
rubocops/cask: Don't force on_* blocks for all stanzas
- In the event that there's only one common stanza within the `on_*`
  blocks (eg, `url`) with a generic `version` that doesn't change per-OS,
  let's not force adding `version` to each `on_*` block as well.
2023-03-21 22:51:18 +00:00
Issy Long
dec1309140
rubocops/cask: Casks with zero on_* blocks are still valid 2023-03-21 22:51:17 +00:00
Issy Long
5ce4966f4a
rubocops/cask: Use ON_SYSTEM_METHODS for skipping
Co-authored-by: Rylan Polster <rslpolster@gmail.com>
2023-03-21 22:51:16 +00:00
Issy Long
9cc046bc60
rubocops/cask: Enforce the use of on_{system} blocks
- As discussed in
  https://github.com/Homebrew/brew/pull/14976#issuecomment-1474544569
  and further comments, this is needed because in order to enforce the
  order of `on_{arch,system}` blocks we need to have everything
  consistently within one of those blocks.
- We previously allowed overrides where the top-level `version` stanza
  would be the default, unless on an OS that had an `on_system` block
  with a `version` specified. But this breaks down when we try to order
  the `on_system` blocks because if a `url` at the top-level has a
  `version` interpolated in it, then the `version` stanza needs to be
  above the `url` stanza. But it could be that `version` is OS-specific.
- Let's stop allowing overrides and require that everything be in an
  `on_system` block. This will make it easier to enforce the order of
  `on_system` blocks in a future PR (14976).
2023-03-21 22:51:12 +00:00
Markus Reiter
3c89f99df1
Fix toplevel_stanzas. 2023-03-21 14:43:59 +01:00
Issy Long
2aeeaf706e
Merge pull request #14891 from issyl0/cask-rubocops-unnecessary-requires 2023-03-06 12:23:49 +00:00
Issy Long
1d65c942c3
rubocops/cask: Clean up unnecessary requires
- I suspect these were copy-pasted from other cops, like I did in
  https://github.com/Homebrew/brew/pull/14886#discussion_r1125569999.
- The "forwardable" require is unnecesary if the cop doesn't
  `extend Forwardable` and use `def_delegator`.
- The "uri" require is unnecessary if the cop doesn't call `URI` methods.
2023-03-05 17:13:46 +00:00
Issy Long
4e067565dd
rubocops/cask/url: Fix test expectations; regexp for starts_with? 2023-03-05 16:55:47 +00:00
Issy Long
4791224acf
rubocops/cask/url: Remove unnecessary require "forwardable" 2023-03-05 16:38:10 +00:00
Issy Long
f4a0bc7af3
rubocops/cask: Appease Sorbet with the correct inheritance
- The `on_url_stanza` method is now used in two cops, `Url` and
  `UrlLegacyCommaSeparators`. Make the latter inherit from the former
  to make Sorbet happy.
- The style and typecheck checks now pass fine.
2023-03-05 16:33:11 +00:00
Issy Long
79db987215
rubocops/cask: Disallow protocol in cask URL verified stanza
- Apparently the "verified" parameter in the URL (present when a Cask's
  download URL is not the same as its homepage) shouldn't have the
  protocol (`https`, `http`) at the front.
- Removing this has happened manually in the past, so here's an
  autocorrecting RuboCop for it.
2023-03-04 23:00:04 +00:00
Douglas Eichelberger
6c93f6fe91 Enable typing in rubocops 2023-02-16 15:51:20 -08:00
Douglas Eichelberger
220becda96 remove undent 🐵-patch 2023-01-27 22:55:38 -08:00
Rylan Polster
d316819f0c
Add tests 2022-12-28 16:10:26 -05:00
Rylan Polster
3556e756fc
Check casks for macOS version conditionals 2022-12-28 16:10:26 -05:00
Issy Long
b7d997e80d
sorbet: Bump some files from typed: false to typed: true
- This was done with `brew typecheck --update --suggest-typed` which
  (as of the previous commit) uses Spoom, yet another gem. I thought I'd
  see how well it works. There are no Sorbet errors after these changes!
2022-10-11 01:09:03 +01:00
Rylan Polster
1c54e915b6
Update cask rubocops to use on_arch blocks and sha256 arm:, intel: 2022-08-25 00:49:28 -04:00
Rylan Polster
3f00893201
Include on_{system} blocks as stanzas in rubocop 2022-08-23 14:09:29 -04:00
Rylan Polster
af99dfba00
Refactor on_system rubocops for use in casks 2022-08-14 17:31:07 -04:00
Rylan Polster
ec132ff851
Add and adjust cask rubocops to handle variables 2022-08-10 17:45:43 -04:00
Rylan Polster
39071d5816
Remove arch from cask stanza ordering temporarily 2022-08-10 15:37:28 -04:00
Rylan Polster
dd72f1ac95
Add arch cask DSL 2022-08-05 17:12:55 -04:00
danielbayley
7d145f5798 Fix Rubocop trailing / bug 2022-04-27 18:42:11 +01:00
Bevan Kay
8c82ec964f
Update Library/Homebrew/rubocops/cask/url_legacy_comma_separators.rb
Co-authored-by: Issy Long <issyl0@github.com>
2022-01-12 10:40:22 +11:00
Bevan Kay
d371547d5a
fix tests 2022-01-12 10:39:38 +11:00
Bevan Kay
7e24930e4e
Update Library/Homebrew/rubocops/cask/url_legacy_comma_separators.rb
Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2022-01-11 01:22:22 +11:00
Bevan Kay
22d68fb99b
fix style offences 2022-01-10 21:34:51 +11:00
Bevan Kay
cc2b99c8cf
Add check for url :block 2022-01-10 21:27:20 +11:00
Bevan Kay
d5448ff54a
rubocops (cask/url): add rubocop to use csv instead of before_comma and after_comma in cask 2021-12-31 11:08:47 +11:00
Michael Cho
b44ecaceb7
docs: fix cask doc urls to use docs.brew.sh 2021-06-25 13:20:40 -07:00
Bo Anderson
450bc4ab33
Fix brew style 2021-03-26 14:11:03 +00:00
Jonathan Chang
ac8eb00443 rubocops/cask/*: use rubocop v1 API 2021-01-12 19:16:38 +11:00
Jonathan Chang
23b8d0ccb8 rubocops/desc: use rubocop v1 API 2021-01-12 19:16:38 +11:00
Sam Ford
ad544e465d
Add livecheck group to cask stanza order 2020-12-12 17:43:25 -05:00
linzichao
058a1c3645 add verified parameter in url 2020-12-01 01:17:21 +01:00
Markus Reiter
5be4c9b5e0 Upgrade typed sigils. 2020-11-25 17:04:19 +01:00
Markus Reiter
da9289eff0 Add more type signatures. 2020-11-13 12:26:36 +01:00
Jonathan Chang
215a84e328 rubocop: fix Style/DocumentDynamicEvalDefinition 2020-11-10 23:28:31 +11:00
Jonathan Chang
500908ee6f rubocop: fix Lint/NoReturnInBeginEndBlocks 2020-11-10 23:28:31 +11:00
EricFromCanada
3768b7a6e9 apidoc: update comment wording, punctuation, formatting 2020-11-06 00:21:02 -05:00