737 Commits

Author SHA1 Message Date
Mahrud Sayrafi
eebffa8be3
audit(github): also permit refs/heads in GitHub URLs 2023-10-28 00:53:49 -05:00
Rui Chen
b954e20d12
audit(github): also need to consider commit artifact
Signed-off-by: Rui Chen <rui@chenrui.dev>
2023-10-23 14:58:03 -04:00
Rui Chen
a496f6708e
audit(github): prefer /archive/refs/tags urls over /archive
Signed-off-by: Rui Chen <rui@chenrui.dev>
2023-10-23 11:00:27 -04:00
Issy Long
5ddebe1640
rubocops/text: Declare "revision 0" in formulae as unnecessary
- This came up in a user contribution recently so here's a RuboCop for it.
2023-10-04 23:28:30 +01:00
Dawid Dziurla
b4366b61ef
audit: check for cargo build only in install method 2023-08-18 11:20:56 +02:00
Mike McQuaid
d30fee25e4
formula_cop: fix style_exceptions_dir handling.
This needed to be adjusted to handle a sharded homebrew/core and
repositories with formulae in the root.
2023-08-09 15:20:57 +01:00
Mike McQuaid
68aa5da833
Merge pull request #15614 from carlocab/quictls-cop
rubocops/lines: disallow `quictls` dependencies in homebrew/core
2023-07-18 10:44:09 +01:00
Francois-Xavier Coudert
639f59473d Do not insist on using macOS texinfo 2023-07-18 08:57:11 +02:00
Carlo Cabrera
95c06f5ad5
rubocops/lines: simplify PyoxidizerCheck 2023-07-14 12:57:23 +08:00
Carlo Cabrera
470c1e6683
Implement rustup audit as a style check
This allows results to be cached and auto-corrected.
2023-07-12 10:49:47 +08:00
Carlo Cabrera
83f2a69acb
rubocops/lines: disallow quictls dependencies in homebrew/core
QuicTLS is a fork of OpenSSL that adds support for QUIC. We'll probably
end up adding it to homebrew/core at some point (see
Homebrew/homebrew-core#134975), but I don't think we want to actually
use it as a dependency of any formulae in place of OpenSSL.

We ought to only allow it for software that actually require QuicTLS in
place of OpenSSL, but I'm not aware of any existing formulae that have
this requirement.
2023-07-01 23:07:28 +08:00
Razvan Azamfirei
c355723fe5
fix desc auto-correct order 2023-06-20 11:36:47 -04:00
Razvan Azamfirei
a3ee3650cb
Update Library/Homebrew/rubocops/shared/desc_helper.rb
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2023-06-20 11:24:35 -04:00
Razvan Azamfirei
c1009247bf
Apply suggestions from code review
Co-authored-by: FX Coudert <fxcoudert@gmail.com>
2023-06-20 08:59:01 -04:00
Razvan Azamfirei
adf6278e3c
rubocops: add emoji audit 2023-06-20 08:10:38 -04:00
apainintheneck
f2adbf6613 service: change custom name DSL
After some discussion, we decided to change the DSL to get rid of
the `plist_name` and `service_name` methods which aren't meaningful
for most users.

The new DSL looks like this:

```rb
service do
  name macos: "name", linux: "name"
end
```

I also updated some specs here to reflect these changes.

There was some talk about maybe deprecating `plist_name` and `service_name`
but I think that's outside of the scope of this PR so I'm leaving
them as is for now. One benefit of this is that everything here is backwards
compatible.
2023-05-17 21:54:32 -07:00
apainintheneck
1bae81cba2 rubocops/service: add checks for custom service names
It now checks for two new edge cases.
1. Are the required methods defined in the block?
2. Is the `run` command defined if we're using methods other
   than `service_name` or `plist_name`?

It has also been updated to only get the list of method call nodes
once instead of doing it repeatedly for each cellar path check.
2023-05-13 14:53:01 -07:00
Mike McQuaid
04866b6e39
Merge pull request #15392 from reitermarkus/remove-rubocop
Remove `NoDslVersion` cop.
2023-05-10 13:13:35 +01:00
Markus Reiter
46b9dba03c
Remove NoDslVersion cop. 2023-05-10 01:02:42 +02:00
Markus Reiter
f7168bf234
Merge pull request #15336 from reitermarkus/version-head-null
Merge `HeadVersion` and `NullVersion` into `Version`.
2023-05-10 01:01:21 +02:00
Markus Reiter
8274920217
Rename OS::Mac::Version to MacOSVersion. 2023-05-09 05:08:38 +02:00
Markus Reiter
02dbeb62fc
Refactor RuboCop tests. 2023-05-09 04:28:25 +02:00
Markus Reiter
1df501b0ac
Tweak tests. 2023-05-07 10:04:28 +02:00
Markus Reiter
ce8788e5bc
Fix code style. 2023-05-07 08:34:13 +02:00
Markus Reiter
81fdb3716e
Implement StanzaOrder cop using on_cask_stanza_block. 2023-05-07 08:30:29 +02:00
Markus Reiter
2dea4f2370
Add on_cask_stanza_block. 2023-05-07 08:30:08 +02:00
Issy Long
8035d46dfe
very wip but reimagined
- Thanks to Markus on Slack for saying "the cop should only apply to the
  content of the blocks, or more specifically only to stanzas that are
  direct children of cask or on_* blocks", which made me realize that
  I was overcomplicating things.
2023-05-07 08:30:08 +02:00
Issy Long
a493787125
Regressed a bit, but at least it's not clobbering anymore? 2023-05-07 08:29:31 +02:00
Issy Long
704482d815
wip a test for ordering of both on_* blocks and their contents
- This is very broken, "detected clobbering" errors.
2023-05-07 08:29:31 +02:00
Issy Long
40bc235cb6
Simplify offending_stanzas method - pass sorted_stanzas in directly
- Otherwise we're doing the same "if inner" check twice, for no gain.
2023-05-07 08:29:30 +02:00
Issy Long
9457a23430
Extract methods for checking for on_* blocks and their contents
- The same code to do the same thing was getting a bit repetitive in
  `Cask/StanzaOrder`, `Cask/StanzaGrouping` and `Cask/NoOverrides`
  cops.
2023-05-07 08:29:30 +02:00
Issy Long
bd6e9e72a1
rubocops/cask: Check for correct stanza ordering within on_* blocks
- Now that we detect correct stanza _grouping_ within `on_*` blocks in
  Casks (PR 15211), correct stanza _ordering_ in `on_*` blocks was the
  next logical step. For example, `url` has to come after `version` and
  `sha256` in an `on_macos` or `on_intel` block for consistency with the
  top-level stanza order we enforce elsewhere.
- Still not doing the nested `on_os` inside `on_arch`, that felt
  excessive for an edge case that isn't present in any actual real
  Casks we have. I removed the test with that specific TODO.
2023-05-07 08:27:43 +02:00
Ruoyu Zhong
254941c6f7
rubocops/service: check for more cellar paths
This is a follow-up to #15154. In addition to `bin`, the `service` block
can also reference other cellar paths like `libexec`. They don't work
with the API either, as reported in
https://github.com/orgs/Homebrew/discussions/4459.

Violations are already corrected in Homebrew/homebrew-core#129736
and Homebrew/homebrew-core#129737.

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2023-04-30 07:39:25 +08:00
Douglas Eichelberger
08af78a2a5 brew style --fix 2023-04-25 09:26:24 -07:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Issy Long
6de61e4994
Ensure that stanza grouping works for nested stanzas with comments
- Since moving `comments_hash` to `Stanza`, we've been using the wrong
  kind of "comments": the comments for the _stanza_, not the comments
  for the entire Cask.
- Add a test to ensure this actually works. There was previously an
  infinite loop here due to the bad `comments`, visible in a `StanzaOrder`
  cop test, which I speculatively added a failing test for. Turns out
  that supporting nested stanza _ordering_ (vs. just grouping) is a
  whole separate piece of work (there are multiple TODOs there already),
  so I've backed that out and will do that separately.
2023-04-13 15:59:18 +01:00
Markus Reiter
8b9ee05118
Cache Stanza#comments. 2023-04-12 23:08:49 +02:00
Issy Long
6e6493bd1b
Fix Stanza#source_range_with_comments
- All hail Sorbet for telling me that I forgot to rename this variable!
2023-04-12 20:52:38 +01:00
Issy Long
10bdb9f653
Don't pass cask_node into Stanza, stanza_node.parent is enough 2023-04-12 20:46:23 +01:00
Issy Long
519c1b46d8
In-line converting nodes to stanzas; move comment detection to Stanza
- Since comment detection is only used in `Stanza`, move it there.
- The `stanzaify` method was only in `CaskBlock` since the other use of
  `Stanza.new` was. Since it's only used in one other place, move it to
  where it's used.
2023-04-12 20:46:22 +01:00
Issy Long
233db299cd
rubocop/cask: Check for correct stanza grouping within on_* blocks
- A variant of this was an ancient TODO from 2018 (with `if/else` blocks).
- Now in 2023 we have `on_*` blocks within Casks that are very common.
- The most common stanzas present inside `on_*` blocks are `version`,
  `sha256` and `url`. So I feel like it's worth keeping a consistent
  style for these inside and outside `on_*` blocks.
2023-04-12 20:46:20 +01:00
Issy Long
0c2e6e59c5
rubocop: Remove redundant Style/InverseMethods disables 2023-04-07 21:35:38 +01:00
Mike McQuaid
3404767cd0
Merge pull request #15154 from apainintheneck/cop-to-prevent-bin-in-service-blocks 2023-04-05 11:35:33 +01:00
apainintheneck
70451ea7b1 Add cop to stop bin in service block
The preferred method is opt_bin because that works
with the API and is more portable (works between versions).

Also removed the last example from the docs of `bin/"name"`
from the service block section
2023-04-04 20:00:30 -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