Merge pull request #1106 from reitermarkus/rubocop

Even more RuboCop changes.
This commit is contained in:
Mike McQuaid 2016-09-23 19:35:15 +01:00 committed by GitHub
commit dd393c73ed
37 changed files with 74 additions and 92 deletions

View File

@ -23,9 +23,8 @@ Style/CommandLiteral:
Style/RegexpLiteral: Style/RegexpLiteral:
EnforcedStyle: slashes EnforcedStyle: slashes
# too prevalent to change this now, but might be discussed/changed later
Style/Alias: Style/Alias:
EnforcedStyle: prefer_alias_method EnforcedStyle: prefer_alias
# our current conditional style is established, clear and # our current conditional style is established, clear and
# requiring users to change that now would be confusing. # requiring users to change that now would be confusing.

View File

@ -91,14 +91,6 @@ Style/AccessorMethodName:
- 'Homebrew/formulary.rb' - 'Homebrew/formulary.rb'
- 'Homebrew/migrator.rb' - 'Homebrew/migrator.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: prefer_alias, prefer_alias_method
Style/Alias:
Exclude:
- 'Homebrew/blacklist.rb'
# Offense count: 1 # Offense count: 1
Style/CaseEquality: Style/CaseEquality:
Exclude: Exclude:
@ -119,13 +111,6 @@ Style/ConstantName:
Exclude: Exclude:
- 'Homebrew/os/mac.rb' - 'Homebrew/os/mac.rb'
# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: format, sprintf, percent
Style/FormatString:
Exclude:
- 'Homebrew/formula.rb'
# Offense count: 13 # Offense count: 13
# Configuration parameters: AllowedVariables. # Configuration parameters: AllowedVariables.
Style/GlobalVars: Style/GlobalVars:
@ -194,8 +179,6 @@ Style/ModuleFunction:
- 'Homebrew/os/mac.rb' - 'Homebrew/os/mac.rb'
- 'Homebrew/os/mac/xcode.rb' - 'Homebrew/os/mac/xcode.rb'
- 'Homebrew/os/mac/xquartz.rb' - 'Homebrew/os/mac/xquartz.rb'
- 'Homebrew/utils/github.rb'
- 'Homebrew/utils/json.rb'
# Offense count: 8 # Offense count: 8
Style/MultilineBlockChain: Style/MultilineBlockChain:

View File

@ -47,7 +47,7 @@ class BuildOptions
def bottle? def bottle?
include? "build-bottle" include? "build-bottle"
end end
alias_method :build_bottle?, :bottle? alias build_bottle? bottle?
# True if a {Formula} is being built with {Formula.head} instead of {Formula.stable}. # True if a {Formula} is being built with {Formula.head} instead of {Formula.stable}.
# <pre>args << "--some-new-stuff" if build.head?</pre> # <pre>args << "--some-new-stuff" if build.head?</pre>

View File

@ -1,6 +1,6 @@
class Checksum class Checksum
attr_reader :hash_type, :hexdigest attr_reader :hash_type, :hexdigest
alias_method :to_s, :hexdigest alias to_s hexdigest
TYPES = [:sha256].freeze TYPES = [:sha256].freeze

View File

@ -1,7 +1,7 @@
require "dependency_collector" require "dependency_collector"
class DependencyCollector class DependencyCollector
alias_method :_parse_symbol_spec, :parse_symbol_spec alias _parse_symbol_spec parse_symbol_spec
def parse_symbol_spec(spec, tags) def parse_symbol_spec(spec, tags)
case spec case spec

View File

@ -72,8 +72,8 @@ class Formula
yield if block_given? yield if block_given?
PythonRequirement.new PythonRequirement.new
end end
alias_method :python2, :python alias python2 python
alias_method :python3, :python alias python3 python
def startup_plist def startup_plist
odeprecated "Formula#startup_plist", "Formula#plist" odeprecated "Formula#startup_plist", "Formula#plist"

View File

