mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
brew style manual fixes
This commit is contained in:
parent
e09147fe75
commit
8b97c27c21
@ -47,15 +47,13 @@ class PATH
|
||||
alias to_s to_str
|
||||
|
||||
def ==(other)
|
||||
if other.respond_to?(:to_ary)
|
||||
return true if to_ary == other.to_ary
|
||||
if other.respond_to?(:to_ary) && to_ary == other.to_ary
|
||||
true
|
||||
elsif other.respond_to?(:to_str) && to_str == other.to_str
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
|
||||
if other.respond_to?(:to_str)
|
||||
return true if to_str == other.to_str
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
def empty?
|
||||
|
@ -13,7 +13,6 @@ require "cask/exceptions"
|
||||
require "cask/denylist"
|
||||
require "cask/download"
|
||||
require "cask/dsl"
|
||||
require "cask/exceptions"
|
||||
require "cask/installer"
|
||||
require "cask/macos"
|
||||
require "cask/metadata"
|
||||
|
@ -14,10 +14,6 @@ module Cask
|
||||
new(cask)
|
||||
end
|
||||
|
||||
def initialize(cask)
|
||||
super(cask)
|
||||
end
|
||||
|
||||
def to_a
|
||||
[true]
|
||||
end
|
||||
|
@ -380,10 +380,10 @@ module Cask
|
||||
|
||||
add_warning "cask token contains .app" if token.end_with? ".app"
|
||||
|
||||
if /-(?<designation>alpha|beta|rc|release-candidate)$/ =~ cask.token
|
||||
if cask.tap.official? && cask.tap != "homebrew/cask-versions"
|
||||
add_warning "cask token contains version designation '#{designation}'"
|
||||
end
|
||||
if /-(?<designation>alpha|beta|rc|release-candidate)$/ =~ cask.token &&
|
||||
cask.tap.official? &&
|
||||
cask.tap != "homebrew/cask-versions"
|
||||
add_warning "cask token contains version designation '#{designation}'"
|
||||
end
|
||||
|
||||
add_warning "cask token mentions launcher" if token.end_with? "launcher"
|
||||
|
@ -44,9 +44,9 @@ module Cask
|
||||
odebug "Uninstalling Cask #{cask}"
|
||||
|
||||
if cask.installed?
|
||||
if installed_caskfile = cask.installed_caskfile
|
||||
if (installed_caskfile = cask.installed_caskfile) && installed_caskfile.exist?
|
||||
# Use the same cask file that was used for installation, if possible.
|
||||
cask = CaskLoader.load(installed_caskfile) if installed_caskfile.exist?
|
||||
cask = CaskLoader.load(installed_caskfile)
|
||||
end
|
||||
else
|
||||
raise CaskNotInstalledError, cask unless force
|
||||
|
@ -32,9 +32,9 @@ module Cask
|
||||
odebug "Zapping Cask #{cask}"
|
||||
|
||||
if cask.installed?
|
||||
if installed_caskfile = cask.installed_caskfile
|
||||
if (installed_caskfile = cask.installed_caskfile) && installed_caskfile.exist?
|
||||
# Use the same cask file that was used for installation, if possible.
|
||||
cask = CaskLoader.load(installed_caskfile) if installed_caskfile.exist?
|
||||
cask = CaskLoader.load(installed_caskfile)
|
||||
end
|
||||
else
|
||||
raise CaskNotInstalledError, cask unless args.force?
|
||||
|
@ -285,10 +285,8 @@ module Cask
|
||||
end
|
||||
end
|
||||
|
||||
def respond_to_missing?(*)
|
||||
super
|
||||
end
|
||||
|
||||
# No need to define it as its the default/superclass implementation.
|
||||
# rubocop:disable Style/MissingRespondToMissing
|
||||
def method_missing(method, *)
|
||||
if method
|
||||
Utils.method_missing_message(method, token)
|
||||
@ -297,6 +295,7 @@ module Cask
|
||||
super
|
||||
end
|
||||
end
|
||||
# rubocop:enable Style/MissingRespondToMissing
|
||||
|
||||
def appdir
|
||||
cask.config.appdir
|
||||
|
@ -21,10 +21,8 @@ module Cask
|
||||
@command.run!(executable, **options)
|
||||
end
|
||||
|
||||
def respond_to_missing?(*)
|
||||
super
|
||||
end
|
||||
|
||||
# No need to define it as its the default/superclass implementation.
|
||||
# rubocop:disable Style/MissingRespondToMissing
|
||||
def method_missing(method, *)
|
||||
if method
|
||||
underscored_class = self.class.name.gsub(/([[:lower:]])([[:upper:]][[:lower:]])/, '\1_\2').downcase
|
||||
@ -35,6 +33,7 @@ module Cask
|
||||
super
|
||||
end
|
||||
end
|
||||
# rubocop:enable Style/MissingRespondToMissing
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -214,9 +214,7 @@ module Cask
|
||||
|
||||
odebug "Installing artifact of class #{artifact.class}"
|
||||
|
||||
if artifact.is_a?(Artifact::Binary)
|
||||
next unless binaries?
|
||||
end
|
||||
next if artifact.is_a?(Artifact::Binary) && !binaries?
|
||||
|
||||
artifact.install_phase(command: @command, verbose: verbose?, force: force?)
|
||||
already_installed_artifacts.unshift(artifact)
|
||||
@ -226,13 +224,11 @@ module Cask
|
||||
rescue => e
|
||||
begin
|
||||
already_installed_artifacts.each do |artifact|
|
||||
next unless artifact.respond_to?(:uninstall_phase)
|
||||
if artifact.respond_to?(:uninstall_phase)
|
||||
odebug "Reverting installation of artifact of class #{artifact.class}"
|
||||
artifact.uninstall_phase(command: @command, verbose: verbose?, force: force?)
|
||||
end
|
||||
|
||||
odebug "Reverting installation of artifact of class #{artifact.class}"
|
||||
artifact.uninstall_phase(command: @command, verbose: verbose?, force: force?)
|
||||
end
|
||||
|
||||
already_installed_artifacts.each do |artifact|
|
||||
next unless artifact.respond_to?(:post_uninstall_phase)
|
||||
|
||||
odebug "Reverting installation of artifact of class #{artifact.class}"
|
||||
@ -455,13 +451,13 @@ module Cask
|
||||
odebug "#{artifacts.length} artifact/s defined", artifacts
|
||||
|
||||
artifacts.each do |artifact|
|
||||
next unless artifact.respond_to?(:uninstall_phase)
|
||||
if artifact.respond_to?(:uninstall_phase)
|
||||
odebug "Uninstalling artifact of class #{artifact.class}"
|
||||
artifact.uninstall_phase(
|
||||
command: @command, verbose: verbose?, skip: clear, force: force?, upgrade: upgrade?,
|
||||
)
|
||||
end
|
||||
|
||||
odebug "Uninstalling artifact of class #{artifact.class}"
|
||||
artifact.uninstall_phase(command: @command, verbose: verbose?, skip: clear, force: force?, upgrade: upgrade?)
|
||||
end
|
||||
|
||||
artifacts.each do |artifact|
|
||||
next unless artifact.respond_to?(:post_uninstall_phase)
|
||||
|
||||
odebug "Post-uninstalling artifact of class #{artifact.class}"
|
||||
|
@ -416,9 +416,7 @@ module Homebrew
|
||||
path.extend(ObserverPathnameExtension)
|
||||
if path.symlink?
|
||||
unless path.resolved_path_exists?
|
||||
if path.to_s.match?(Keg::INFOFILE_RX)
|
||||
path.uninstall_info unless dry_run?
|
||||
end
|
||||
path.uninstall_info if path.to_s.match?(Keg::INFOFILE_RX) && !dry_run?
|
||||
|
||||
if dry_run?
|
||||
puts "Would remove (broken link): #{path}"
|
||||
|
@ -63,8 +63,8 @@ module Homebrew
|
||||
def info
|
||||
args = info_args.parse
|
||||
|
||||
if args.days.present?
|
||||
raise UsageError, "--days must be one of #{VALID_DAYS.join(", ")}" unless VALID_DAYS.include?(args.days)
|
||||
if args.days.present? && !VALID_DAYS.include?(args.days)
|
||||
raise UsageError, "--days must be one of #{VALID_DAYS.join(", ")}"
|
||||
end
|
||||
|
||||
if args.category.present?
|
||||
@ -79,10 +79,7 @@ module Homebrew
|
||||
|
||||
if args.json
|
||||
raise UsageError, "invalid JSON version: #{args.json}" unless ["v1", true].include? args.json
|
||||
|
||||
if !(args.all? || args.installed?) && args.no_named?
|
||||
raise FormulaUnspecifiedError if args.no_named?
|
||||
end
|
||||
raise FormulaUnspecifiedError if !(args.all? || args.installed?) && args.no_named?
|
||||
|
||||
print_json(args: args)
|
||||
elsif args.github?
|
||||
|
@ -5,10 +5,8 @@ module Homebrew
|
||||
class Parser
|
||||
module Compat
|
||||
module DeprecatedArgs
|
||||
def respond_to_missing?(*)
|
||||
super
|
||||
end
|
||||
|
||||
# No need to define it as its the default/superclass implementation.
|
||||
# rubocop:disable Style/MissingRespondToMissing
|
||||
def method_missing(method, *)
|
||||
if ![:debug?, :quiet?, :verbose?, :value].include?(method) && !@printed_args_warning
|
||||
odeprecated "Homebrew.args", "`args = <command>_args.parse` and pass `args` along the call chain"
|
||||
@ -17,6 +15,7 @@ module Homebrew
|
||||
|
||||
super
|
||||
end
|
||||
# rubocop:enable Style/MissingRespondToMissing
|
||||
end
|
||||
|
||||
def parse(*)
|
||||
|
@ -81,11 +81,6 @@ class DescriptionCacheStore < CacheStore
|
||||
|
||||
private
|
||||
|
||||
# Not implemented; access is through `Searchable`.
|
||||
def fetch
|
||||
super
|
||||
end
|
||||
|
||||
# `select` from the underlying database.
|
||||
def select(&block)
|
||||
database.select(&block)
|
||||
|
@ -1030,8 +1030,8 @@ module Homebrew
|
||||
def audit_download_strategy
|
||||
url_strategy = DownloadStrategyDetector.detect(url)
|
||||
|
||||
if using == :git || url_strategy == GitDownloadStrategy
|
||||
problem "Git should specify :revision when a :tag is specified." if specs[:tag] && !specs[:revision]
|
||||
if (using == :git || url_strategy == GitDownloadStrategy) && specs[:tag] && !specs[:revision]
|
||||
problem "Git should specify :revision when a :tag is specified."
|
||||
end
|
||||
|
||||
return unless using
|
||||
|
@ -187,12 +187,10 @@ module Homebrew
|
||||
absolute_symlinks_start_with_string << pn if link.to_s.start_with?(string)
|
||||
end
|
||||
|
||||
if args.verbose?
|
||||
unless absolute_symlinks_start_with_string.empty?
|
||||
opoo "Absolute symlink starting with #{string}:"
|
||||
absolute_symlinks_start_with_string.each do |pn|
|
||||
puts " #{pn} -> #{pn.resolved_path}"
|
||||
end
|
||||
if args.verbose? && absolute_symlinks_start_with_string.present?
|
||||
opoo "Absolute symlink starting with #{string}:"
|
||||
absolute_symlinks_start_with_string.each do |pn|
|
||||
puts " #{pn} -> #{pn.resolved_path}"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -215,8 +215,8 @@ module Homebrew
|
||||
bintray_key = ENV["HOMEBREW_BINTRAY_KEY"]
|
||||
bintray_org = args.bintray_org || "homebrew"
|
||||
|
||||
if bintray_user.blank? || bintray_key.blank?
|
||||
odie "Missing HOMEBREW_BINTRAY_USER or HOMEBREW_BINTRAY_KEY variables!" if !args.dry_run? && !args.no_upload?
|
||||
if (bintray_user.blank? || bintray_key.blank?) && !args.dry_run? && !args.no_upload?
|
||||
odie "Missing HOMEBREW_BINTRAY_USER or HOMEBREW_BINTRAY_KEY variables!"
|
||||
end
|
||||
|
||||
workflow = args.workflow || "tests.yml"
|
||||
|
@ -656,11 +656,6 @@ module Homebrew
|
||||
end
|
||||
next if status.blank?
|
||||
|
||||
# these will result in uncommitted gems.
|
||||
if path == HOMEBREW_REPOSITORY
|
||||
next if ENV["HOMEBREW_SORBET"]
|
||||
end
|
||||
|
||||
message ||= ""
|
||||
message += "\n" unless message.empty?
|
||||
message += <<~EOS
|
||||
|
@ -19,6 +19,8 @@ require "active_support/core_ext/object/try"
|
||||
require "active_support/core_ext/array/access"
|
||||
require "active_support/core_ext/string/inflections"
|
||||
require "active_support/core_ext/array/conversions"
|
||||
require "active_support/core_ext/hash/deep_merge"
|
||||
require "active_support/core_ext/file/atomic"
|
||||
|
||||
I18n.backend.available_locales # Initialize locales so they can be overwritten.
|
||||
I18n.backend.store_translations :en, support: { array: { last_word_connector: " and " } }
|
||||
@ -66,7 +68,6 @@ HOMEBREW_DEFAULT_PREFIX = "/usr/local"
|
||||
LINUXBREW_DEFAULT_PREFIX = "/home/linuxbrew/.linuxbrew"
|
||||
|
||||
require "fileutils"
|
||||
require "os"
|
||||
require "os/global"
|
||||
|
||||
module Homebrew
|
||||
@ -123,9 +124,6 @@ end.compact.freeze
|
||||
require "set"
|
||||
|
||||
require "extend/string"
|
||||
require "active_support/core_ext/object/blank"
|
||||
require "active_support/core_ext/hash/deep_merge"
|
||||
require "active_support/core_ext/file/atomic"
|
||||
|
||||
require "system_command"
|
||||
require "exceptions"
|
||||
|
@ -297,8 +297,8 @@ class Keg
|
||||
next if aliases.include?(a)
|
||||
|
||||
alias_opt_symlink = opt/a
|
||||
if alias_opt_symlink.symlink? && alias_opt_symlink.exist?
|
||||
alias_opt_symlink.delete if rack == alias_opt_symlink.realpath.parent
|
||||
if alias_opt_symlink.symlink? && alias_opt_symlink.exist? && rack == alias_opt_symlink.realpath.parent
|
||||
alias_opt_symlink.delete
|
||||
end
|
||||
|
||||
alias_linkedkegs_symlink = linkedkegs/a
|
||||
|
@ -18,11 +18,9 @@ module RuboCop
|
||||
option_call_nodes.each do |option_call|
|
||||
option = parameters(option_call).first
|
||||
problem DEPRECATION_MSG if regex_match_group(option, /32-bit/)
|
||||
end
|
||||
|
||||
option_call_nodes.each do |option_call|
|
||||
offending_node(option_call)
|
||||
option = string_content(parameters(option_call).first)
|
||||
option = string_content(option)
|
||||
problem UNI_DEPRECATION_MSG if option == "universal"
|
||||
|
||||
if option !~ /with(out)?-/ &&
|
||||
|
@ -48,13 +48,11 @@ module RuboCop
|
||||
end
|
||||
|
||||
gh_patch_param_pattern = %r{https?://github\.com/.+/.+/(?:commit|pull)/[a-fA-F0-9]*.(?:patch|diff)}
|
||||
if regex_match_group(patch, gh_patch_param_pattern)
|
||||
unless patch_url.match?(/\?full_index=\w+$/)
|
||||
problem <<~EOS
|
||||
GitHub patches should use the full_index parameter:
|
||||
#{patch_url}?full_index=1
|
||||
EOS
|
||||
end
|
||||
if regex_match_group(patch, gh_patch_param_pattern) && !patch_url.match?(/\?full_index=\w+$/)
|
||||
problem <<~EOS
|
||||
GitHub patches should use the full_index parameter:
|
||||
#{patch_url}?full_index=1
|
||||
EOS
|
||||
end
|
||||
|
||||
gh_patch_patterns = Regexp.union([%r{/raw\.github\.com/},
|
||||
@ -62,13 +60,11 @@ module RuboCop
|
||||
%r{gist\.github\.com/raw},
|
||||
%r{gist\.github\.com/.+/raw},
|
||||
%r{gist\.githubusercontent\.com/.+/raw}])
|
||||
if regex_match_group(patch, gh_patch_patterns)
|
||||
unless patch_url.match?(%r{/[a-fA-F0-9]{6,40}/})
|
||||
problem <<~EOS.chomp
|
||||
GitHub/Gist patches should specify a revision:
|
||||
#{patch_url}
|
||||
EOS
|
||||
end
|
||||
if regex_match_group(patch, gh_patch_patterns) && !patch_url.match?(%r{/[a-fA-F0-9]{6,40}/})
|
||||
problem <<~EOS.chomp
|
||||
GitHub/Gist patches should specify a revision:
|
||||
#{patch_url}
|
||||
EOS
|
||||
end
|
||||
|
||||
gh_patch_diff_pattern =
|
||||
|
@ -64,8 +64,10 @@ module RuboCop
|
||||
name_regex = name.delete("-").split("").join('[\s\-]?')
|
||||
problem "Description shouldn't start with the #{type} name." if regex_match_group(desc, /^#{name_regex}\b/i)
|
||||
|
||||
if type == :cask && match = regex_match_group(desc, /\b(macOS|Mac( ?OS( ?X)?)?|OS ?X)\b/i)
|
||||
problem "Description shouldn't contain the platform." if match[1] != "MAC"
|
||||
if type == :cask &&
|
||||
(match = regex_match_group(desc, /\b(macOS|Mac( ?OS( ?X)?)?|OS ?X)\b/i)) &&
|
||||
match[1] != "MAC"
|
||||
problem "Description shouldn't contain the platform."
|
||||
end
|
||||
|
||||
# Check if a full stop is used at the end of a desc (apart from in the case of "etc.").
|
||||
|
@ -145,10 +145,7 @@ module SystemConfig
|
||||
|
||||
value = Homebrew::EnvConfig.send(method_name)
|
||||
next unless value
|
||||
|
||||
if (default = hash[:default].presence)
|
||||
next if value.to_s == default.to_s
|
||||
end
|
||||
next if (default = hash[:default].presence) && value.to_s == default.to_s
|
||||
|
||||
if ENV.sensitive?(env)
|
||||
f.puts "#{env}: set"
|
||||
|
@ -272,8 +272,8 @@ class Tap
|
||||
|
||||
begin
|
||||
safe_system "git", *args
|
||||
unless Readall.valid_tap?(self, aliases: true)
|
||||
raise "Cannot tap #{name}: invalid syntax in tap!" unless Homebrew::EnvConfig.developer?
|
||||
if !Readall.valid_tap?(self, aliases: true) && !Homebrew::EnvConfig.developer?
|
||||
raise "Cannot tap #{name}: invalid syntax in tap!"
|
||||
end
|
||||
rescue Interrupt, RuntimeError
|
||||
ignore_interrupts do
|
||||
|
@ -192,9 +192,6 @@ describe BottleSpecification do
|
||||
|
||||
checksums.each_pair do |cat, digest|
|
||||
subject.sha256(digest => cat)
|
||||
end
|
||||
|
||||
checksums.each_pair do |cat, digest|
|
||||
checksum, = subject.checksum_for(cat)
|
||||
expect(Checksum.new(:sha256, digest)).to eq(checksum)
|
||||
end
|
||||
|
@ -138,9 +138,8 @@ module Utils
|
||||
else
|
||||
item["formula"]
|
||||
end
|
||||
if filter.present?
|
||||
next if key != filter && !key.start_with?("#{filter} ")
|
||||
end
|
||||
next if filter.present? && key != filter && !key.start_with?("#{filter} ")
|
||||
|
||||
results[key] = item["count"].tr(",", "").to_i
|
||||
end
|
||||
|
||||
@ -163,12 +162,8 @@ module Utils
|
||||
value.each do |days, results|
|
||||
days = days.to_i
|
||||
if full_analytics
|
||||
if args.days.present?
|
||||
next if args.days&.to_i != days
|
||||
end
|
||||
if args.category.present?
|
||||
next if args.category != category
|
||||
end
|
||||
next if args.days.present? && args.days&.to_i != days
|
||||
next if args.category.present? && args.category != category
|
||||
|
||||
table_output(category, days, results)
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user