style: re-enable sha256 checks for bottle blocks
Follow up PR to #10450
This commit is contained in:
parent
26a3d4a544
commit
38ae6e0c0d
@ -32,11 +32,7 @@ module RuboCop
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
checksum_string = string_content(checksum)
|
if string_content(checksum).size != 64 && regex_match_group(checksum, /^\w*$/)
|
||||||
|
|
||||||
return if checksum_string == "cellar"
|
|
||||||
|
|
||||||
if checksum_string.size != 64 && regex_match_group(checksum, /^\w*$/)
|
|
||||||
problem "sha256 should be 64 characters"
|
problem "sha256 should be 64 characters"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -126,9 +126,19 @@ module RuboCop
|
|||||||
parameters(call).first
|
parameters(call).first
|
||||||
# sha256 is passed as a key-value pair in bottle blocks
|
# sha256 is passed as a key-value pair in bottle blocks
|
||||||
elsif parameters(call).first.hash_type?
|
elsif parameters(call).first.hash_type?
|
||||||
|
if parameters(call).first.keys.first.value == :cellar
|
||||||
|
# sha256 :cellar :any, :tag "hexdigest"
|
||||||
|
parameters(call).first.values.last
|
||||||
|
elsif parameters(call).first.keys.first.is_a?(RuboCop::AST::SymbolNode)
|
||||||
|
# sha256 :tag "hexdigest"
|
||||||
|
parameters(call).first.values.first
|
||||||
|
else
|
||||||
|
# Legacy bottle block syntax
|
||||||
|
# sha256 "hexdigest" => :tag
|
||||||
parameters(call).first.keys.first
|
parameters(call).first.keys.first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Yields to a block with comment text as parameter.
|
# Yields to a block with comment text as parameter.
|
||||||
def audit_comments
|
def audit_comments
|
||||||
|
@ -63,6 +63,32 @@ describe RuboCop::Cop::FormulaAudit::Checksum do
|
|||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "reports an offense if a checksum is not 64 characters in a bottle block without cellar" do
|
||||||
|
expect_offense(<<~RUBY)
|
||||||
|
class Foo < Formula
|
||||||
|
url 'https://brew.sh/foo-1.0.tgz'
|
||||||
|
|
||||||
|
bottle do
|
||||||
|
sha256 catalina: "5cf6e1ae0a645b426c0474cc7cd3f7d1605ffa1ac5756a39a8b2268ddc7ea0e9ad"
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ sha256 should be 64 characters
|
||||||
|
end
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
|
||||||
|
it "reports an offense if a checksum is not 64 characters in a bottle block" do
|
||||||
|
expect_offense(<<~RUBY)
|
||||||
|
class Foo < Formula
|
||||||
|
url 'https://brew.sh/foo-1.0.tgz'
|
||||||
|
|
||||||
|
bottle do
|
||||||
|
sha256 cellar: :any, catalina: "5cf6e1ae0a645b426c0474cc7cd3f7d1605ffa1ac5756a39a8b2268ddc7ea0e9ad"
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ sha256 should be 64 characters
|
||||||
|
end
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user