Fix Style/IfUnlessModifier.

This commit is contained in:
Markus Reiter 2016-09-23 11:01:40 +02:00
parent a5b11a6a5c
commit fe2d51e0b9
30 changed files with 49 additions and 162 deletions

View File

@ -177,34 +177,6 @@ Style/IfUnlessModifier:
Exclude: Exclude:
- 'Taps/**/*' - 'Taps/**/*'
- 'Homebrew/dev-cmd/audit.rb' - 'Homebrew/dev-cmd/audit.rb'
- 'Homebrew/dev-cmd/bottle.rb'
- 'Homebrew/dev-cmd/edit.rb'
- 'Homebrew/dev-cmd/mirror.rb'
- 'Homebrew/dev-cmd/pull.rb'
- 'Homebrew/dev-cmd/test-bot.rb'
- 'Homebrew/extend/ENV/std.rb'
- 'Homebrew/extend/ENV/super.rb'
- 'Homebrew/extend/os/blacklist.rb'
- 'Homebrew/extend/os/bottles.rb'
- 'Homebrew/extend/os/cleaner.rb'
- 'Homebrew/extend/os/development_tools.rb'
- 'Homebrew/extend/os/diagnostic.rb'
- 'Homebrew/extend/os/emoji.rb'
- 'Homebrew/extend/os/extend/ENV/shared.rb'
- 'Homebrew/extend/os/extend/ENV/std.rb'
- 'Homebrew/extend/os/extend/ENV/super.rb'
- 'Homebrew/extend/os/formula_cellar_checks.rb'
- 'Homebrew/extend/os/keg_relocate.rb'
- 'Homebrew/extend/os/mac/extend/ENV/shared.rb'
- 'Homebrew/extend/os/system_config.rb'
- 'Homebrew/formula.rb'
- 'Homebrew/formula_installer.rb'
- 'Homebrew/formula_versions.rb'
- 'Homebrew/formulary.rb'
- 'Homebrew/language/haskell.rb'
- 'Homebrew/migrator.rb'
- 'Homebrew/tab.rb'
- 'Homebrew/utils/git.rb'
# Offense count: 2 # Offense count: 2
# Cop supports --auto-correct. # Cop supports --auto-correct.

View File

@ -108,9 +108,7 @@ module Homebrew
absolute_symlinks_start_with_string = [] absolute_symlinks_start_with_string = []
keg.find do |pn| keg.find do |pn|
next unless pn.symlink? && (link = pn.readlink).absolute? next unless pn.symlink? && (link = pn.readlink).absolute?
if link.to_s.start_with?(string) absolute_symlinks_start_with_string << pn if link.to_s.start_with?(string)
absolute_symlinks_start_with_string << pn
end
end end
if ARGV.verbose? if ARGV.verbose?
@ -155,9 +153,7 @@ module Homebrew
return ofail "Formula not installed with '--build-bottle': #{f.full_name}" return ofail "Formula not installed with '--build-bottle': #{f.full_name}"
end end
unless f.stable return ofail "Formula has no stable version: #{f.full_name}" unless f.stable
return ofail "Formula has no stable version: #{f.full_name}"
end
if ARGV.include?("--no-rebuild") || !f.tap if ARGV.include?("--no-rebuild") || !f.tap
rebuild = 0 rebuild = 0

View File

@ -33,9 +33,9 @@ module Homebrew
# Don't use ARGV.formulae as that will throw if the file doesn't parse # Don't use ARGV.formulae as that will throw if the file doesn't parse
paths = ARGV.named.map do |name| paths = ARGV.named.map do |name|
path = Formulary.path(name) path = Formulary.path(name)
unless path.file? || ARGV.force?
raise FormulaUnavailableError, name raise FormulaUnavailableError, name unless path.file? || ARGV.force?
end
path path
end end
exec_editor(*paths) exec_editor(*paths)

View File

@ -4,9 +4,7 @@
module Homebrew module Homebrew
def mirror def mirror
if ARGV.named.empty? odie "This command requires at least formula argument!" if ARGV.named.empty?
odie "This command requires at least formula argument!"
end
bintray_user = ENV["BINTRAY_USER"] bintray_user = ENV["BINTRAY_USER"]
bintray_key = ENV["BINTRAY_KEY"] bintray_key = ENV["BINTRAY_KEY"]

View File