@ -25,7 +25,7 @@ class AmazonWebServicesFormula < Formula
libexec.install Dir["*"] libexec.install Dir["*"]
bin.install_symlink Dir["#{libexec}/bin/*"] - ["#{libexec}/bin/service"] bin.install_symlink Dir["#{libexec}/bin/*"] - ["#{libexec}/bin/service"]
end end
alias_method :standard_install, :install alias standard_install install
# Use this method to generate standard caveats. # Use this method to generate standard caveats.
def standard_instructions(home_name, home_value = libexec) def standard_instructions(home_name, home_value = libexec)

View File

@ -18,7 +18,7 @@ class CompilerFailure
# Allows Apple compiler `fails_with` statements to keep using `build` # Allows Apple compiler `fails_with` statements to keep using `build`
# even though `build` and `version` are the same internally # even though `build` and `version` are the same internally
alias_method :build, :version alias build version
# The cause is no longer used so we need not hold a reference to the string # The cause is no longer used so we need not hold a reference to the string
def cause(_); end def cause(_); end

View File

@ -14,7 +14,7 @@ module Debrew
super(e) unless Debrew.debug(e) == :ignore super(e) unless Debrew.debug(e) == :ignore
end end
alias_method :fail, :raise alias fail raise
end end
module Formula module Formula
@ -75,7 +75,7 @@ module Debrew
end end
class << self class << self
alias_method :original_raise, :raise alias original_raise raise
end end
@active = false @active = false

View File

@ -22,7 +22,7 @@ class Dependencies
@deps * arg @deps * arg
end end
alias_method :to_ary, :to_a alias to_ary to_a
def optional def optional
select(&:optional?) select(&:optional?)
@ -50,7 +50,7 @@ class Dependencies
def ==(other) def ==(other)
deps == other.deps deps == other.deps
end end
alias_method :eql?, :== alias eql? ==
def inspect def inspect
"#<#{self.class.name}: #{to_a.inspect}>" "#<#{self.class.name}: #{to_a.inspect}>"
@ -79,5 +79,5 @@ class Requirements
self self
end end
alias_method :to_ary, :to_a alias to_ary to_a
end end

View File

@ -22,7 +22,7 @@ class Dependency
def ==(other) def ==(other)
instance_of?(other.class) && name == other.name && tags == other.tags instance_of?(other.class) && name == other.name && tags == other.tags
end end
alias_method :eql?, :== alias eql? ==
def hash def hash
name.hash ^ tags.hash name.hash ^ tags.hash

View File

@ -22,8 +22,7 @@ class DevelopmentTools
def installation_instructions def installation_instructions
"Install Clang or brew install gcc" "Install Clang or brew install gcc"
end end
alias_method :custom_installation_instructions, alias custom_installation_instructions installation_instructions
:installation_instructions
def default_cc def default_cc
cc = DevelopmentTools.locate "cc" cc = DevelopmentTools.locate "cc"
@ -48,7 +47,7 @@ class DevelopmentTools
`#{path} --version 2>/dev/null`[/build (\d{4,})/, 1].to_i `#{path} --version 2>/dev/null`[/build (\d{4,})/, 1].to_i
end end
end end
alias_method :gcc_4_0_build_version, :gcc_40_build_version alias gcc_4_0_build_version gcc_40_build_version
def gcc_42_build_version def gcc_42_build_version
@gcc_42_build_version ||= @gcc_42_build_version ||=
@ -59,7 +58,7 @@ class DevelopmentTools
end end
end end
end end
alias_method :gcc_build_version, :gcc_42_build_version alias gcc_build_version gcc_42_build_version
def clang_version def clang_version
@clang_version ||= @clang_version ||=

View File

@ -608,7 +608,7 @@ class SubversionDownloadStrategy < VCSDownloadStrategy
fetch_repo cached_location, @url fetch_repo cached_location, @url
end end
end end
alias_method :update, :clone_repo alias update clone_repo
end end
class GitDownloadStrategy < VCSDownloadStrategy class GitDownloadStrategy < VCSDownloadStrategy

View File

