Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Library/Homebrew/cask/cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
require "cask/config"

require "cask/cmd/abstract_command"
require "cask/cmd/audit"
require "cask/cmd/install"

module Cask
Expand Down
110 changes: 0 additions & 110 deletions Library/Homebrew/cask/cmd/audit.rb

This file was deleted.

43 changes: 24 additions & 19 deletions Library/Homebrew/dev-cmd/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,30 +237,35 @@ def self.audit
cask_results = if audit_casks.empty?
{}
else
require "cask/cmd/abstract_command"
require "cask/cmd/audit"

if args.display_failures_only?
odeprecated "`brew audit <cask> --display-failures-only`", "`brew audit <cask>` without the argument"
end

# For switches, we add `|| nil` so that `nil` will be passed instead of `false` if they aren't set.
# This way, we can distinguish between "not set" and "set to false".
Cask::Cmd::Audit.audit_casks(
*audit_casks,
download: nil,
# No need for `|| nil` for `--[no-]signing` because boolean switches are already `nil` if not passed
signing: args.signing?,
online: args.online? || nil,
strict: args.strict? || nil,
new_cask: args.new_cask? || nil,
token_conflicts: args.token_conflicts? || nil,
quarantine: nil,
any_named_args: !no_named_args,
language: nil,
only: args.only,
except: args.except,
)
require "cask/auditor"

audit_casks.to_h do |cask|
odebug "Auditing Cask #{cask}"
errors = Cask::Auditor.audit(
cask,
# For switches, we add `|| nil` so that `nil` will be passed
# instead of `false` if they aren't set.
# This way, we can distinguish between "not set" and "set to false".
audit_online: (args.online? || nil),
audit_strict: (args.strict? || nil),

# No need for `|| nil` for `--[no-]signing`
# because boolean switches are already `nil` if not passed
audit_signing: args.signing?,
audit_new_cask: (args.new_cask? || nil),
audit_token_conflicts: (args.token_conflicts? || nil),
quarantine: true,
any_named_args: !no_named_args,
only: args.only,
except: args.except,
)
[cask.sourcefile_path, { errors: errors, warnings: [] }]
end
end

failed_casks = cask_results.reject { |_, result| result[:errors].empty? }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
failed_casks = cask_results.reject { |_, result| result[:errors].empty? }
failed_casks = cask_results.reject { |_, errors| errors.empty? }

below here: all references to result[:warnings] can be removed and result[: errors] replaced with just result/errors because, if you apply suggestions above, warnings is never set/used and errors is the hash value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hurray, this was a TODO that I wrote a note about in 8319c8f so it's great if this gets done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hyuraku nudge on this!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #15269 for this.

Expand Down
161 changes: 0 additions & 161 deletions Library/Homebrew/test/cask/cmd/audit_spec.rb

This file was deleted.

23 changes: 0 additions & 23 deletions Library/Homebrew/test/cask/quarantine_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# typed: false
# frozen_string_literal: true

require "cask/cmd/audit"
require "cask/cmd/install"
require "cask/cask_loader"
require "cask/download"
Expand Down Expand Up @@ -36,17 +35,6 @@
expect(cached_location).to be_quarantined
end

it "quarantines Cask audits" do
expect do
Cask::Cmd::Audit.run("local-transmission", "--download")
end.to not_raise_error.and not_to_output.to_stderr

local_transmission = Cask::CaskLoader.load(cask_path("local-transmission"))
cached_location = Cask::Download.new(local_transmission).fetch

expect(cached_location).to be_quarantined
end

it "quarantines Cask installs even if the fetch was not" do
download = Cask::Download.new(Cask::CaskLoader.load("local-transmission"), quarantine: false)
download.fetch
Expand Down Expand Up @@ -151,17 +139,6 @@
expect(cached_location).not_to be_quarantined
end

it "does not quarantine Cask audits" do
expect do
Cask::Cmd::Audit.run("local-transmission", "--download", "--no-quarantine")
end.to not_raise_error.and not_to_output.to_stderr

local_transmission = Cask::CaskLoader.load(cask_path("local-transmission"))
cached_location = Cask::Download.new(local_transmission).fetch

expect(cached_location).not_to be_quarantined
end

it "does not quarantine Cask installs even if the fetch was" do
download = Cask::Download.new(Cask::CaskLoader.load("local-transmission"), quarantine: true)
download.fetch
Expand Down