@ -41,12 +41,12 @@ require "pkg_version"
module Homebrew module Homebrew
def pull def pull
if ARGV[0] == "--rebase" odie "You meant `git pull --rebase`." if ARGV[0] == "--rebase"
odie "You meant `git pull --rebase`."
end
if ARGV.named.empty? if ARGV.named.empty?
odie "This command requires at least one argument containing a URL or pull request number" odie "This command requires at least one argument containing a URL or pull request number"
end end
do_bump = ARGV.include?("--bump") && !ARGV.include?("--clean") do_bump = ARGV.include?("--bump") && !ARGV.include?("--clean")
# Formulae with affected bottles that were published # Formulae with affected bottles that were published
@ -429,9 +429,9 @@ module Homebrew
# Returns nil if formula is absent or if there was an error reading it # Returns nil if formula is absent or if there was an error reading it
def self.lookup(name) def self.lookup(name)
json = Utils.popen_read(HOMEBREW_BREW_FILE, "info", "--json=v1", name) json = Utils.popen_read(HOMEBREW_BREW_FILE, "info", "--json=v1", name)
unless $?.success?
return nil return nil unless $?.success?
end
Homebrew.force_utf8!(json) Homebrew.force_utf8!(json)
FormulaInfoFromJson.new(Utils::JSON.load(json)[0]) FormulaInfoFromJson.new(Utils::JSON.load(json)[0])
end end

View File

@ -724,9 +724,7 @@ module Homebrew
coverage_args = [] coverage_args = []
if ARGV.include?("--coverage") if ARGV.include?("--coverage")
if ENV["JENKINS_HOME"] if ENV["JENKINS_HOME"]
if OS.mac? && MacOS.version == :sierra coverage_args << "--coverage" if OS.mac? && MacOS.version == :sierra
coverage_args << "--coverage"
end
else else
coverage_args << "--coverage" coverage_args << "--coverage"
end end
@ -741,9 +739,7 @@ module Homebrew
test "brew", "cask-tests", *coverage_args test "brew", "cask-tests", *coverage_args
end end
elsif @tap elsif @tap
if @tap.name == "homebrew/core" test "brew", "style", @tap.name if @tap.name == "homebrew/core"
test "brew", "style", @tap.name
end
test "brew", "readall", "--aliases", @tap.name test "brew", "readall", "--aliases", @tap.name
end end
end end
@ -1054,9 +1050,7 @@ module Homebrew
ARGV << "--junit" << "--local" << "--test-default-formula" ARGV << "--junit" << "--local" << "--test-default-formula"
end end
if ARGV.include? "--ci-master" ARGV << "--fast" if ARGV.include?("--ci-master")
ARGV << "--fast"
end
if ARGV.include? "--local" if ARGV.include? "--local"
ENV["HOMEBREW_CACHE"] = "#{ENV["HOME"]}/Library/Caches/Homebrew" ENV["HOMEBREW_CACHE"] = "#{ENV["HOME"]}/Library/Caches/Homebrew"
@ -1080,9 +1074,7 @@ module Homebrew
safe_system "brew", "tap", tap.name, "--full" safe_system "brew", "tap", tap.name, "--full"
end end
if ARGV.include? "--ci-upload" return test_ci_upload(tap) if ARGV.include?("--ci-upload")
return test_ci_upload(tap)
end
tests = [] tests = []
any_errors = false any_errors = false

View File

@ -192,15 +192,11 @@ module Stdenv
end end
def libcxx def libcxx
if compiler == :clang append "CXX", "-stdlib=libc++" if compiler == :clang
append "CXX", "-stdlib=libc++"
end
end end
def libstdcxx def libstdcxx
if compiler == :clang append "CXX", "-stdlib=libstdc++" if compiler == :clang
append "CXX", "-stdlib=libstdc++"
end
end end
# @private # @private

View File

@ -64,9 +64,7 @@ module Superenv
self["HOMEBREW_INCLUDE_PATHS"] = determine_include_paths self["HOMEBREW_INCLUDE_PATHS"] = determine_include_paths
self["HOMEBREW_LIBRARY_PATHS"] = determine_library_paths self["HOMEBREW_LIBRARY_PATHS"] = determine_library_paths
self["HOMEBREW_DEPENDENCIES"] = determine_dependencies self["HOMEBREW_DEPENDENCIES"] = determine_dependencies
unless formula.nil? self["HOMEBREW_FORMULA_PREFIX"] = formula.prefix unless formula.nil?
self["HOMEBREW_FORMULA_PREFIX"] = formula.prefix
end
# The HOMEBREW_CCCFG ENV variable is used by the ENV/cc tool to control # The HOMEBREW_CCCFG ENV variable is used by the ENV/cc tool to control
# compiler flag stripping. It consists of a string of characters which act # compiler flag stripping. It consists of a string of characters which act

View File

@ -1,5 +1,2 @@
require "blacklist" require "blacklist"
require "extend/os/mac/blacklist" if OS.mac?
if OS.mac?
require "extend/os/mac/blacklist"
end

