Skip to content

Commit

Permalink
Merge pull request #2757 from Homebrew/revert-2755-audit_checksum_rub…
Browse files Browse the repository at this point in the history
…ocop

Revert "audit: Port audit_checksum method to rubocop and add tests"
  • Loading branch information
MikeMcQuaid authored Jun 9, 2017
2 parents e83e394 + 113a7a8 commit 1ef00aa
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 145 deletions.
3 changes: 0 additions & 3 deletions Library/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ FormulaAudit/Text:
FormulaAudit/Caveats:
Enabled: true

FormulaAudit/Checksum:
Enabled: true

FormulaAuditStrict/BottleBlock:
Enabled: true

Expand Down
23 changes: 23 additions & 0 deletions Library/Homebrew/dev-cmd/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,7 @@ def initialize(resource, options = {})

def audit
audit_version
audit_checksum
audit_download_strategy
audit_urls
self
Expand All @@ -1272,6 +1273,28 @@ def audit_version
problem "version #{version} should not end with an underline and a number"
end

def audit_checksum
return unless checksum

case checksum.hash_type
when :md5
problem "MD5 checksums are deprecated, please use SHA256"
return
when :sha1
problem "SHA1 checksums are deprecated, please use SHA256"
return
when :sha256 then len = 64
end

if checksum.empty?
problem "#{checksum.hash_type} is empty"
else
problem "#{checksum.hash_type} should be #{len} characters" unless checksum.hexdigest.length == len
problem "#{checksum.hash_type} contains invalid characters" unless checksum.hexdigest =~ /^[a-fA-F0-9]+$/
problem "#{checksum.hash_type} should be lowercase" unless checksum.hexdigest == checksum.hexdigest.downcase
end
end

def audit_download_strategy
if url =~ %r{^(cvs|bzr|hg|fossil)://} || url =~ %r{^(svn)\+http://}
problem "Use of the #{$&} scheme is deprecated, pass `:using => :#{$1}` instead"
Expand Down
1 change: 0 additions & 1 deletion Library/Homebrew/rubocops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
require_relative "./rubocops/homepage_cop"
require_relative "./rubocops/text_cop"
require_relative "./rubocops/caveats_cop"
require_relative "./rubocops/checksum_cop"
55 changes: 0 additions & 55 deletions Library/Homebrew/rubocops/checksum_cop.rb

This file was deleted.

11 changes: 3 additions & 8 deletions Library/Homebrew/rubocops/extend/formula_cop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,12 @@ def find_block(node, block_name)
nil
end

# Returns an array of block nodes of depth first order named block_name below node
# Returns an array of block nodes named block_name inside node
def find_blocks(node, block_name)
return if node.nil?
node.each_child_node(:block).select { |block_node| block_name == block_node.method_name }
end

# Returns an array of block nodes of any depth below node in AST
def find_all_blocks(node, block_name)
return if node.nil?
node.each_descendant(:block).select { |block_node| block_name == block_node.method_name }
end

# Returns a method definition node with method_name
def find_method_def(node, method_name)
return if node.nil?
Expand Down Expand Up @@ -256,7 +250,8 @@ def caveats_strings

# Returns the array of arguments of the method_node
def parameters(method_node)
method_node.method_args if method_node.send_type? || method_node.block_type?
return unless method_node.send_type?
method_node.method_args
end

# Returns true if the given parameters are present in method call
Expand Down
78 changes: 0 additions & 78 deletions Library/Homebrew/test/rubocops/checksum_cop_spec.rb

This file was deleted.

0 comments on commit 1ef00aa

Please sign in to comment.