@ -17,7 +17,7 @@ module Emoji
def enabled? def enabled?
!ENV["HOMEBREW_NO_EMOJI"] !ENV["HOMEBREW_NO_EMOJI"]
end end
alias_method :generic_enabled?, :enabled? alias generic_enabled? enabled?
end end
end end

View File

@ -53,7 +53,7 @@ module Stdenv
append_path "PATH", gcc_formula.opt_bin.to_s append_path "PATH", gcc_formula.opt_bin.to_s
end end
end end
alias_method :generic_setup_build_environment, :setup_build_environment alias generic_setup_build_environment setup_build_environment
def homebrew_extra_pkg_config_paths def homebrew_extra_pkg_config_paths
[] []
@ -84,7 +84,7 @@ module Stdenv
old old
end end
alias_method :j1, :deparallelize alias j1 deparallelize
# These methods are no-ops for compatibility. # These methods are no-ops for compatibility.
%w[fast O4 Og].each { |opt| define_method(opt) {} } %w[fast O4 Og].each { |opt| define_method(opt) {} }
@ -112,13 +112,13 @@ module Stdenv
super super
set_cpu_cflags "-march=nocona -mssse3" set_cpu_cflags "-march=nocona -mssse3"
end end
alias_method :gcc_4_0_1, :gcc_4_0 alias gcc_4_0_1 gcc_4_0
def gcc def gcc
super super
set_cpu_cflags set_cpu_cflags
end end
alias_method :gcc_4_2, :gcc alias gcc_4_2 gcc
GNU_GCC_VERSIONS.each do |n| GNU_GCC_VERSIONS.each do |n|
define_method(:"gcc-#{n}") do define_method(:"gcc-#{n}") do
@ -139,19 +139,19 @@ module Stdenv
def minimal_optimization def minimal_optimization
set_cflags "-Os #{SAFE_CFLAGS_FLAGS}" set_cflags "-Os #{SAFE_CFLAGS_FLAGS}"
end end
alias_method :generic_minimal_optimization, :minimal_optimization alias generic_minimal_optimization minimal_optimization
def no_optimization def no_optimization
set_cflags SAFE_CFLAGS_FLAGS set_cflags SAFE_CFLAGS_FLAGS
end end
alias_method :generic_no_optimization, :no_optimization alias generic_no_optimization no_optimization
def libxml2 def libxml2
end end
def x11 def x11
end end
alias_method :libpng, :x11 alias libpng x11
# we've seen some packages fail to build when warnings are disabled! # we've seen some packages fail to build when warnings are disabled!
def enable_warnings def enable_warnings
@ -224,7 +224,7 @@ module Stdenv
append flags, xarch unless xarch.empty? append flags, xarch unless xarch.empty?
append flags, map.fetch(effective_arch, default) append flags, map.fetch(effective_arch, default)
end end
alias_method :generic_set_cpu_flags, :set_cpu_flags alias generic_set_cpu_flags set_cpu_flags
# @private # @private
def effective_arch def effective_arch

View File

@ -18,7 +18,7 @@ module Superenv
attr_accessor :keg_only_deps, :deps attr_accessor :keg_only_deps, :deps
attr_accessor :x11 attr_accessor :x11
alias_method :x11?, :x11 alias x11? x11
def self.extended(base) def self.extended(base)
base.keg_only_deps = [] base.keg_only_deps = []
@ -82,7 +82,7 @@ module Superenv
# s - apply fix for sed's Unicode support # s - apply fix for sed's Unicode support
# a - apply fix for apr-1-config path # a - apply fix for apr-1-config path
end end
alias_method :generic_setup_build_environment, :setup_build_environment alias generic_setup_build_environment setup_build_environment
private private
@ -263,7 +263,7 @@ module Superenv
old old
end end
alias_method :j1, :deparallelize alias j1 deparallelize
def make_jobs def make_jobs
self["MAKEFLAGS"] =~ /-\w*j(\d+)/ self["MAKEFLAGS"] =~ /-\w*j(\d+)/
@ -334,18 +334,18 @@ module Superenv
# These methods are no longer necessary under superenv, but are needed to # These methods are no longer necessary under superenv, but are needed to
# maintain an interface compatible with stdenv. # maintain an interface compatible with stdenv.
alias_method :fast, :noop alias fast noop
alias_method :O4, :noop alias O4 noop
alias_method :Og, :noop alias Og noop
alias_method :libxml2, :noop alias libxml2 noop
alias_method :set_cpu_flags, :noop alias set_cpu_flags noop
# These methods provide functionality that has not yet been ported to # These methods provide functionality that has not yet been ported to
# superenv. # superenv.
alias_method :gcc_4_0_1, :noop alias gcc_4_0_1 noop
alias_method :minimal_optimization, :noop alias minimal_optimization noop
alias_method :no_optimization, :noop alias no_optimization noop
alias_method :enable_warnings, :noop alias enable_warnings noop
end end
class Array class Array