View File

@ -1,5 +1,2 @@
require "utils/bottles" require "utils/bottles"
require "extend/os/mac/utils/bottles" if OS.mac?
if OS.mac?
require "extend/os/mac/utils/bottles"
end

View File

@ -1,5 +1,2 @@
require "cleaner" require "cleaner"
require "extend/os/mac/cleaner" if OS.mac?
if OS.mac?
require "extend/os/mac/cleaner"
end

View File

@ -1,5 +1,2 @@
require "dependency_collector" require "dependency_collector"
require "extend/os/mac/dependency_collector" if OS.mac?
if OS.mac?
require "extend/os/mac/dependency_collector"
end

View File

@ -1,5 +1,2 @@
require "development_tools" require "development_tools"
require "extend/os/mac/development_tools" if OS.mac?
if OS.mac?
require "extend/os/mac/development_tools"
end

View File

@ -1,5 +1,2 @@
require "diagnostic" require "diagnostic"
require "extend/os/mac/diagnostic" if OS.mac?
if OS.mac?
require "extend/os/mac/diagnostic"
end

View File

@ -1,6 +1,3 @@
require "os" require "os"
require "emoji" require "emoji"
require "extend/os/mac/emoji" if OS.mac?
if OS.mac?
require "extend/os/mac/emoji"
end

View File

@ -1,5 +1,2 @@
require "extend/ENV/shared" require "extend/ENV/shared"
require "extend/os/mac/extend/ENV/shared" if OS.mac?
if OS.mac?
require "extend/os/mac/extend/ENV/shared"
end

View File

@ -1,5 +1,2 @@
require "extend/ENV/std" require "extend/ENV/std"
require "extend/os/mac/extend/ENV/std" if OS.mac?
if OS.mac?
require "extend/os/mac/extend/ENV/std"
end

View File

@ -1,5 +1,2 @@
require "extend/ENV/super" require "extend/ENV/super"
require "extend/os/mac/extend/ENV/super" if OS.mac?
if OS.mac?
require "extend/os/mac/extend/ENV/super"
end

View File

@ -1,5 +1,2 @@
require "formula_cellar_checks" require "formula_cellar_checks"
require "extend/os/mac/formula_cellar_checks" if OS.mac?
if OS.mac?
require "extend/os/mac/formula_cellar_checks"
end

View File

@ -1,5 +1,2 @@
require "keg_relocate" require "keg_relocate"
require "extend/os/mac/keg_relocate" if OS.mac?
if OS.mac?
require "extend/os/mac/keg_relocate"
end

View File

@ -2,13 +2,8 @@ module SharedEnvExtension
def no_weak_imports_support? def no_weak_imports_support?
return false unless compiler == :clang return false unless compiler == :clang
if MacOS::Xcode.version && MacOS::Xcode.version < "8.0" return false if MacOS::Xcode.version && MacOS::Xcode.version < "8.0"
return false return false if MacOS::CLT.version && MacOS::CLT.version < "8.0"
end
if MacOS::CLT.version && MacOS::CLT.version < "8.0"
return false
end
true true
end end

View File

@ -1,5 +1,2 @@
require "system_config" require "system_config"
require "extend/os/mac/system_config" if OS.mac?
if OS.mac?
require "extend/os/mac/system_config"
end

View File

@ -395,9 +395,7 @@ class Formula
def oldname def oldname
@oldname ||= if tap @oldname ||= if tap
formula_renames = tap.formula_renames formula_renames = tap.formula_renames
if formula_renames.value?(name) formula_renames.to_a.rassoc(name).first if formula_renames.value?(name)
formula_renames.to_a.rassoc(name).first
end
end end
end end
@ -1776,9 +1774,7 @@ class Formula
ENV["HOMEBREW_CC_LOG_PATH"] = logfn ENV["HOMEBREW_CC_LOG_PATH"] = logfn
# TODO: system "xcodebuild" is deprecated, this should be removed soon. # TODO: system "xcodebuild" is deprecated, this should be removed soon.
if cmd.to_s.start_with? "xcodebuild" ENV.remove_cc_etc if cmd.to_s.start_with? "xcodebuild"
ENV.remove_cc_etc
end
# Turn on argument filtering in the superenv compiler wrapper. # Turn on argument filtering in the superenv compiler wrapper.
# We should probably have a better mechanism for this than adding # We should probably have a better mechanism for this than adding
@ -1786,9 +1782,7 @@ class Formula
if cmd == "python" if cmd == "python"
setup_py_in_args = %w[setup.py build.py].include?(args.first) setup_py_in_args = %w[setup.py build.py].include?(args.first)
setuptools_shim_in_args = args.any? { |a| a.to_s.start_with? "import setuptools" } setuptools_shim_in_args = args.any? { |a| a.to_s.start_with? "import setuptools" }
if setup_py_in_args || setuptools_shim_in_args ENV.refurbish_args if setup_py_in_args || setuptools_shim_in_args
ENV.refurbish_args
end
end end
$stdout.reopen(out) $stdout.reopen(out)

