431 Commits

Author SHA1 Message Date
Bevan Kay
2b60576165
rubocops/cask: add a cop for specific numbered shared file list files 2024-02-04 14:13:06 +01:00
Douglas Eichelberger
3a27cac7df
Merge pull request #16510 from dduugg/inverse-include-exclude-cop
Vendor remaining Rails cops, remove ActiveSupport
2024-01-30 11:59:10 -08:00
Razvan Azamfirei
7c540dd3c5
rubocop: add uninstall methods order tests
Co-authored-by: Bevan Kay <email@bevankay.me>
2024-01-28 07:08:47 -05:00
Razvan Azamfirei
db72295c20
rubocop: order uninstall methods 2024-01-28 07:08:47 -05:00
Douglas Eichelberger
ae249ec282 Vendor InverseMethods cop 2024-01-26 15:03:59 -08:00
Douglas Eichelberger
0caaa1fa36 Vendor SafeNavigationWithBlank cop 2024-01-26 15:03:59 -08:00
Douglas Eichelberger
665bda0fbd Vendor Presence cop 2024-01-26 15:03:59 -08:00
Douglas Eichelberger
f99d39faf9 Vendor CompactBlank cop 2024-01-26 15:03:59 -08:00
Douglas Eichelberger
9d081a67cc Replace Rails/NegateInclude with Inverse/Invertible cops 2024-01-26 12:27:50 -08:00
Issy Long
a6b8a795b4
Merge pull request #16365 from issyl0/rubocop-cask-zap-arrays-alphabetical
Add a new RuboCop for alphabetizing `zap trash` array elements
2024-01-24 21:34:18 +00:00
Issy Long
693a27d48b
Treat zap and uninstall the same
- Since `zap` can have more than just `trash`.
2024-01-21 19:48:30 +00:00
Issy Long
458844af44
Move multi-line comments with the code they're 'attached' to
Co-authored-by: Bevan J. Kay <email@bevankay.me>
2024-01-21 12:42:22 +00:00
Bevan J. Kay
779f1bba7d
Move comments in tandem with the lines they belong to 2024-01-20 00:03:34 +00:00
Issy Long
e4b4af4c45
Add a failing test for comments moving with the alphabetization 2024-01-14 21:32:50 +00:00
Michael Cho
b4657e1eef
rubocops/components_redundancy: stable/head block removal
When a `stable do` or `head do` block only contains `url`, `sha256`,
`mirror`, and/or `version`, then the block should be removed.
2024-01-12 19:07:10 -05:00
Issy Long
9070f6d829
Check uninstall too, avoiding arrays containing commands 2024-01-02 23:31:13 +00:00
Michael Cho
2f3f017a6e
rubocops/uses_from_macos: audit when depends_on :linux 2023-12-30 18:30:05 -05:00
Issy Long
fb124f92ed
Ignore non-zap trash methods 2023-12-22 00:41:56 +00:00
Issy Long
b9f13fc35d
Better detection and replacement of non-alphabetized arrays
- Use `sort_by` to sort the array, rather than comparing each element
  to the next.
- This doesn't error with complaints about clobbering at all when run on
  `homebrew/cask`, hurray. And it also handles interpolations correctly,
  rather than ignoring them.

Co-authored-by: Bevan Kay <email@bevankay.me>
2023-12-22 00:26:38 +00:00
Issy Long
f34accfcde
Make the test expect_offense calls consistent with other tests 2023-12-22 00:20:02 +00:00
Issy Long
f4754baa00
Ignore zap trash stanzas with interpolation
- Interpolating the version into a path is a common pattern, but the interpolations
  trip up the alphabetization autocorrect quite spectacularly, so let's
  ignore them (for now?).
2023-12-22 00:19:03 +00:00
Mike McQuaid
4d93a50ad6
Merge pull request #16364 from cho-m/pybuild-rubocopy
rubocops/lines: consistency with single non-runtime Python
2023-12-20 11:57:17 +00:00
Issy Long
8cf58e36e6
Add a new RuboCop for alphabetizing zap trash array elements
- Part of issue 16323.
- Previously this was being done manually by Cask maintainers.
- While we're here, enforce that the `zap trash` path is not in `[]` if
  it only contains a single element.
- This is buggy on actual Casks, hence the draft PR.
2023-12-19 23:42:08 +00:00
Michael Cho
61b512c72c
rubocops/lines: consistency with single non-runtime Python 2023-12-19 15:20:45 -05:00
Rylan Polster
8d8cd23414
Add rubocop to enforce deprecate! over discontinued 2023-12-17 16:49:53 -05:00
Bo Anderson
b42256d286
Deprecate, disable & delete code for Homebrew 4.2.0 2023-12-07 23:42:13 +00:00
Rylan Polster
f98b8f948c
Add rubocop to remove MacOS references 2023-11-22 21:19:01 -05: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
Patrick Linnane
c56669e9cd
various: fix miscellaneous typos 2023-07-18 08:52:49 -07:00
Carlo Cabrera
451bea2713
tests: add QuicTLSCheck test 2023-07-14 13:13:51 +08:00
Razvan Azamfirei
b1baca7720
rephrase failure message 2023-06-20 11:33:49 -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
Markus Reiter
46b9dba03c
Remove NoDslVersion cop. 2023-05-10 01:02:42 +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
81fdb3716e
Implement StanzaOrder cop using on_cask_stanza_block. 2023-05-07 08:30:29 +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
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
9075cbae62 brew style --fix 2023-04-21 09:58:50 -07:00
Douglas Eichelberger
ac1e6ded9a git grep -l '# typed: false' | xargs gsed -i 's|# typed: false||g' 2023-04-21 09:57:47 -07:00
Issy Long
e51ad41434
Delete a Cask RuboCop test for an edge case that is not fixed
- This test tests nothing. And the TODO comment is wrong.
- We _could_ fix it, but it's a very edgy edge case which pertains to
  `livecheck` blocks which currently don't have stanza grouping or
  ordering cop support. If we decide in the future to add these, we can
  add this back too (provided I remember).
- Also I think I may have got confused with the stanza grouping vs.
  stanza ordering cops when writing this, rendering this test more
  useless.
2023-04-15 23:09:42 +01: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
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
da734a30c2
Say yes to RuboCop's DisplayCopNames; fix test expectations
- Fixing the test expected output was unbelievably tedious.
- There's been debate about this setting being `false` but in
  https://github.com/Homebrew/brew/pull/15136#issuecomment-1500063225
  we decided that it was worth using the default since RuboCop behaviour changed
  so we'd have had to do some horrible things to keep it as `false` -
  https://github.com/Homebrew/brew/pull/15136#issuecomment-1500037278 -
  and multiple maintainers specify the `--display-cop-names` option to
  `brew style` themselves since it's clearer what's gone wrong.
2023-04-07 19:14:07 +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