446 Commits

Author SHA1 Message Date
Eric Knibbe
4932fb7fd0
rubocops/urls: remove dead link 2024-05-06 22:57:23 -04:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Mike McQuaid
97ad3567d1
Optimise more command handling/speed
- in `brew.sh` split the `case` into those cases that take a single or
  no arguments and those that take multiple arguments or handle
  multiple commands. This considerably speeds up the
  `brew shellenv bash` case that wasn't being handled here before.
- add `setup-ruby` to the list of commands that can be called quickly
  by `brew.sh` without additional setup. This speeds up the
  `brew setup-ruby` no-op case by ~10x.
- add a parameter to `setup-ruby` to avoid running Bundler if the
  command doesn't need it. This makes many more cases for
  `brew setup-ruby` to be no-op cases.
- Remove the (now) unused `HOMEBREW_RUBY3` check in `setup-ruby`.
- Improve argument handling in `command_path.sh` to allow it to be
  used as a function in `setup-ruby.sh`.
- Add a new RuboCop to check usage of `install_bundler_gems!` is only
  inside `dev-cmd` (or a few other acceptable places).
- Use new `processed_source.file_path` API in `formula_cop.rb`
2024-04-30 12:48:29 +01:00
Douglas Eichelberger
03b815df82 Enable and fix RSpec/DescribedClassModuleWrapping 2024-03-30 11:29:34 -07:00
Sam Ford
b3ab410215
rubocops/livecheck: Rework LivecheckUrlProvided
The existing `LivecheckUrlProvided` RuboCop requires a `url` for all
`livecheck` blocks except those using `skip`, `formula`, or `cask`,
as those only appear in a `livecheck` block with no other DSL methods.

We now have a `throttle` method that can be used alongside other DSL
methods (e.g., `url`, `regex`, `strategy`) or by itself. `brew style`
currently fails when `throttle` is used by itself, so this reworks
the conditions to allow this usage.
2024-03-21 15:53:25 -04:00
apainintheneck
769b4f89c7 rubocops/service_spec: update test to cover custom name that requires root
This was added in recently and this just updates the test to reflect the
expected behavior for the cop.
2024-03-20 21:05:14 -07:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Mike McQuaid
b8243d0e9e
Merge pull request #16717 from jesboat/fix-chmod-message2
[brew audit] fix "Incorrect file permissions" message
2024-02-22 08:51:52 +00:00
Issy Long
a895496982
rubocop: The pyyaml resource requires depends_on "libyaml" 2024-02-20 23:22:15 +00:00
Jade Elizabeth Sailor
94aeabfc8a [brew audit] fix "Incorrect file permissions" message
When the file isn't world-readable, `brew audit` prints a failure
message including a suggestion to `chmod +r` the file. Unfortunately,
this isn't quite right: with both macOS and coreutils, leaving out the
"who" in a chmod only affects bits which would be set in the umask. So,
if the umask doesn't allow world-readable (which might be why the file
wasn't world-readable in the first place), the suggested chmod command
does nothing.

Change to print `chmod a+r` instead; that does have the intended effect.

No other `chmod` suggestions in this file have the same problem.
2024-02-20 16:26:21 -05:00
Mike McQuaid
14ba271533
Merge pull request #16705 from issyl0/lxml-resource-needs-uses-from-macos
rubocop: Formulae with the "lxml" resource have required dependencies
2024-02-20 12:54:19 +00:00
Issy Long
ff23de4766
Formatting and cope with more modern RSpec config changes
Co-authored-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2024-02-20 12:17:27 +00:00
Issy Long
33c33b5338
rubocop: Formulae with the "lxml" resource have required dependencies
- We're moving from `depends_on "python-lxml"` to `resource "lxml" ...` as part
  of the new Python vendoring plan.
- For `resource "lxml"` to work, `uses_from_macos "libxml2"` and
  `uses_from_macos "libxslt"` are needed in the formulae.
- This new RuboCop rule enforces that a formula including the "lxml" resource
  also include those dependencies.
2024-02-19 22:50:55 +00:00
Douglas Eichelberger
d7ebf97467
Turn on disable_monkey_patching 2024-02-19 13:57:28 +00:00
Douglas Eichelberger
26eda5a303
git grep -l '^describe' | xargs gsed -i 's|^describe|RSpec.describe|g' 2024-02-19 13:57:27 +00:00
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