rubocops/cask: Enforce the order of on_#{arch} blocks
- These were previously being manually fixed which is time maintainers
could have spent fixing more important problems.
- I don't work with Casks much at all, so I was unsure as to what the
existing "arch" and "on_arch_conditional" parts were, if they're
deprecated or if things were eventually going to migrate to
`on_#{arch}` blocks?
This commit is contained in:
parent
d43ba7c306
commit
b6062acdbe
@ -6,7 +6,7 @@ module RuboCop
|
||||
# Constants available globally for use in all cask cops.
|
||||
module Constants
|
||||
STANZA_GROUPS = [
|
||||
[:arch, :on_arch_conditional],
|
||||
[:on_arm, :on_intel, :arch, :on_arch_conditional],
|
||||
[:version, :sha256],
|
||||
[:language],
|
||||
[:url, :appcast, :name, :desc, :homepage],
|
||||
|
||||
@ -474,4 +474,65 @@ describe RuboCop::Cop::Cask::StanzaOrder do
|
||||
|
||||
include_examples "does not report any offenses"
|
||||
end
|
||||
|
||||
context "when `on_arch` blocks are out of order" do
|
||||
let(:source) do
|
||||
<<~CASK
|
||||
cask 'foo' do
|
||||
on_intel do
|
||||
url "https://foo.brew.sh/foo-intel.zip"
|
||||
sha256 :no_check
|
||||
version :latest
|
||||
end
|
||||
|
||||
on_arm do
|
||||
url "https://foo.brew.sh/foo-arm.zip"
|
||||
sha256 :no_check
|
||||
version :latest
|
||||
end
|
||||
|
||||
name "Foo"
|
||||
end
|
||||
CASK
|
||||
end
|
||||
|
||||
let(:expected_offenses) do
|
||||
[{
|
||||
message: "`on_intel` stanza out of order",
|
||||
severity: :convention,
|
||||
line: 2,
|
||||
column: 2,
|
||||
source: "on_intel do\n url \"https://foo.brew.sh/foo-intel.zip\"\n sha256 :no_check\n version :latest\n end", # rubocop:disable Layout/LineLength
|
||||
}, {
|
||||
message: "`on_arm` stanza out of order",
|
||||
severity: :convention,
|
||||
line: 8,
|
||||
column: 2,
|
||||
source: "on_arm do\n url \"https://foo.brew.sh/foo-arm.zip\"\n sha256 :no_check\n version :latest\n end", # rubocop:disable Layout/LineLength
|
||||
}]
|
||||
end
|
||||
|
||||
let(:correct_source) do
|
||||
<<~CASK
|
||||
cask 'foo' do
|
||||
on_arm do
|
||||
url "https://foo.brew.sh/foo-arm.zip"
|
||||
sha256 :no_check
|
||||
version :latest
|
||||
end
|
||||
|
||||
on_intel do
|
||||
url "https://foo.brew.sh/foo-intel.zip"
|
||||
sha256 :no_check
|
||||
version :latest
|
||||
end
|
||||
|
||||
name "Foo"
|
||||
end
|
||||
CASK
|
||||
end
|
||||
|
||||
include_examples "reports offenses"
|
||||
include_examples "autocorrects source"
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user