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:
- 'Taps/**/*'
- '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
# Cop supports --auto-correct.

View File

@ -108,9 +108,7 @@ module Homebrew
absolute_symlinks_start_with_string = []
keg.find do |pn|
next unless pn.symlink? && (link = pn.readlink).absolute?
if link.to_s.start_with?(string)
absolute_symlinks_start_with_string << pn
end
absolute_symlinks_start_with_string << pn if link.to_s.start_with?(string)
end
if ARGV.verbose?
@ -155,9 +153,7 @@ module Homebrew
return ofail "Formula not installed with '--build-bottle': #{f.full_name}"
end
unless f.stable
return ofail "Formula has no stable version: #{f.full_name}"
end
return ofail "Formula has no stable version: #{f.full_name}" unless f.stable
if ARGV.include?("--no-rebuild") || !f.tap
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
paths = ARGV.named.map do |name|
path = Formulary.path(name)
unless path.file? || ARGV.force?
raise FormulaUnavailableError, name
end
raise FormulaUnavailableError, name unless path.file? || ARGV.force?
path
end
exec_editor(*paths)

View File

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

View File

@ -41,12 +41,12 @@ require "pkg_version"
module Homebrew
def pull
if ARGV[0] == "--rebase"
odie "You meant `git pull --rebase`."
end
odie "You meant `git pull --rebase`." if ARGV[0] == "--rebase"
if ARGV.named.empty?
odie "This command requires at least one argument containing a URL or pull request number"
end
do_bump = ARGV.include?("--bump") && !ARGV.include?("--clean")
# 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
def self.lookup(name)
json = Utils.popen_read(HOMEBREW_BREW_FILE, "info", "--json=v1", name)
unless $?.success?
return nil
end
return nil unless $?.success?
Homebrew.force_utf8!(json)
FormulaInfoFromJson.new(Utils::JSON.load(json)[0])
end

View File

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

View File

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

View File

@ -64,9 +64,7 @@ module Superenv
self["HOMEBREW_INCLUDE_PATHS"] = determine_include_paths
self["HOMEBREW_LIBRARY_PATHS"] = determine_library_paths
self["HOMEBREW_DEPENDENCIES"] = determine_dependencies
unless formula.nil?
self["HOMEBREW_FORMULA_PREFIX"] = formula.prefix
end
self["HOMEBREW_FORMULA_PREFIX"] = formula.prefix unless formula.nil?
# 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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -301,9 +301,7 @@ class Formulary
return TapLoader.new(ref)
end
if File.extname(ref) == ".rb"
return FromPathLoader.new(ref)
end
return FromPathLoader.new(ref) if File.extname(ref) == ".rb"
formula_with_that_name = core_path(ref)
if formula_with_that_name.file?
@ -311,9 +309,7 @@ class Formulary
end
possible_alias = CoreTap.instance.alias_dir/ref
if possible_alias.file?
return AliasLoader.new(possible_alias)
end
return AliasLoader.new(possible_alias) if possible_alias.file?
possible_tap_formulae = tap_paths(ref)
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
# dependencies, and call cabal configure afterwards to set the flags again for compile
flags = ""
if options[:flags]
flags = "--flags=#{options[:flags].join(" ")}"
end
flags = "--flags=#{options[:flags].join(" ")}" if options[:flags]
args_and_flags = args
args_and_flags << flags unless flags.empty?
args_and_flags << flags unless flags.nil?
# install dependencies in the sandbox
cabal_install "--only-dependencies", *args_and_flags
# 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
cabal_install "--prefix=#{prefix}", *args

View File

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

View File

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

View File

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