19 Commits

Author SHA1 Message Date
Eric Knibbe
c75122c694
rubocops/cask/url: put keyword parameters on a new line 2025-06-05 10:53:34 -04: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
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
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
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
Sean Molenaar
48134ab674 feat: use shared checks for URL cop 2024-06-25 16:13:17 +02:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Douglas Eichelberger
08af78a2a5 brew style --fix 2023-04-25 09:26:24 -07:00
Issy Long
7bb20a3b83
Skip if the URL stanza has only two path components
https://github.com/Homebrew/homebrew-cask-fonts/pull/7336#discussion_r1156325651
2023-04-04 16:11:44 +01:00
Issy Long
28f8cbe8da
Handle when the URL has interpolation: use source not str_content
- We see this a lot in real Casks.
2023-04-02 23:39:43 +01:00
Issy Long
41c35986f8
Simplify the 'should not start with https?://' message wording
Co-authored-by: Markus Reiter <me@reitermark.us>
2023-04-02 22:43:57 +01:00
Issy Long
21da074346
Only 'verified' stanzas with 0 or >1 path components should end with "/"
Handle good things like:

```ruby
url "https://example.org/download",
    verified: "example.org/download" # This is fine.
```

And bad things like:

```ruby
url "https://example.org/",
    verified: "example.org" # This should end with a slash.
```
2023-04-02 22:26:23 +01:00
Issy Long
17c0eaab25
Fix indentation of verified in url stanza examples 2023-04-02 16:41:29 +01:00
Issy Long
b586d97f84
rubocops/cask: Ensure that "verified" URLs with paths end with "/"
- These were being fixed manually[1], so let's make a RuboCop for any
  further occurrences since this is a good rule to enforce[2].

[1] - https://github.com/Homebrew/homebrew-cask/pull/144179#issuecomment-1489857249
[2] - https://github.com/Homebrew/homebrew-cask/pull/80965#issuecomment-616232313
2023-04-02 15:29:53 +01: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
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