View File

@ -84,7 +84,7 @@ module FileUtils
end end
# @private # @private
alias_method :old_mkdir, :mkdir alias old_mkdir mkdir
# A version of mkdir that also changes to that folder in a block. # A version of mkdir that also changes to that folder in a block.
def mkdir(name, &_block) def mkdir(name, &_block)
@ -122,7 +122,7 @@ module FileUtils
if method_defined?(:ruby) if method_defined?(:ruby)
# @private # @private
alias_method :old_ruby, :ruby alias old_ruby ruby
end end
# Run the `ruby` Homebrew is using rather than whatever is in the `PATH`. # Run the `ruby` Homebrew is using rather than whatever is in the `PATH`.

View File

@ -81,7 +81,7 @@ module Hardware
%w[aes altivec avx avx2 lm sse3 ssse3 sse4 sse4_2].each do |flag| %w[aes altivec avx avx2 lm sse3 ssse3 sse4 sse4_2].each do |flag|
define_method(flag + "?") { flags.include? flag } define_method(flag + "?") { flags.include? flag }
end end
alias_method :is_64_bit?, :lm? alias is_64_bit? lm?
def bits def bits
is_64_bit? ? 64 : 32 is_64_bit? ? 64 : 32

View File

@ -3,7 +3,7 @@ require "os/mac/xcode"
# @private # @private
class DevelopmentTools class DevelopmentTools
class << self class << self
alias_method :original_locate, :locate alias original_locate locate
def locate(tool) def locate(tool)
(@locate ||= {}).fetch(tool) do |key| (@locate ||= {}).fetch(tool) do |key|
@locate[key] = if (located_tool = original_locate(tool)) @locate[key] = if (located_tool = original_locate(tool))

View File

@ -118,6 +118,6 @@ module Superenv
# These methods are no longer necessary under superenv, but are needed to # These methods are no longer necessary under superenv, but are needed to
# maintain an interface compatible with stdenv. # maintain an interface compatible with stdenv.
alias_method :macosxsdk, :noop alias macosxsdk noop
alias_method :remove_macosxsdk, :noop alias remove_macosxsdk noop
end end

View File

@ -21,7 +21,7 @@ module Utils
class Collector class Collector
private private
alias_method :original_find_matching_tag, :find_matching_tag alias original_find_matching_tag find_matching_tag
def find_matching_tag(tag) def find_matching_tag(tag)
original_find_matching_tag(tag) || find_altivec_tag(tag) || find_or_later_tag(tag) original_find_matching_tag(tag) || find_altivec_tag(tag) || find_or_later_tag(tag)
end end

View File

@ -132,7 +132,7 @@ class Pathname
if method_defined?(:write) if method_defined?(:write)
# @private # @private
alias_method :old_write, :write alias old_write write
end end
# we assume this pathname object is a file obviously # we assume this pathname object is a file obviously
@ -212,7 +212,7 @@ class Pathname
end end
# @private # @private
alias_method :extname_old, :extname alias extname_old extname
# extended to support common double extensions # extended to support common double extensions
def extname(path = to_s) def extname(path = to_s)
@ -322,7 +322,7 @@ class Pathname
end end
# FIXME: eliminate the places where we rely on this method # FIXME: eliminate the places where we rely on this method
alias_method :to_str, :to_s unless method_defined?(:to_str) alias to_str to_s unless method_defined?(:to_str)
def cd def cd
Dir.chdir(self) { yield } Dir.chdir(self) { yield }

