SIGN IN SIGN UP
Homebrew / brew UNCLAIMED

🍺 The missing package manager for macOS (or Linux)

0 0 185 Ruby

rubocops/urls: collect all livecheck urls

`RuboCop::Cop::FormulaAudit::Urls` and `::HttpUrls` contain logic to
identify the main `livecheck` block URL, which is used to ensure
certain URL cops don't apply to a `livecheck` block URL. This was
created at a time when formulae only contained one `livecheck` block
but nowadays we also have `livecheck` blocks in resources. Since this
only collects the URL from the first `livecheck` block, the cops that
are skipped for the main `livecheck` block URL aren't skipped for
resource `livecheck` block URLs. This addresses the issue by
collecting all `livecheck` block URLs and modifying related conditions
accordingly.

In the process, this also adds a guard to ensure that we skip over
URL symbols (e.g., `:stable`, `:url`, `:homepage`, `:head`), as those
would otherwise appear in the array like `stable`, `url`, etc.
Skipping should be fine but if we run into issues in the future, we'll
have to figure out a way to map the symbols to their respective URLs,
which may be challenging when working with the AST (i.e., we can't use
`Livecheck.url_to_string` and would have to manually identify URLs
while accounting for permutations that are usually handled when a
formula is parsed, like conditional arch/OS logic).

It may be worth mentioning that URL audits don't handle string
interpolation (i.e., "https://example.com/#{something}" is audited
as written), so the logic to collect `livecheck` block URLs uses the
same approach to ensure URLs match.
S
Sam Ford committed
d2d27b3db4175123690a2191272ce2ef7c223a19
Parent: dd3e642