diff options
author | Samuel E. Giddins <segiddins@segiddins.me> | 2015-07-15 20:51:16 -0700 |
---|---|---|
committer | Samuel E. Giddins <segiddins@segiddins.me> | 2015-07-15 20:51:16 -0700 |
commit | af694073229af89af205d24ff449f51f74316a37 (patch) | |
tree | 5258cd3a3832bcc21eaa3249c99cdf410a8f9d0a | |
parent | c85c0c9c642dcdccb7d769d7d9a56d51ad314915 (diff) | |
download | bundler-af694073229af89af205d24ff449f51f74316a37.tar.gz |
[RuboCop] Enable Style/SymbolProc
-rw-r--r-- | .rubocop_todo.yml | 6 | ||||
-rw-r--r-- | lib/bundler.rb | 2 | ||||
-rw-r--r-- | lib/bundler/cli/console.rb | 2 | ||||
-rw-r--r-- | lib/bundler/cli/install.rb | 4 | ||||
-rw-r--r-- | lib/bundler/cli/outdated.rb | 2 | ||||
-rw-r--r-- | lib/bundler/cli/show.rb | 4 | ||||
-rw-r--r-- | lib/bundler/cli/update.rb | 2 | ||||
-rw-r--r-- | lib/bundler/definition.rb | 16 | ||||
-rw-r--r-- | lib/bundler/dependency.rb | 2 | ||||
-rw-r--r-- | lib/bundler/dsl.rb | 2 | ||||
-rw-r--r-- | lib/bundler/graph.rb | 2 | ||||
-rw-r--r-- | lib/bundler/index.rb | 4 | ||||
-rw-r--r-- | lib/bundler/installer.rb | 2 | ||||
-rw-r--r-- | lib/bundler/lazy_specification.rb | 2 | ||||
-rw-r--r-- | lib/bundler/lockfile_parser.rb | 4 | ||||
-rw-r--r-- | lib/bundler/resolver.rb | 2 | ||||
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 2 | ||||
-rw-r--r-- | lib/bundler/runtime.rb | 4 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 2 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 6 | ||||
-rw-r--r-- | lib/bundler/spec_set.rb | 6 | ||||
-rw-r--r-- | lib/bundler/worker.rb | 4 | ||||
-rw-r--r-- | spec/install/force_spec.rb | 2 | ||||
-rw-r--r-- | spec/quality_spec.rb | 4 | ||||
-rw-r--r-- | spec/support/helpers.rb | 2 | ||||
-rw-r--r-- | spec/support/indexes.rb | 6 | ||||
-rw-r--r-- | spec/support/streams.rb | 2 |
27 files changed, 45 insertions, 53 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f63e112095..c88b42da1b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -493,12 +493,6 @@ Style/StringLiterals: Style/StringLiteralsInInterpolation: Enabled: false -# Offense count: 45 -# Cop supports --auto-correct. -# Configuration parameters: IgnoredMethods. -Style/SymbolProc: - Enabled: false - # Offense count: 14 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. diff --git a/lib/bundler.rb b/lib/bundler.rb index 496047f67a..d46c4394e2 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -437,7 +437,7 @@ module Bundler ENV['GEM_PATH'] = '' elsif blank_home || Bundler.rubygems.gem_dir != bundle_path.to_s possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path] - paths = possibles.flatten.compact.uniq.reject { |p| p.empty? } + paths = possibles.flatten.compact.uniq.reject(&:empty?) ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR) end diff --git a/lib/bundler/cli/console.rb b/lib/bundler/cli/console.rb index eee3baba76..92bf848b47 100644 --- a/lib/bundler/cli/console.rb +++ b/lib/bundler/cli/console.rb @@ -7,7 +7,7 @@ module Bundler end def run - group ? Bundler.require(:default, *(group.split.map! {|g| g.to_sym })) : Bundler.require + group ? Bundler.require(:default, *(group.split.map!(&:to_sym))) : Bundler.require ARGV.clear console = get_console(Bundler.settings[:console] || 'irb') diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index 8b9d8ebb24..128f9d6f2a 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -29,11 +29,11 @@ module Bundler Bundler.settings.without = [] if options[:without] && options[:without].empty? with = options.fetch("with", []) - with |= Bundler.settings.with.map {|group| group.to_s } + with |= Bundler.settings.with.map(&:to_s) with -= options[:without] if options[:without] without = options.fetch("without", []) - without |= Bundler.settings.without.map {|group| group.to_s } + without |= Bundler.settings.without.map(&:to_s) without -= options[:with] if options[:with] options[:with] = with diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 1612adf897..94dd032a9d 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -41,7 +41,7 @@ module Bundler if options["strict"] active_spec = definition.specs.detect { |spec| spec.name == current_spec.name } else - active_spec = definition.index[current_spec.name].sort_by { |b| b.version } + active_spec = definition.index[current_spec.name].sort_by(&:version) if !current_spec.version.prerelease? && !options[:pre] && active_spec.size > 1 active_spec = active_spec.delete_if { |b| b.respond_to?(:version) && b.version.prerelease? } end diff --git a/lib/bundler/cli/show.rb b/lib/bundler/cli/show.rb index 96c1490209..161e931c72 100644 --- a/lib/bundler/cli/show.rb +++ b/lib/bundler/cli/show.rb @@ -31,12 +31,12 @@ module Bundler end if options[:paths] - Bundler.load.specs.sort_by { |s| s.name }.map do |s| + Bundler.load.specs.sort_by(&:name).map do |s| Bundler.ui.info s.full_gem_path end else Bundler.ui.info "Gems included by the bundle:" - Bundler.load.specs.sort_by { |s| s.name }.each do |s| + Bundler.load.specs.sort_by(&:name).each do |s| desc = " * #{s.name} (#{s.version}#{s.git_version})" if @verbose latest = latest_specs.find { |l| l.name == s.name } diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb index 5bcc89bab3..ee61c34445 100644 --- a/lib/bundler/cli/update.rb +++ b/lib/bundler/cli/update.rb @@ -21,7 +21,7 @@ module Bundler "Run `bundle install` to update and install the bundled gems." end # cycle through the requested gems, just to make sure they exist - names = Bundler.locked_gems.specs.map{ |s| s.name } + names = Bundler.locked_gems.specs.map(&:name) gems.each do |g| next if names.include?(g) require "bundler/cli/common" diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 40781f4155..9c84d350d2 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -91,7 +91,7 @@ module Bundler @path_changes = converge_paths eager_unlock = expand_dependencies(@unlock[:gems]) - @unlock[:gems] = @locked_specs.for(eager_unlock).map { |s| s.name } + @unlock[:gems] = @locked_specs.for(eager_unlock).map(&:name) @source_changes = converge_sources @dependency_changes = converge_dependencies @@ -169,7 +169,7 @@ module Bundler def requested_specs @requested_specs ||= begin groups = requested_groups - groups.map! { |g| g.to_sym } + groups.map!(&:to_sym) specs_for(groups) end end @@ -203,7 +203,7 @@ module Bundler def index @index ||= Index.build do |idx| - dependency_names = @dependencies.map { |d| d.name } + dependency_names = @dependencies.map(&:name) sources.all_sources.each do |source| source.dependency_names = dependency_names.dup @@ -237,7 +237,7 @@ module Bundler end def groups - dependencies.map { |d| d.groups }.flatten.uniq + dependencies.map(&:groups).flatten.uniq end def lock(file, preserve_bundled_with = false) @@ -292,7 +292,7 @@ module Bundler # This needs to be sorted by full name so that # gems with the same name, but different platform # are ordered consistently - sort_by { |s| s.full_name }. + sort_by(&:full_name). each do |spec| next if spec.name == 'bundler' out << spec.to_lock @@ -302,7 +302,7 @@ module Bundler out << "PLATFORMS\n" - platforms.map { |p| p.to_s }.sort.each do |p| + platforms.map(&:to_s).sort.each do |p| out << " #{p}\n" end @@ -311,7 +311,7 @@ module Bundler handled = [] dependencies. - sort_by { |d| d.to_s }. + sort_by(&:to_s). each do |dep| next if handled.include?(dep.name) out << dep.to_lock @@ -620,7 +620,7 @@ module Bundler def requested_dependencies groups = requested_groups - groups.map! { |g| g.to_sym } + groups.map!(&:to_sym) dependencies.reject { |d| !d.should_include? || (d.groups & groups).empty? } end diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb index e58ed4b7d5..d02bbeeaaf 100644 --- a/lib/bundler/dependency.rb +++ b/lib/bundler/dependency.rb @@ -51,7 +51,7 @@ module Bundler super(name, version, type) @autorequire = nil - @groups = Array(options["group"] || :default).map { |g| g.to_sym } + @groups = Array(options["group"] || :default).map(&:to_sym) @source = options["source"] @platforms = Array(options["platforms"]) @env = options["env"] diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 31f82a5145..037bea44b1 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -273,7 +273,7 @@ module Bundler platforms = @platforms.dup opts["platforms"] = opts["platform"] || opts["platforms"] platforms.concat Array(opts.delete("platforms")) - platforms.map! { |p| p.to_sym } + platforms.map!(&:to_sym) platforms.each do |p| next if VALID_PLATFORMS.include?(p) raise GemfileError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}" diff --git a/lib/bundler/graph.rb b/lib/bundler/graph.rb index 244e3e9b99..5138a1378e 100644 --- a/lib/bundler/graph.rb +++ b/lib/bundler/graph.rb @@ -107,7 +107,7 @@ module Bundler } end - matches = matches.sort_by { |s| s.sort_obj } # HACK: shouldn't be needed + matches = matches.sort_by(&:sort_obj) # HACK: shouldn't be needed end end end diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb index acd3a7b9be..5789fd8d4f 100644 --- a/lib/bundler/index.rb +++ b/lib/bundler/index.rb @@ -36,7 +36,7 @@ module Bundler end def inspect - "#<#{self.class}:0x#{object_id} sources=#{sources.map{|s| s.inspect}} specs.size=#{specs.size}>" + "#<#{self.class}:0x#{object_id} sources=#{sources.map(&:inspect)} specs.size=#{specs.size}>" end def empty? @@ -104,7 +104,7 @@ module Bundler def dependency_names names = [] - each{|s| names.push(*s.dependencies.map{|d| d.name }) } + each{|s| names.push(*s.dependencies.map(&:name)) } names.uniq end diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index fc6249dc23..38869c09f1 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -222,7 +222,7 @@ module Bundler if groups.empty? specs = @definition.requested_specs else - specs = @definition.specs_for groups.map { |g| g.to_sym } + specs = @definition.specs_for groups.map(&:to_sym) end specs.each do |spec| diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index e8f73095cf..43d9dc993d 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -41,7 +41,7 @@ module Bundler out = " #{name} (#{version}-#{platform})\n" end - dependencies.sort_by {|d| d.to_s }.uniq.each do |dep| + dependencies.sort_by(&:to_s).uniq.each do |dep| next if dep.type == :development out << " #{dep.to_lock}\n" end diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index aff5f9a9de..c5d860c2ab 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -138,7 +138,7 @@ module Bundler def parse_dependency(line) if line =~ NAME_VERSION_2 name, version, pinned = $1, $2, $4 - version = version.split(",").map { |d| d.strip } if version + version = version.split(",").map(&:strip) if version dep = Bundler::Dependency.new(name, version) @@ -172,7 +172,7 @@ module Bundler @specs[@current_spec.identifier] ||= @current_spec elsif line =~ NAME_VERSION_6 name, version = $1, $2 - version = version.split(',').map { |d| d.strip } if version + version = version.split(',').map(&:strip) if version dep = Gem::Dependency.new(name, version) @current_spec.dependencies << dep end diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 2acf746e48..78711b23f1 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -331,7 +331,7 @@ module Bundler "Try running `bundle update #{requirement.name}`" elsif requirement.source name = requirement.name - versions = @source_requirements[name][name].map { |s| s.version } + versions = @source_requirements[name][name].map(&:version) message = "Could not find gem '#{requirement}' in #{requirement.source}.\n" if versions.any? message << "Source contains '#{name}' at: #{versions.join(', ')}" diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index ac5e6d629c..6cd1570cad 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -266,7 +266,7 @@ module Bundler def replace_gem(specs) reverse_rubygems_kernel_mixin - executables = specs.map { |s| s.executables }.flatten + executables = specs.map(&:executables).flatten ::Kernel.send(:define_method, :gem) do |dep, *reqs| if executables.include? File.basename(caller.first.split(':').first) diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index 1364f670ea..8736bba656 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -5,7 +5,7 @@ module Bundler include SharedHelpers def setup(*groups) - groups.map! { |g| g.to_sym } + groups.map!(&:to_sym) # Has to happen first clean_load_path @@ -55,7 +55,7 @@ module Bundler ] def require(*groups) - groups.map! { |g| g.to_sym } + groups.map!(&:to_sym) groups = [:default] if groups.empty? @definition.dependencies.each do |dep| diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index c2f3ab6a28..1c2ef6e635 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -193,7 +193,7 @@ module Bundler end def get_array(key) - self[key] ? self[key].split(":").map { |w| w.to_sym } : [] + self[key] ? self[key].split(":").map(&:to_sym) : [] end def set_array(key, array) diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 2cc613136f..29efd68f54 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -52,7 +52,7 @@ module Bundler end def options - { "remotes" => @remotes.map { |r| r.to_s } } + { "remotes" => @remotes.map(&:to_s) } end def self.from_lock(options) @@ -68,7 +68,7 @@ module Bundler end def to_s - remote_names = self.remotes.map { |r| r.to_s }.join(', ') + remote_names = self.remotes.map(&:to_s).join(', ') "rubygems repository #{remote_names}" end alias_method :name, :to_s @@ -108,7 +108,7 @@ module Bundler if spec.remote # Check for this spec from other sources uris = [spec.remote.anonymized_uri] - uris += remotes_for_spec(spec).map { |remote| remote.anonymized_uri } + uris += remotes_for_spec(spec).map(&:anonymized_uri) uris.uniq! Installer.ambiguous_gems << [spec.name, *uris] if uris.length > 1 diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index 74975a5225..42962df259 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -10,7 +10,7 @@ module Bundler def_delegators :sorted, :each def initialize(specs) - @specs = specs.sort_by { |s| s.name } + @specs = specs.sort_by(&:name) end def for(dependencies, skip = [], check = false, match_current_platform = false) @@ -81,7 +81,7 @@ module Bundler def materialize(deps, missing_specs = nil) materialized = self.for(deps, [], false, true).to_a - deps = materialized.map {|s| s.name }.uniq + deps = materialized.map(&:name).uniq materialized.map! do |s| next s unless s.is_a?(LazySpecification) s.source.dependency_names = deps if s.source.respond_to?(:dependency_names=) @@ -145,7 +145,7 @@ module Bundler end def tsort_each_child(s) - s.dependencies.sort_by { |d| d.name }.each do |d| + s.dependencies.sort_by(&:name).each do |d| next if d.type == :development lookup[d.name].each { |s2| yield s2 } end diff --git a/lib/bundler/worker.rb b/lib/bundler/worker.rb index d5d3b19508..531e597915 100644 --- a/lib/bundler/worker.rb +++ b/lib/bundler/worker.rb @@ -61,11 +61,11 @@ module Bundler # so as worker threads after retrieving it, shut themselves down def stop_threads @threads.each { @request_queue.enq POISON } - @threads.each { |thread| thread.join } + @threads.each(&:join) end def abort_threads - @threads.each {|i| i.exit } + @threads.each(&:exit) exit 1 end end diff --git a/spec/install/force_spec.rb b/spec/install/force_spec.rb index 344694ed8e..4991e84e89 100644 --- a/spec/install/force_spec.rb +++ b/spec/install/force_spec.rb @@ -19,7 +19,7 @@ describe "bundle install" do expect(exitstatus).to eq(0) if exitstatus expect(out).to include "Using bundler" expect(out).to include "Installing rack 1.0.0" - expect(rack_lib.open{|f| f.read }).to eq("RACK = '1.0.0'\n") + expect(rack_lib.open(&:read)).to eq("RACK = '1.0.0'\n") should_be_installed "rack 1.0.0" end diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index b84e543670..d136844543 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -43,9 +43,7 @@ describe "The library itself" do end RSpec::Matchers.define :be_well_formed do - match do |actual| - actual.empty? - end + match(&:empty?) failure_message do |actual| actual.join("\n") diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 12bfaaa2e9..d074a5e0bb 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -33,7 +33,7 @@ module Spec opts = args.last.is_a?(Hash) ? args.pop : {} expect_err = opts.delete(:expect_err) env = opts.delete(:env) - groups = args.map {|a| a.inspect }.join(", ") + groups = args.map(&:inspect).join(", ") setup = "require 'rubygems' ; require 'bundler' ; Bundler.setup(#{groups})\n" @out = ruby(setup + cmd, :expect_err => expect_err, :env => env) end diff --git a/spec/support/indexes.rb b/spec/support/indexes.rb index 436d4bbb7c..ea549aaccb 100644 --- a/spec/support/indexes.rb +++ b/spec/support/indexes.rb @@ -25,13 +25,13 @@ module Spec def should_resolve_as(specs) got = resolve - got = got.map { |s| s.full_name }.sort + got = got.map(&:full_name).sort expect(got).to eq(specs.sort) end def should_resolve_and_include(specs) got = resolve - got = got.map { |s| s.full_name }.sort + got = got.map(&:full_name).sort specs.each do |s| expect(got).to include(s) end @@ -40,7 +40,7 @@ module Spec def should_conflict_on(names) begin got = resolve - flunk "The resolve succeeded with: #{got.map { |s| s.full_name }.sort.inspect}" + flunk "The resolve succeeded with: #{got.map(&:full_name).sort.inspect}" rescue Bundler::VersionConflict => e expect(Array(names).sort).to eq(e.conflicts.sort) end diff --git a/spec/support/streams.rb b/spec/support/streams.rb index 610e99986a..10e1d44cf5 100644 --- a/spec/support/streams.rb +++ b/spec/support/streams.rb @@ -1,7 +1,7 @@ require 'stringio' def capture(*streams) - streams.map! { |stream| stream.to_s } + streams.map!(&:to_s) begin result = StringIO.new streams.each { |stream| eval "$#{stream} = result" } |