cask/audits: on_#{os_version} stanza order is oldest => newest
- This, ie Mojave first, is more common in real Casks than the alternative of newest to oldest ie Ventura first. - Doing it this way reduces the number of offenses from ~500 to ~200.
This commit is contained in:
parent
d97ed0a7c2
commit
48b1279b00
@ -6,10 +6,15 @@ module RuboCop
|
|||||||
# Constants available globally for use in all cask cops.
|
# Constants available globally for use in all cask cops.
|
||||||
module Constants
|
module Constants
|
||||||
ON_SYSTEM_METHODS = [:arm, :intel, *MacOSVersions::SYMBOLS.keys].map { |option| :"on_#{option}" }.freeze
|
ON_SYSTEM_METHODS = [:arm, :intel, *MacOSVersions::SYMBOLS.keys].map { |option| :"on_#{option}" }.freeze
|
||||||
|
ON_SYSTEM_METHODS_STANZA_ORDER = [
|
||||||
|
:arm,
|
||||||
|
:intel,
|
||||||
|
*MacOSVersions::SYMBOLS.reverse_each.to_h.keys, # Oldest OS blocks first since that's more common in Casks.
|
||||||
|
].map { |option, _| :"on_#{option}" }.freeze
|
||||||
|
|
||||||
STANZA_GROUPS = [
|
STANZA_GROUPS = [
|
||||||
[:arch, :on_arch_conditional],
|
[:arch, :on_arch_conditional],
|
||||||
ON_SYSTEM_METHODS,
|
ON_SYSTEM_METHODS_STANZA_ORDER,
|
||||||
[:version, :sha256],
|
[:version, :sha256],
|
||||||
[:language],
|
[:language],
|
||||||
[:url, :appcast, :name, :desc, :homepage],
|
[:url, :appcast, :name, :desc, :homepage],
|
||||||
|
|||||||
@ -604,11 +604,11 @@ describe RuboCop::Cop::Cask::StanzaOrder do
|
|||||||
|
|
||||||
let(:expected_offenses) do
|
let(:expected_offenses) do
|
||||||
[{
|
[{
|
||||||
message: "`on_catalina` stanza out of order",
|
message: "`on_ventura` stanza out of order",
|
||||||
severity: :convention,
|
severity: :convention,
|
||||||
line: 6,
|
line: 2,
|
||||||
column: 2,
|
column: 2,
|
||||||
source: "on_catalina do\n url \"https://foo.brew.sh/foo-catalina.zip\"\n sha256 :no_check\n end",
|
source: "on_ventura do\n url \"https://foo.brew.sh/foo-ventura.zip\"\n sha256 :no_check\n end",
|
||||||
}, {
|
}, {
|
||||||
message: "`on_mojave` stanza out of order",
|
message: "`on_mojave` stanza out of order",
|
||||||
severity: :convention,
|
severity: :convention,
|
||||||
@ -627,20 +627,20 @@ describe RuboCop::Cop::Cask::StanzaOrder do
|
|||||||
let(:correct_source) do
|
let(:correct_source) do
|
||||||
<<~CASK
|
<<~CASK
|
||||||
cask "foo" do
|
cask "foo" do
|
||||||
on_ventura do
|
on_mojave do
|
||||||
url "https://foo.brew.sh/foo-ventura.zip"
|
url "https://foo.brew.sh/foo-mojave.zip"
|
||||||
sha256 :no_check
|
|
||||||
end
|
|
||||||
on_big_sur do
|
|
||||||
url "https://foo.brew.sh/foo-big-sur.zip"
|
|
||||||
sha256 :no_check
|
sha256 :no_check
|
||||||
end
|
end
|
||||||
on_catalina do
|
on_catalina do
|
||||||
url "https://foo.brew.sh/foo-catalina.zip"
|
url "https://foo.brew.sh/foo-catalina.zip"
|
||||||
sha256 :no_check
|
sha256 :no_check
|
||||||
end
|
end
|
||||||
on_mojave do
|
on_big_sur do
|
||||||
url "https://foo.brew.sh/foo-mojave.zip"
|
url "https://foo.brew.sh/foo-big-sur.zip"
|
||||||
|
sha256 :no_check
|
||||||
|
end
|
||||||
|
on_ventura do
|
||||||
|
url "https://foo.brew.sh/foo-ventura.zip"
|
||||||
sha256 :no_check
|
sha256 :no_check
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user