Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant namespacing. #4835

Merged
merged 1 commit into from
Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions Library/Homebrew/cask/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,27 @@ def check_untrusted_pkg
return if tap.nil?
return if tap.user != "Homebrew"

return unless cask.artifacts.any? { |k| k.is_a?(Hbc::Artifact::Pkg) && k.stanza_options.key?(:allow_untrusted) }
return unless cask.artifacts.any? { |k| k.is_a?(Artifact::Pkg) && k.stanza_options.key?(:allow_untrusted) }
add_warning "allow_untrusted is not permitted in official Homebrew Cask taps"
end

def check_stanza_requires_uninstall
odebug "Auditing stanzas which require an uninstall"

return if cask.artifacts.none? { |k| k.is_a?(Hbc::Artifact::Pkg) || k.is_a?(Hbc::Artifact::Installer) }
return if cask.artifacts.any? { |k| k.is_a?(Hbc::Artifact::Uninstall) }
return if cask.artifacts.none? { |k| k.is_a?(Artifact::Pkg) || k.is_a?(Artifact::Installer) }
return if cask.artifacts.any? { |k| k.is_a?(Artifact::Uninstall) }
add_warning "installer and pkg stanzas require an uninstall stanza"
end

def check_single_pre_postflight
odebug "Auditing preflight and postflight stanzas"

if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::PreflightBlock) && k.directives.key?(:preflight) } > 1
if cask.artifacts.count { |k| k.is_a?(Artifact::PreflightBlock) && k.directives.key?(:preflight) } > 1
add_warning "only a single preflight stanza is allowed"
end

count = cask.artifacts.count do |k|
k.is_a?(Hbc::Artifact::PostflightBlock) &&
k.is_a?(Artifact::PostflightBlock) &&
k.directives.key?(:postflight)
end
return unless count > 1
Expand All @@ -95,12 +95,12 @@ def check_single_pre_postflight
def check_single_uninstall_zap
odebug "Auditing single uninstall_* and zap stanzas"

if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::Uninstall) } > 1
if cask.artifacts.count { |k| k.is_a?(Artifact::Uninstall) } > 1
add_warning "only a single uninstall stanza is allowed"
end

count = cask.artifacts.count do |k|
k.is_a?(Hbc::Artifact::PreflightBlock) &&
k.is_a?(Artifact::PreflightBlock) &&
k.directives.key?(:uninstall_preflight)
end

Expand All @@ -109,15 +109,15 @@ def check_single_uninstall_zap
end

count = cask.artifacts.count do |k|
k.is_a?(Hbc::Artifact::PostflightBlock) &&
k.is_a?(Artifact::PostflightBlock) &&
k.directives.key?(:uninstall_postflight)
end

if count > 1
add_warning "only a single uninstall_postflight stanza is allowed"
end

return unless cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::Zap) } > 1
return unless cask.artifacts.count { |k| k.is_a?(Artifact::Zap) } > 1
add_warning "only a single zap stanza is allowed"
end

Expand Down Expand Up @@ -276,7 +276,7 @@ def bad_osdn_url?
end

def check_generic_artifacts
cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Artifact) }.each do |artifact|
cask.artifacts.select { |a| a.is_a?(Artifact::Artifact) }.each do |artifact|
unless artifact.target.absolute?
add_error "target must be absolute path for #{artifact.class.english_name} #{artifact.source}"
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cask 'generic-artifact-absolute-target' do
artifact 'Caffeine.app', target: "#{Hbc::Config.global.appdir}/Caffeine.app"
artifact 'Caffeine.app', target: "#{appdir}/Caffeine.app"
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://example.com/with-generic-artifact'

artifact 'Caffeine.app', target: "#{Hbc::Config.global.appdir}/Caffeine.app"
artifact 'Caffeine.app', target: "#{appdir}/Caffeine.app"
end