View File

@ -13,7 +13,7 @@ class String
# sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt # sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
# mollit anim id est laborum. # mollit anim id est laborum.
# EOS # EOS
alias_method :undent_________________________________________________________72, :undent alias undent_________________________________________________________72 undent
# String.chomp, but if result is empty: returns nil instead. # String.chomp, but if result is empty: returns nil instead.
# Allows `chuzzle || foo` short-circuits. # Allows `chuzzle || foo` short-circuits.

View File

@ -162,7 +162,7 @@ class Formula
# Defaults to true. # Defaults to true.
# @return [Boolean] # @return [Boolean]
attr_accessor :follow_installed_alias attr_accessor :follow_installed_alias
alias_method :follow_installed_alias?, :follow_installed_alias alias follow_installed_alias? follow_installed_alias
# @private # @private
def initialize(name, path, spec, alias_path: nil) def initialize(name, path, spec, alias_path: nil)
@ -1235,7 +1235,7 @@ class Formula
name == other.name && name == other.name &&
active_spec == other.active_spec active_spec == other.active_spec
end end
alias_method :eql?, :== alias eql? ==
# @private # @private
def hash def hash
@ -1668,7 +1668,7 @@ class Formula
@exec_count ||= 0 @exec_count ||= 0
@exec_count += 1 @exec_count += 1
logfn = "#{logs}/#{active_log_prefix}%02d.%s" % [@exec_count, File.basename(cmd).split(" ").first] logfn = format("#{logs}/#{active_log_prefix}%02d.%s", @exec_count, File.basename(cmd).split(" ").first)
logs.mkpath logs.mkpath
File.open(logfn, "w") do |log| File.open(logfn, "w") do |log|

View File

@ -166,7 +166,7 @@ module FormulaCellarChecks
audit_check_output(check_elisp_dirname(formula.share, formula.name)) audit_check_output(check_elisp_dirname(formula.share, formula.name))
audit_check_output(check_elisp_root(formula.share, formula.name)) audit_check_output(check_elisp_root(formula.share, formula.name))
end end
alias_method :generic_audit_installed, :audit_installed alias generic_audit_installed audit_installed
private private

View File

