Allow livecheck method in on_system blocks

It's sometimes necessary to have a `livecheck` block in an `on_macos`
or `on_linux` block. For example, a formula may be disabled on macOS
but not on Linux. In that scenario, we only want a `livecheck` block
to apply to Linux, so livecheck will automatically skip the formula
as disabled on macOS.

While this setup works on a technical level, `brew style` will give
an `on_linux cannot include livecheck` offense. This commit addresses
the issue by adding `livecheck` to `on_system_allowed_methods` in the
`ComponentsOrder` Rubocop.

This also updates `on_system_allowed_methods` to use the order in
`FORMULA_COMPONENT_PRECEDENCE_LIST`, which may make it a bit easier
for formula maintainers to read at a glance.
This commit is contained in:
Sam Ford 2022-10-17 13:22:34 -04:00
parent 4737289259
commit 40199404cf
No known key found for this signature in database
GPG Key ID: 7AF5CBEE1DD6F76D

View File

@ -120,14 +120,15 @@ module RuboCop
end end
end end
on_system_allowed_methods = %w[ on_system_allowed_methods = %w[
depends_on livecheck
patch keg_only
resource
deprecate!
disable! disable!
deprecate!
depends_on
conflicts_with conflicts_with
fails_with fails_with
keg_only resource
patch
ignore_missing_libraries ignore_missing_libraries
] ]
on_system_allowed_methods += on_system_methods.map(&:to_s) on_system_allowed_methods += on_system_methods.map(&:to_s)