diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2015-11-26 12:39:25 -0600 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2015-11-26 12:39:25 -0600 |
commit | 404903c84e85004f1d451bf75a6b534c87efb089 (patch) | |
tree | 1354131080f43015b1416574a07e9a9e988c6ae8 | |
parent | 29eaf79e9c1b6c4e73256ad02cbd502577e6f454 (diff) | |
download | bundler-404903c84e85004f1d451bf75a6b534c87efb089.tar.gz |
[RuboCop] Enable Style/IfUnlessModifier
-rw-r--r-- | .rubocop_todo.yml | 18 | ||||
-rw-r--r-- | lib/bundler.rb | 4 | ||||
-rw-r--r-- | lib/bundler/cli/install.rb | 4 | ||||
-rw-r--r-- | lib/bundler/definition.rb | 12 | ||||
-rw-r--r-- | lib/bundler/dependency.rb | 4 | ||||
-rw-r--r-- | lib/bundler/fetcher.rb | 4 | ||||
-rw-r--r-- | lib/bundler/gem_helper.rb | 4 | ||||
-rw-r--r-- | lib/bundler/lockfile_parser.rb | 4 | ||||
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 8 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 8 | ||||
-rw-r--r-- | lib/bundler/source/git.rb | 4 | ||||
-rw-r--r-- | lib/bundler/source/git/git_proxy.rb | 4 | ||||
-rw-r--r-- | spec/support/builders.rb | 12 |
13 files changed, 18 insertions, 72 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cfd1c84066..165ef3b9d8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -102,24 +102,6 @@ Style/GlobalVars: Style/GuardClause: Enabled: false -# Offense count: 18 -# Cop supports --auto-correct. -# Configuration parameters: MaxLineLength. -Style/IfUnlessModifier: - Exclude: - - 'lib/bundler.rb' - - 'lib/bundler/cli/install.rb' - - 'lib/bundler/definition.rb' - - 'lib/bundler/dependency.rb' - - 'lib/bundler/fetcher.rb' - - 'lib/bundler/gem_helper.rb' - - 'lib/bundler/lockfile_parser.rb' - - 'lib/bundler/rubygems_integration.rb' - - 'lib/bundler/settings.rb' - - 'lib/bundler/source/git.rb' - - 'lib/bundler/source/git/git_proxy.rb' - - 'spec/support/builders.rb' - # Offense count: 2 Style/ModuleFunction: Exclude: diff --git a/lib/bundler.rb b/lib/bundler.rb index 7af59ac363..be90b0628e 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -252,9 +252,7 @@ module Bundler def requires_sudo? return @requires_sudo if defined?(@requires_sudo_ran) - if settings.allow_sudo? - sudo_present = which "sudo" - end + sudo_present = which "sudo" if settings.allow_sudo? if sudo_present # the bundle path and subdirectories need to be writable for Rubygems diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index 256ae0a7d2..df3472d70a 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -69,9 +69,7 @@ module Bundler "before deploying." end - if Bundler.app_cache.exist? - options[:local] = true - end + options[:local] = true if Bundler.app_cache.exist? Bundler.settings[:frozen] = "1" end diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index b327f25e99..7acd78ea0b 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -19,9 +19,7 @@ module Bundler unlock ||= {} gemfile = Pathname.new(gemfile).expand_path - unless gemfile.file? - raise GemfileNotFound, "#{gemfile} not found" - end + raise GemfileNotFound, "#{gemfile} not found" unless gemfile.file? Dsl.evaluate(gemfile, lockfile, unlock) end @@ -355,9 +353,7 @@ module Bundler new_deps = @dependencies - @locked_deps deleted_deps = @locked_deps - @dependencies - if new_deps.any? - added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } - end + added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any? if deleted_deps.any? deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } @@ -512,9 +508,7 @@ module Bundler def converge_dependencies (@dependencies + @locked_deps).each do |dep| - if dep.source - dep.source = sources.get(dep.source) - end + dep.source = sources.get(dep.source) if dep.source end Set.new(@dependencies) != Set.new(@locked_deps) end diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb index d629363787..153f363de5 100644 --- a/lib/bundler/dependency.rb +++ b/lib/bundler/dependency.rb @@ -65,9 +65,7 @@ module Bundler @env = options["env"] @should_include = options.fetch("should_include", true) - if options.key?("require") - @autorequire = Array(options["require"] || []) - end + @autorequire = Array(options["require"] || []) if options.key?("require") end def gem_platforms(valid_platforms) diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index 4c28746b53..5ef8817553 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -98,9 +98,7 @@ module Bundler specs = {} fetchers.dup.each do |f| - unless f.api_fetcher? && !gem_names - break if specs = f.specs(gem_names) - end + break unless f.api_fetcher? && !gem_names || !specs = f.specs(gem_names) fetchers.delete(f) end @use_api = false if fetchers.none?(&:api_fetcher?) diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb index 74db06696c..d468194538 100644 --- a/lib/bundler/gem_helper.rb +++ b/lib/bundler/gem_helper.rb @@ -177,9 +177,7 @@ module Bundler Bundler.ui.debug(cmd) SharedHelpers.chdir(base) do outbuf = `#{cmd}` - if $? == 0 - block.call(outbuf) if block - end + block.call(outbuf) if $? == 0 && block end [outbuf, $?] end diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index 5fa1f5aae0..497fbcb133 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -184,9 +184,7 @@ module Bundler end def parse_platform(line) - if line =~ /^ (.*)$/ - @platforms << Gem::Platform.new($1) - end + @platforms << Gem::Platform.new($1) if line =~ /^ (.*)$/ end def parse_bundled_with(line) diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index d4aa5af5ad..22143ec5ca 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -346,9 +346,7 @@ module Bundler redefine_method(gem_class, :bin_path) do |name, *args| exec_name = args.first - if exec_name == "bundle" - return ENV["BUNDLE_BIN_PATH"] - end + return ENV["BUNDLE_BIN_PATH"] if exec_name == "bundle" spec = nil @@ -647,9 +645,7 @@ module Bundler const_set(:CHDIR_MONITOR, EXT_LOCK) end - if const_defined?(:CHDIR_MUTEX) - remove_const(:CHDIR_MUTEX) - end + remove_const(:CHDIR_MUTEX) if const_defined?(:CHDIR_MUTEX) const_set(:CHDIR_MUTEX, const_get(:CHDIR_MONITOR)) end end diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 5d9731e9f0..1ca41e2e71 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -56,9 +56,7 @@ module Bundler def local_overrides repos = {} all.each do |k| - if k =~ /^local\./ - repos[$'] = self[k] - end + repos[$'] = self[k] if k =~ /^local\./ end repos end @@ -163,9 +161,7 @@ module Bundler private def key_for(key) - if key.is_a?(String) && /https?:/ =~ key - key = normalize_uri(key).to_s - end + key = normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key key = key.to_s.gsub(".", "__").upcase "BUNDLE_#{key}" end diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index 3a75299ff8..b11de1e4bc 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -147,9 +147,7 @@ module Bundler # TODO: actually cache git specs def specs(*) - if has_app_cache? && !local? - set_local!(app_cache_path) - end + set_local!(app_cache_path) if has_app_cache? && !local? if requires_checkout? && !@copied git_proxy.checkout diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index d7e4ff3554..b8900888a9 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -107,9 +107,7 @@ module Bundler git_retry %(fetch --force --quiet --tags "#{path}") git "reset --hard #{@revision}" - if submodules - git_retry "submodule update --init --recursive" - end + git_retry "submodule update --init --recursive" if submodules end end diff --git a/spec/support/builders.rb b/spec/support/builders.rb index 6c503c9217..4f5dace604 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -408,9 +408,7 @@ module Spec Array(versions).each do |version| spec = builder.new(self, name, version) - if !spec.authors || spec.authors.empty? - spec.authors = ["no one"] - end + spec.authors = ["no one"] if !spec.authors || spec.authors.empty? yield spec if block_given? spec._build(options) end @@ -551,9 +549,7 @@ module Spec @files["#{name}.gemspec"] = @spec.to_ruby end - unless options[:no_default] - @files = _default_files.merge(@files) - end + @files = _default_files.merge(@files) unless options[:no_default] @spec.authors = ["no one"] @@ -666,9 +662,7 @@ module Spec destination = opts[:path] || _default_path FileUtils.mkdir_p(destination) - if !@spec.authors || @spec.authors.empty? - @spec.authors = ["that guy"] - end + @spec.authors = ["that guy"] if !@spec.authors || @spec.authors.empty? Bundler.rubygems.build(@spec, opts[:skip_validation]) if opts[:to_system] |