View File

@ -257,9 +257,7 @@ class FormulaInstaller
unless @poured_bottle unless @poured_bottle
not_pouring = !pour_bottle || @pour_failed not_pouring = !pour_bottle || @pour_failed
if not_pouring && !ignore_deps? compute_and_install_dependencies if not_pouring && !ignore_deps?
compute_and_install_dependencies
end
build build
clean clean
end end

View File

@ -52,9 +52,7 @@ class FormulaVersions
rev_list(branch) do |rev| rev_list(branch) do |rev|
formula_at_revision(rev) do |f| formula_at_revision(rev) do |f|
bottle = f.bottle_specification bottle = f.bottle_specification
unless bottle.checksums.empty? map[f.pkg_version] << bottle.rebuild unless bottle.checksums.empty?
map[f.pkg_version] << bottle.rebuild
end
end end
end end
map map

View File

@ -301,9 +301,7 @@ class Formulary
return TapLoader.new(ref) return TapLoader.new(ref)
end end
if File.extname(ref) == ".rb" return FromPathLoader.new(ref) if File.extname(ref) == ".rb"
return FromPathLoader.new(ref)
end
formula_with_that_name = core_path(ref) formula_with_that_name = core_path(ref)
if formula_with_that_name.file? if formula_with_that_name.file?
@ -311,9 +309,7 @@ class Formulary
end end
possible_alias = CoreTap.instance.alias_dir/ref possible_alias = CoreTap.instance.alias_dir/ref
if possible_alias.file? return AliasLoader.new(possible_alias) if possible_alias.file?
return AliasLoader.new(possible_alias)
end
possible_tap_formulae = tap_paths(ref) possible_tap_formulae = tap_paths(ref)
if possible_tap_formulae.size > 1 if possible_tap_formulae.size > 1

View File

@ -79,19 +79,16 @@ module Language
# if we have build flags, we have to pass them to cabal install to resolve the necessary # if we have build flags, we have to pass them to cabal install to resolve the necessary
# dependencies, and call cabal configure afterwards to set the flags again for compile # dependencies, and call cabal configure afterwards to set the flags again for compile
flags = "" flags = "--flags=#{options[:flags].join(" ")}" if options[:flags]
if options[:flags]
flags = "--flags=#{options[:flags].join(" ")}"
end
args_and_flags = args args_and_flags = args
args_and_flags << flags unless flags.empty? args_and_flags << flags unless flags.nil?
# install dependencies in the sandbox # install dependencies in the sandbox
cabal_install "--only-dependencies", *args_and_flags cabal_install "--only-dependencies", *args_and_flags
# call configure if build flags are set # call configure if build flags are set
cabal_configure flags unless flags.empty? cabal_configure flags unless flags.nil?
# install the main package in the destination dir # install the main package in the destination dir
cabal_install "--prefix=#{prefix}", *args cabal_install "--prefix=#{prefix}", *args

View File

@ -337,9 +337,7 @@ class Migrator
end end
def backup_oldname_cellar def backup_oldname_cellar
unless old_cellar.exist? FileUtils.mv(new_cellar, old_cellar) unless old_cellar.exist?
FileUtils.mv(new_cellar, old_cellar)
end
end end
def backup_old_tabs def backup_old_tabs

View File

@ -328,9 +328,9 @@ class Tab < OpenStruct
else else
s << "Built from source" s << "Built from source"
end end
if time
s << Time.at(time).strftime("on %Y-%m-%d at %H:%M:%S") s << Time.at(time).strftime("on %Y-%m-%d at %H:%M:%S") if time
end
unless used_options.empty? unless used_options.empty?
s << "with:" s << "with:"
s << used_options.to_a.join(" ") s << used_options.to_a.join(" ")

View File

@ -22,9 +22,7 @@ module Utils
return if git_available? return if git_available?
# we cannot install brewed git if homebrew/core is unavailable. # we cannot install brewed git if homebrew/core is unavailable.
unless CoreTap.instance.installed? raise "Git is unavailable" unless CoreTap.instance.installed?
raise "Git is unavailable"
end
begin begin
oh1 "Installing git" oh1 "Installing git"