diff options
| author | Markus Reiter | 2016-09-23 11:01:40 +0200 | 
|---|---|---|
| committer | Markus Reiter | 2016-09-23 15:30:07 +0200 | 
| commit | fe2d51e0b9d4d9c138e512c245b1ed8d0f1dbf53 (patch) | |
| tree | 24c62806b60d59b0f9a689ac693a7afec5bd3291 | |
| parent | a5b11a6a5c7e29b9040f93fd211f52479507dd01 (diff) | |
| download | brew-fe2d51e0b9d4d9c138e512c245b1ed8d0f1dbf53.tar.bz2 | |
Fix Style/IfUnlessModifier.
30 files changed, 49 insertions, 162 deletions
diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index c6e126a9e..80fa07aab 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -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. diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 797828e0e..b2aa3b2c5 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -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 diff --git a/Library/Homebrew/dev-cmd/edit.rb b/Library/Homebrew/dev-cmd/edit.rb index f80d05861..2d2a5ec08 100644 --- a/Library/Homebrew/dev-cmd/edit.rb +++ b/Library/Homebrew/dev-cmd/edit.rb @@ -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) diff --git a/Library/Homebrew/dev-cmd/mirror.rb b/Library/Homebrew/dev-cmd/mirror.rb index 162008123..9966163f8 100644 --- a/Library/Homebrew/dev-cmd/mirror.rb +++ b/Library/Homebrew/dev-cmd/mirror.rb @@ -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"] diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index 7f027e159..b06719fb1 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -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 diff --git a/Library/Homebrew/dev-cmd/test-bot.rb b/Library/Homebrew/dev-cmd/test-bot.rb index d63f88a1c..ba78cdb59 100644 --- a/Library/Homebrew/dev-cmd/test-bot.rb +++ b/Library/Homebrew/dev-cmd/test-bot.rb @@ -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 diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index a9b2358b1..c1111b840 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -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 diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 4169905df..39ff4b8f8 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -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 diff --git a/Library/Homebrew/extend/os/blacklist.rb b/Library/Homebrew/extend/os/blacklist.rb index f72c7c643..932040f82 100644 --- a/Library/Homebrew/extend/os/blacklist.rb +++ b/Library/Homebrew/extend/os/blacklist.rb @@ -1,5 +1,2 @@  require "blacklist" - -if OS.mac? -  require "extend/os/mac/blacklist" -end +require "extend/os/mac/blacklist" if OS.mac? diff --git a/Library/Homebrew/extend/os/bottles.rb b/Library/Homebrew/extend/os/bottles.rb index aff9300de..146b807a4 100644 --- a/Library/Homebrew/extend/os/bottles.rb +++ b/Library/Homebrew/extend/os/bottles.rb @@ -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? diff --git a/Library/Homebrew/extend/os/cleaner.rb b/Library/Homebrew/extend/os/cleaner.rb index 868ff2d33..6b94cdf5a 100644 --- a/Library/Homebrew/extend/os/cleaner.rb +++ b/Library/Homebrew/extend/os/cleaner.rb @@ -1,5 +1,2 @@  require "cleaner" - -if OS.mac? -  require "extend/os/mac/cleaner" -end +require "extend/os/mac/cleaner" if OS.mac? diff --git a/Library/Homebrew/extend/os/dependency_collector.rb b/Library/Homebrew/extend/os/dependency_collector.rb index d295263f6..56fcad31d 100644 --- a/Library/Homebrew/extend/os/dependency_collector.rb +++ b/Library/Homebrew/extend/os/dependency_collector.rb @@ -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? diff --git a/Library/Homebrew/extend/os/development_tools.rb b/Library/Homebrew/extend/os/development_tools.rb index 7b590dc8b..5bd5cb81a 100644 --- a/Library/Homebrew/extend/os/development_tools.rb +++ b/Library/Homebrew/extend/os/development_tools.rb @@ -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? diff --git a/Library/Homebrew/extend/os/diagnostic.rb b/Library/Homebrew/extend/os/diagnostic.rb index 0c844743b..f8f53b1f4 100644 --- a/Library/Homebrew/extend/os/diagnostic.rb +++ b/Library/Homebrew/extend/os/diagnostic.rb @@ -1,5 +1,2 @@  require "diagnostic" - -if OS.mac? -  require "extend/os/mac/diagnostic" -end +require "extend/os/mac/diagnostic" if OS.mac? diff --git a/Library/Homebrew/extend/os/emoji.rb b/Library/Homebrew/extend/os/emoji.rb index fe3e7f44e..8fd99e1d3 100644 --- a/Library/Homebrew/extend/os/emoji.rb +++ b/Library/Homebrew/extend/os/emoji.rb @@ -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? diff --git a/Library/Homebrew/extend/os/extend/ENV/shared.rb b/Library/Homebrew/extend/os/extend/ENV/shared.rb index 676159b37..e9574eb58 100644 --- a/Library/Homebrew/extend/os/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/os/extend/ENV/shared.rb @@ -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? diff --git a/Library/Homebrew/extend/os/extend/ENV/std.rb b/Library/Homebrew/extend/os/extend/ENV/std.rb index 320f9981f..8e6b13a61 100644 --- a/Library/Homebrew/extend/os/extend/ENV/std.rb +++ b/Library/Homebrew/extend/os/extend/ENV/std.rb @@ -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? diff --git a/Library/Homebrew/extend/os/extend/ENV/super.rb b/Library/Homebrew/extend/os/extend/ENV/super.rb index fd4e93c22..27c49eb84 100644 --- a/Library/Homebrew/extend/os/extend/ENV/super.rb +++ b/Library/Homebrew/extend/os/extend/ENV/super.rb @@ -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? diff --git a/Library/Homebrew/extend/os/formula_cellar_checks.rb b/Library/Homebrew/extend/os/formula_cellar_checks.rb index 4e30cd791..66b5b80d3 100644 --- a/Library/Homebrew/extend/os/formula_cellar_checks.rb +++ b/Library/Homebrew/extend/os/formula_cellar_checks.rb @@ -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? diff --git a/Library/Homebrew/extend/os/keg_relocate.rb b/Library/Homebrew/extend/os/keg_relocate.rb index 2fde45d93..25a74286a 100644 --- a/Library/Homebrew/extend/os/keg_relocate.rb +++ b/Library/Homebrew/extend/os/keg_relocate.rb @@ -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? diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/shared.rb b/Library/Homebrew/extend/os/mac/extend/ENV/shared.rb index 866204024..67a3944c3 100644 --- a/Library/Homebrew/extend/os/mac/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/os/mac/extend/ENV/shared.rb @@ -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 diff --git a/Library/Homebrew/extend/os/system_config.rb b/Library/Homebrew/extend/os/system_config.rb index cf7b69cb6..edc007166 100644 --- a/Library/Homebrew/extend/os/system_config.rb +++ b/Library/Homebrew/extend/os/system_config.rb @@ -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? diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index cd1890a43..7a5584cdf 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index f63ecdcb9..6e8f2e3b7 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -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 diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb index ec2e2a459..81e15d314 100644 --- a/Library/Homebrew/formula_versions.rb +++ b/Library/Homebrew/formula_versions.rb @@ -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 diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 74f669413..a6ec45d3c 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -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 diff --git a/Library/Homebrew/language/haskell.rb b/Library/Homebrew/language/haskell.rb index b5d0e1220..4b7f88a99 100644 --- a/Library/Homebrew/language/haskell.rb +++ b/Library/Homebrew/language/haskell.rb @@ -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 diff --git a/Library/Homebrew/migrator.rb b/Library/Homebrew/migrator.rb index d31025119..d8c06de1a 100644 --- a/Library/Homebrew/migrator.rb +++ b/Library/Homebrew/migrator.rb @@ -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 diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 12b23cc73..379f2e8a4 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -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(" ") diff --git a/Library/Homebrew/utils/git.rb b/Library/Homebrew/utils/git.rb index 837cc22e4..dfe47f890 100644 --- a/Library/Homebrew/utils/git.rb +++ b/Library/Homebrew/utils/git.rb @@ -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"  | 