@ -43,10 +43,10 @@ module Homebrew
extend self extend self
attr_accessor :failed attr_accessor :failed
alias_method :failed?, :failed alias failed? failed
attr_accessor :raise_deprecation_exceptions attr_accessor :raise_deprecation_exceptions
alias_method :raise_deprecation_exceptions?, :raise_deprecation_exceptions alias raise_deprecation_exceptions? raise_deprecation_exceptions
end end
HOMEBREW_PULL_API_REGEX = %r{https://api\.github\.com/repos/([\w-]+)/([\w-]+)?/pulls/(\d+)} HOMEBREW_PULL_API_REGEX = %r{https://api\.github\.com/repos/([\w-]+)/([\w-]+)?/pulls/(\d+)}

View File

@ -118,9 +118,9 @@ class Keg
end end
if Pathname.method_defined?(:to_path) if Pathname.method_defined?(:to_path)
alias_method :to_path, :to_s alias to_path to_s
else else
alias_method :to_str, :to_s alias to_str to_s
end end
def inspect def inspect
@ -130,7 +130,7 @@ class Keg
def ==(other) def ==(other)
instance_of?(other.class) && path == other.path instance_of?(other.class) && path == other.path
end end
alias_method :eql?, :== alias eql? ==
def hash def hash
path.hash path.hash

View File

@ -13,7 +13,7 @@ class Keg
end end
end end
end end
alias_method :generic_fix_dynamic_linkage, :fix_dynamic_linkage alias generic_fix_dynamic_linkage fix_dynamic_linkage
def relocate_dynamic_linkage(_old_prefix, _new_prefix, _old_cellar, _new_cellar) def relocate_dynamic_linkage(_old_prefix, _new_prefix, _old_cellar, _new_cellar)
[] []

View File

@ -21,7 +21,7 @@ class Option
def ==(other) def ==(other)
instance_of?(other.class) && name == other.name instance_of?(other.class) && name == other.name
end end
alias_method :eql?, :== alias eql? ==
def hash def hash
name.hash name.hash
@ -51,7 +51,7 @@ class DeprecatedOption
def ==(other) def ==(other)
instance_of?(other.class) && old == other.old && current == other.current instance_of?(other.class) && old == other.old && current == other.current
end end
alias_method :eql?, :== alias eql? ==
end end
class Options class Options
@ -106,7 +106,7 @@ class Options
any? { |opt| opt == o || opt.name == o || opt.flag == o } any? { |opt| opt == o || opt.name == o || opt.flag == o }
end end
alias_method :to_ary, :to_a alias to_ary to_a
def inspect def inspect
"#<#{self.class.name}: #{to_a.inspect}>" "#<#{self.class.name}: #{to_a.inspect}>"

View File

@ -29,13 +29,13 @@ class PkgVersion
version.to_s version.to_s
end end
end end
alias_method :to_str, :to_s alias to_str to_s
def <=>(other) def <=>(other)
return unless other.is_a?(PkgVersion) return unless other.is_a?(PkgVersion)
(version <=> other.version).nonzero? || revision <=> other.revision (version <=> other.version).nonzero? || revision <=> other.revision
end end
alias_method :eql?, :== alias eql? ==
def hash def hash
version.hash ^ revision.hash version.hash ^ revision.hash

View File

@ -102,7 +102,7 @@ class Requirement
def ==(other) def ==(other)
instance_of?(other.class) && name == other.name && tags == other.tags instance_of?(other.class) && name == other.name && tags == other.tags
end end
alias_method :eql?, :== alias eql? ==
def hash def hash
name.hash ^ tags.hash name.hash ^ tags.hash

View File

@ -50,7 +50,7 @@ class PythonRequirement < Requirement
end end
# Deprecated # Deprecated
alias_method :to_s, :python_binary alias to_s python_binary
end end
class Python3Requirement < PythonRequirement class Python3Requirement < PythonRequirement

View File

@ -228,7 +228,7 @@ class Bottle
def to_s def to_s
prefix + suffix prefix + suffix
end end
alias_method :to_str, :to_s alias to_str to_s
def prefix def prefix
"#{name}-#{version}.#{tag}" "#{name}-#{version}.#{tag}"

View File

@ -152,7 +152,7 @@ class SystemConfig
f.puts "Ruby: #{describe_ruby}" f.puts "Ruby: #{describe_ruby}"
f.puts "Java: #{describe_java}" f.puts "Java: #{describe_java}"
end end
alias_method :dump_generic_verbose_config, :dump_verbose_config alias dump_generic_verbose_config dump_verbose_config
end end
end end

View File

@ -2,7 +2,8 @@ require "uri"
require "tempfile" require "tempfile"
module GitHub module GitHub
extend self module_function
ISSUES_URI = URI.parse("https://api.github.com/search/issues") ISSUES_URI = URI.parse("https://api.github.com/search/issues")
Error = Class.new(RuntimeError) Error = Class.new(RuntimeError)

View File

@ -2,7 +2,7 @@ require "vendor/okjson"
module Utils module Utils
module JSON module JSON
extend self module_function
Error = Class.new(StandardError) Error = Class.new(StandardError)

View File

@ -242,7 +242,7 @@ class Version
0 0
end end
alias_method :eql?, :== alias eql? ==
def hash def hash
version.hash version.hash
@ -251,7 +251,7 @@ class Version
def to_s def to_s
version.dup version.dup
end end
alias_method :to_str, :to_s alias to_str to_s
protected protected