summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-01-14 16:34:08 -0600
committerSamuel Giddins <segiddins@segiddins.me>2016-01-31 22:21:13 -0600
commitb1afbe3a2ff7623c9a0e8504bc85af4bd8156059 (patch)
tree832de2112b4c7a44d081302eec030c74448c3712
parent8b64c9785abfcdafe1e8420f61d51e924ba434a1 (diff)
downloadbundler-b1afbe3a2ff7623c9a0e8504bc85af4bd8156059.tar.gz
[RuboCop] Fix Style/MutableConstant
-rw-r--r--.rubocop_todo.yml15
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/cli/gem.rb2
-rw-r--r--lib/bundler/endpoint_specification.rb1
-rw-r--r--lib/bundler/fetcher.rb14
-rw-r--r--lib/bundler/gem_helpers.rb4
-rw-r--r--lib/bundler/lockfile_parser.rb23
-rw-r--r--lib/bundler/runtime.rb2
-rw-r--r--lib/bundler/settings.rb2
-rw-r--r--lib/bundler/source/path.rb3
-rw-r--r--lib/bundler/ui/shell.rb2
-rw-r--r--lib/bundler/version.rb3
-rw-r--r--spec/bundler/fetcher/dependency_spec.rb12
-rw-r--r--spec/bundler/source_spec.rb4
-rw-r--r--spec/bundler/ssl_certs/certificate_manager_spec.rb8
-rw-r--r--spec/support/artifice/compact_index.rb12
-rw-r--r--spec/support/artifice/compact_index_creds_diff_host.rb7
17 files changed, 52 insertions, 64 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 13189d9c44..8911c030e3 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -183,21 +183,6 @@ Style/ModuleFunction:
Style/MultilineMethodCallIndentation:
Enabled: false
-# Offense count: 24
-# Cop supports --auto-correct.
-Style/MutableConstant:
- Exclude:
- - 'lib/bundler/cli.rb'
- - 'lib/bundler/cli/gem.rb'
- - 'lib/bundler/fetcher.rb'
- - 'lib/bundler/gem_helpers.rb'
- - 'lib/bundler/lockfile_parser.rb'
- - 'lib/bundler/runtime.rb'
- - 'lib/bundler/settings.rb'
- - 'lib/bundler/source/path.rb'
- - 'lib/bundler/ui/shell.rb'
- - 'lib/bundler/version.rb'
-
# Offense count: 8
Style/NestedParenthesizedCalls:
Exclude:
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index b6eb708f32..77eab33ddc 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -4,7 +4,7 @@ require "bundler/vendored_thor"
module Bundler
class CLI < Thor
include Thor::Actions
- AUTO_INSTALL_CMDS = %w(show binstubs outdated exec open console licenses clean)
+ AUTO_INSTALL_CMDS = %w(show binstubs outdated exec open console licenses clean).freeze
def self.start(*)
super
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index 8c306d5e88..343a458719 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -5,7 +5,7 @@ module Bundler
TEST_FRAMEWORK_VERSIONS = {
"rspec" => "3.0",
"minitest" => "5.0"
- }
+ }.freeze
attr_reader :options, :gem_name, :thor, :name, :target
diff --git a/lib/bundler/endpoint_specification.rb b/lib/bundler/endpoint_specification.rb
index a571e0f2f2..b26fdaf9cc 100644
--- a/lib/bundler/endpoint_specification.rb
+++ b/lib/bundler/endpoint_specification.rb
@@ -1,3 +1,4 @@
+# frozen_string_literal: true
module Bundler
# used for Creating Specifications from the Gemcutter Endpoint
class EndpointSpecification < Gem::Specification
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
index 8c9da09684..63f61070e3 100644
--- a/lib/bundler/fetcher.rb
+++ b/lib/bundler/fetcher.rb
@@ -53,13 +53,13 @@ module Bundler
# Exceptions classes that should bypass retry attempts. If your password didn't work the
# first time, it's not going to the third time.
- FAIL_ERRORS = [AuthenticationRequiredError, BadAuthenticationError, FallbackError]
+ FAIL_ERRORS = [AuthenticationRequiredError, BadAuthenticationError, FallbackError].freeze
NET_ERRORS = [:HTTPBadGateway, :HTTPBadRequest, :HTTPFailedDependency,
:HTTPForbidden, :HTTPInsufficientStorage, :HTTPMethodNotAllowed,
:HTTPMovedPermanently, :HTTPNoContent, :HTTPNotFound,
:HTTPNotImplemented, :HTTPPreconditionFailed, :HTTPRequestEntityTooLarge,
:HTTPRequestURITooLong, :HTTPUnauthorized, :HTTPUnprocessableEntity,
- :HTTPUnsupportedMediaType, :HTTPVersionNotSupported]
+ :HTTPUnsupportedMediaType, :HTTPVersionNotSupported].freeze
FAIL_ERRORS << Gem::Requirement::BadRequirementError if defined?(Gem::Requirement::BadRequirementError)
FAIL_ERRORS.push(*NET_ERRORS.map {|e| SharedHelpers.const_get_safely(e, Net) }.compact)
@@ -150,10 +150,10 @@ module Bundler
fetchers.shift until fetchers.first.available?
- if remote_uri.scheme == "file" || Bundler::Fetcher.disable_endpoint
- @use_api = false
+ @use_api = if remote_uri.scheme == "file" || Bundler::Fetcher.disable_endpoint
+ false
else
- @use_api = fetchers.first.api_fetcher?
+ fetchers.first.api_fetcher?
end
end
@@ -207,7 +207,7 @@ module Bundler
private
- FETCHERS = [CompactIndex, Dependency, Index]
+ FETCHERS = [CompactIndex, Dependency, Index].freeze
def cis
env_cis = {
@@ -267,7 +267,7 @@ module Bundler
Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EAGAIN,
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
Net::HTTP::Persistent::Error, Zlib::BufError
- ]
+ ].freeze
def bundler_cert_store
store = OpenSSL::X509::Store.new
diff --git a/lib/bundler/gem_helpers.rb b/lib/bundler/gem_helpers.rb
index 146998957d..6e43caef1a 100644
--- a/lib/bundler/gem_helpers.rb
+++ b/lib/bundler/gem_helpers.rb
@@ -1,6 +1,6 @@
module Bundler
module GemHelpers
- GENERIC_CACHE = {}
+ GENERIC_CACHE = {}.freeze
GENERICS = [
[Gem::Platform.new("java"), Gem::Platform.new("java")],
[Gem::Platform.new("mswin32"), Gem::Platform.new("mswin32")],
@@ -9,7 +9,7 @@ module Bundler
[Gem::Platform.new("x64-mingw32"), Gem::Platform.new("x64-mingw32")],
[Gem::Platform.new("x86_64-mingw32"), Gem::Platform.new("x64-mingw32")],
[Gem::Platform.new("mingw32"), Gem::Platform.new("x86-mingw32")]
- ]
+ ].freeze
def generic(p)
return p if p == Gem::Platform::RUBY
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index f802157cca..94e88dbd0c 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -1,3 +1,4 @@
+# frozen_string_literal: true
require "strscan"
# Some versions of the Bundler 1.1 RC series introduced corrupted
@@ -14,16 +15,16 @@ module Bundler
class LockfileParser
attr_reader :sources, :dependencies, :specs, :platforms, :bundler_version, :ruby_version
- BUNDLED = "BUNDLED WITH"
- DEPENDENCIES = "DEPENDENCIES"
- PLATFORMS = "PLATFORMS"
- RUBY = "RUBY VERSION"
- GIT = "GIT"
- GEM = "GEM"
- PATH = "PATH"
- SPECS = " specs:"
+ BUNDLED = "BUNDLED WITH".freeze
+ DEPENDENCIES = "DEPENDENCIES".freeze
+ PLATFORMS = "PLATFORMS".freeze
+ RUBY = "RUBY VERSION".freeze
+ GIT = "GIT".freeze
+ GEM = "GEM".freeze
+ PATH = "PATH".freeze
+ SPECS = " specs:".freeze
OPTIONS = /^ ([a-z]+): (.*)$/i
- SOURCE = [GIT, GEM, PATH]
+ SOURCE = [GIT, GEM, PATH].freeze
def initialize(lockfile)
@platforms = []
@@ -89,7 +90,7 @@ module Bundler
GIT => Bundler::Source::Git,
GEM => Bundler::Source::Rubygems,
PATH => Bundler::Source::Path,
- }
+ }.freeze
def parse_source(line)
case line
@@ -134,7 +135,7 @@ module Bundler
end
end
- NAME_VERSION = '(?! )(.*?)(?: \(([^-]*)(?:-(.*))?\))?'
+ NAME_VERSION = '(?! )(.*?)(?: \(([^-]*)(?:-(.*))?\))?'.freeze
NAME_VERSION_2 = /^ {2}#{NAME_VERSION}(!)?$/
NAME_VERSION_4 = /^ {4}#{NAME_VERSION}$/
NAME_VERSION_6 = /^ {6}#{NAME_VERSION}$/
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index a663026251..fff8a748af 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -52,7 +52,7 @@ module Bundler
/^Missing API definition file in (.+)$/i,
/^cannot load such file -- (.+)$/i,
/^dlopen\([^)]*\): Library not loaded: (.+)$/i,
- ]
+ ].freeze
def require(*groups)
groups.map!(&:to_sym)
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index 31f1fdd7f2..8e0c2282ed 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -4,7 +4,7 @@ module Bundler
class Settings
BOOL_KEYS = %w(frozen cache_all no_prune disable_local_branch_check disable_shared_gems ignore_messages gem.mit gem.coc silence_root_warning).freeze
NUMBER_KEYS = %w(retry timeout redirect ssl_verify_mode).freeze
- DEFAULT_CONFIG = { :retry => 3, :timeout => 10, :redirect => 5 }
+ DEFAULT_CONFIG = { :retry => 3, :timeout => 10, :redirect => 5 }.freeze
def initialize(root = nil)
@root = root
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index 605aa5ae71..6f2fe2c1eb 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -1,3 +1,4 @@
+# frozen_string_literal: true
module Bundler
class Source
class Path < Source
@@ -7,7 +8,7 @@ module Bundler
attr_writer :name
attr_accessor :version
- DEFAULT_GLOB = "{,*,*/*}.gemspec"
+ DEFAULT_GLOB = "{,*,*/*}.gemspec".freeze
def initialize(options)
@options = options
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb
index 2c0076dc06..51919a8a5f 100644
--- a/lib/bundler/ui/shell.rb
+++ b/lib/bundler/ui/shell.rb
@@ -3,7 +3,7 @@ require "bundler/vendored_thor"
module Bundler
module UI
class Shell
- LEVELS = %w(silent error warn confirm info debug)
+ LEVELS = %w(silent error warn confirm info debug).freeze
attr_writer :shell
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index 9a3c7dde22..5ea959b980 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -1,6 +1,7 @@
+# frozen_string_literal: true
module Bundler
# We're doing this because we might write tests that deal
# with other versions of bundler and we are unsure how to
# handle this better.
- VERSION = "1.12.0.pre" unless defined?(::Bundler::VERSION)
+ VERSION = "1.12.0.pre".freeze unless defined?(::Bundler::VERSION)
end
diff --git a/spec/bundler/fetcher/dependency_spec.rb b/spec/bundler/fetcher/dependency_spec.rb
index b78d82b98b..43c496507e 100644
--- a/spec/bundler/fetcher/dependency_spec.rb
+++ b/spec/bundler/fetcher/dependency_spec.rb
@@ -92,7 +92,7 @@ describe Bundler::Fetcher::Dependency do
it "should return a hash with the remote_uri and the list of specs" do
expect(subject.specs(gem_names, full_dependency_list, last_spec_list)).to eq([
["top", gem_version2, "ruby", faraday],
- ["boulder", gem_version1, "ruby", resque]
+ ["boulder", gem_version1, "ruby", resque],
])
end
end
@@ -225,20 +225,20 @@ describe Bundler::Fetcher::Dependency do
[
{
:dependencies => {
- "resque" => "req3,req4"
+ "resque" => "req3,req4",
},
:name => "typhoeus",
:number => "1.0.1",
- :platform => "ruby"
+ :platform => "ruby",
},
{
:dependencies => {
- "faraday" => "req1,req2"
+ "faraday" => "req1,req2",
},
:name => "grape",
:number => "2.0.2",
- :platform => "jruby"
- }
+ :platform => "jruby",
+ },
]
end
diff --git a/spec/bundler/source_spec.rb b/spec/bundler/source_spec.rb
index 5e1fb0ad9d..5033354ff6 100644
--- a/spec/bundler/source_spec.rb
+++ b/spec/bundler/source_spec.rb
@@ -85,7 +85,7 @@ describe Bundler::Source do
let(:spec) { double(:spec, :source => subject) }
it "should return true" do
- expect(subject.can_lock? spec).to be_truthy
+ expect(subject.can_lock?(spec)).to be_truthy
end
end
@@ -93,7 +93,7 @@ describe Bundler::Source do
let(:spec) { double(:spec, :source => double(:other_source)) }
it "should return false" do
- expect(subject.can_lock? spec).to be_falsey
+ expect(subject.can_lock?(spec)).to be_falsey
end
end
end
diff --git a/spec/bundler/ssl_certs/certificate_manager_spec.rb b/spec/bundler/ssl_certs/certificate_manager_spec.rb
index 57c071dafc..81423ccf90 100644
--- a/spec/bundler/ssl_certs/certificate_manager_spec.rb
+++ b/spec/bundler/ssl_certs/certificate_manager_spec.rb
@@ -3,8 +3,8 @@ require "bundler/ssl_certs/certificate_manager"
describe Bundler::SSLCerts::CertificateManager do
let(:rubygems_path) { root }
- let(:stub_cert) { File.join("#{root}", "lib", "rubygems", "ssl_certs", "ssl-cert.pem") }
- let(:rubygems_certs_dir) { File.join("#{root}", "lib", "rubygems", "ssl_certs") }
+ let(:stub_cert) { File.join(root.to_s, "lib", "rubygems", "ssl_certs", "ssl-cert.pem") }
+ let(:rubygems_certs_dir) { File.join(root.to_s, "lib", "rubygems", "ssl_certs") }
subject { described_class.new(rubygems_path) }
@@ -15,7 +15,7 @@ describe Bundler::SSLCerts::CertificateManager do
end
after do
- rubygems_dir = File.join("#{root}", "lib", "rubygems")
+ rubygems_dir = File.join(root.to_s, "lib", "rubygems")
FileUtils.rm_rf(rubygems_dir)
end
@@ -50,7 +50,7 @@ describe Bundler::SSLCerts::CertificateManager do
describe "#up_to_date?" do
context "when bundler certs and rubygems certs are the same" do
before do
- bundler_certs = Dir[File.join("#{root}", "lib", "bundler", "ssl_certs", "*.pem")]
+ bundler_certs = Dir[File.join(root.to_s, "lib", "bundler", "ssl_certs", "*.pem")]
FileUtils.rm(stub_cert)
FileUtils.cp(bundler_certs, rubygems_certs_dir)
end
diff --git a/spec/support/artifice/compact_index.rb b/spec/support/artifice/compact_index.rb
index e7dfda3bea..eb17f01905 100644
--- a/spec/support/artifice/compact_index.rb
+++ b/spec/support/artifice/compact_index.rb
@@ -1,6 +1,7 @@
+# frozen_string_literal: true
require File.expand_path("../endpoint", __FILE__)
-$LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/compact_index*/lib")].first}"
+$LOAD_PATH.unshift Dir[base_system_gems.join("gems/compact_index*/lib")].first.to_s
require "compact_index"
class CompactIndexAPI < Endpoint
@@ -28,11 +29,10 @@ class CompactIndexAPI < Endpoint
def not_modified?(checksum)
etags = parse_etags(request.env["HTTP_IF_NONE_MATCH"])
- if etags.include?(checksum)
- headers "ETag" => quote(checksum)
- status 304
- body ""
- end
+ return unless etags.include?(checksum)
+ headers "ETag" => quote(checksum)
+ status 304
+ body ""
end
def requested_range_for(response_body)
diff --git a/spec/support/artifice/compact_index_creds_diff_host.rb b/spec/support/artifice/compact_index_creds_diff_host.rb
index 6a56c508a2..2e8cd46b5e 100644
--- a/spec/support/artifice/compact_index_creds_diff_host.rb
+++ b/spec/support/artifice/compact_index_creds_diff_host.rb
@@ -13,10 +13,9 @@ class CompactIndexCredsDiffHost < CompactIndexAPI
end
def protected!
- unless authorized?
- response["WWW-Authenticate"] = %(Basic realm="Testing HTTP Auth")
- throw(:halt, [401, "Not authorized\n"])
- end
+ return if authorized?
+ response["WWW-Authenticate"] = %(Basic realm="Testing HTTP Auth")
+ throw(:halt, [401, "Not authorized\n"])
end
end