[rubygems/rubygems] util/rubocop -A --only Style/ClassCheck
https://github.com/rubygems/rubygems/commit/1c3356a872
This commit is contained in:
parent
567db6064b
commit
0b632b9cdd
@ -26,7 +26,7 @@ class Gem::AvailableSet
|
|||||||
s = o.set
|
s = o.set
|
||||||
when Array
|
when Array
|
||||||
s = o.map do |sp,so|
|
s = o.map do |sp,so|
|
||||||
if !sp.kind_of?(Gem::Specification) || !so.kind_of?(Gem::Source)
|
if !sp.is_a?(Gem::Specification) || !so.is_a?(Gem::Source)
|
||||||
raise TypeError, "Array must be in [[spec, source], ...] form"
|
raise TypeError, "Array must be in [[spec, source], ...] form"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class Gem::Command
|
|||||||
# array or a string to be split on white space.
|
# array or a string to be split on white space.
|
||||||
|
|
||||||
def self.add_specific_extra_args(cmd,args)
|
def self.add_specific_extra_args(cmd,args)
|
||||||
args = args.split(/\s+/) if args.kind_of? String
|
args = args.split(/\s+/) if args.is_a? String
|
||||||
specific_extra_args_hash[cmd] = args
|
specific_extra_args_hash[cmd] = args
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ if you believe they were disclosed to a third party.
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
content = Gem::SafeYAML.load(File.read(filename))
|
content = Gem::SafeYAML.load(File.read(filename))
|
||||||
unless content.kind_of? Hash
|
unless content.is_a? Hash
|
||||||
warn "Failed to load #{filename} because it doesn't contain valid YAML hash"
|
warn "Failed to load #{filename} because it doesn't contain valid YAML hash"
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
@ -36,7 +36,7 @@ module Kernel
|
|||||||
skip_list = (ENV["GEM_SKIP"] || "").split(/:/)
|
skip_list = (ENV["GEM_SKIP"] || "").split(/:/)
|
||||||
raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
|
raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
|
||||||
|
|
||||||
if gem_name.kind_of? Gem::Dependency
|
if gem_name.is_a? Gem::Dependency
|
||||||
unless Gem::Deprecate.skip
|
unless Gem::Deprecate.skip
|
||||||
warn "#{Gem.location_of_caller.join ":"}:Warning: Kernel.gem no longer "\
|
warn "#{Gem.location_of_caller.join ":"}:Warning: Kernel.gem no longer "\
|
||||||
"accepts a Gem::Dependency object, please pass the name "\
|
"accepts a Gem::Dependency object, please pass the name "\
|
||||||
|
@ -103,7 +103,7 @@ module Gem::Deprecate
|
|||||||
old = "_deprecated_#{name}"
|
old = "_deprecated_#{name}"
|
||||||
alias_method old, name
|
alias_method old, name
|
||||||
define_method name do |*args, &block|
|
define_method name do |*args, &block|
|
||||||
klass = self.kind_of? Module
|
klass = self.is_a? Module
|
||||||
target = klass ? "#{self}." : "#{self.class}#"
|
target = klass ? "#{self}." : "#{self.class}#"
|
||||||
msg = [ "NOTE: #{target}#{name} is deprecated",
|
msg = [ "NOTE: #{target}#{name} is deprecated",
|
||||||
repl == :none ? " with no replacement" : "; use #{repl} instead",
|
repl == :none ? " with no replacement" : "; use #{repl} instead",
|
||||||
@ -128,7 +128,7 @@ module Gem::Deprecate
|
|||||||
old = "_deprecated_#{name}"
|
old = "_deprecated_#{name}"
|
||||||
alias_method old, name
|
alias_method old, name
|
||||||
define_method name do |*args, &block|
|
define_method name do |*args, &block|
|
||||||
klass = self.kind_of? Module
|
klass = self.is_a? Module
|
||||||
target = klass ? "#{self}." : "#{self.class}#"
|
target = klass ? "#{self}." : "#{self.class}#"
|
||||||
msg = [ "NOTE: #{target}#{name} is deprecated",
|
msg = [ "NOTE: #{target}#{name} is deprecated",
|
||||||
replacement == :none ? " with no replacement" : "; use #{replacement} instead",
|
replacement == :none ? " with no replacement" : "; use #{replacement} instead",
|
||||||
|
@ -116,7 +116,7 @@ module Gem::GemcutterUtilities
|
|||||||
end
|
end
|
||||||
|
|
||||||
def mfa_unauthorized?(response)
|
def mfa_unauthorized?(response)
|
||||||
response.kind_of?(Net::HTTPUnauthorized) && response.body.start_with?("You have enabled multifactor authentication")
|
response.is_a?(Net::HTTPUnauthorized) && response.body.start_with?("You have enabled multifactor authentication")
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_scope(scope)
|
def update_scope(scope)
|
||||||
@ -319,6 +319,6 @@ module Gem::GemcutterUtilities
|
|||||||
end
|
end
|
||||||
|
|
||||||
def api_key_forbidden?(response)
|
def api_key_forbidden?(response)
|
||||||
response.kind_of?(Net::HTTPForbidden) && response.body.start_with?("The API key doesn't have access")
|
response.is_a?(Net::HTTPForbidden) && response.body.start_with?("The API key doesn't have access")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,7 @@ class Gem::NameTuple
|
|||||||
@name = name
|
@name = name
|
||||||
@version = version
|
@version = version
|
||||||
|
|
||||||
unless platform.kind_of? Gem::Platform
|
unless platform.is_a? Gem::Platform
|
||||||
platform = "ruby" if !platform || platform.empty?
|
platform = "ruby" if !platform || platform.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ class Gem::RequestSet::GemDependencyAPI
|
|||||||
# Use the given tag for git:, gist: and github: dependencies.
|
# Use the given tag for git:, gist: and github: dependencies.
|
||||||
|
|
||||||
def gem(name, *requirements)
|
def gem(name, *requirements)
|
||||||
options = requirements.pop if requirements.last.kind_of?(Hash)
|
options = requirements.pop if requirements.last.is_a?(Hash)
|
||||||
options ||= {}
|
options ||= {}
|
||||||
|
|
||||||
options[:git] = @current_repository if @current_repository
|
options[:git] = @current_repository if @current_repository
|
||||||
|
@ -24,7 +24,7 @@ class Gem::Resolver::InstalledSpecification < Gem::Resolver::SpecSpecification
|
|||||||
def installable_platform?
|
def installable_platform?
|
||||||
# BACKCOMPAT If the file is coming out of a specified file, then we
|
# BACKCOMPAT If the file is coming out of a specified file, then we
|
||||||
# ignore the platform. This code can be removed in RG 3.0.
|
# ignore the platform. This code can be removed in RG 3.0.
|
||||||
return true if @source.kind_of? Gem::Source::SpecificFile
|
return true if @source.is_a? Gem::Source::SpecificFile
|
||||||
|
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
@ -7,7 +7,7 @@ class Gem::Resolver::LocalSpecification < Gem::Resolver::SpecSpecification
|
|||||||
# Returns +true+ if this gem is installable for the current platform.
|
# Returns +true+ if this gem is installable for the current platform.
|
||||||
|
|
||||||
def installable_platform?
|
def installable_platform?
|
||||||
return true if @source.kind_of? Gem::Source::SpecificFile
|
return true if @source.is_a? Gem::Source::SpecificFile
|
||||||
|
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
@ -126,7 +126,7 @@ class Gem::SourceList
|
|||||||
# Gem::Source or a source URI.
|
# Gem::Source or a source URI.
|
||||||
|
|
||||||
def include?(other)
|
def include?(other)
|
||||||
if other.kind_of? Gem::Source
|
if other.is_a? Gem::Source
|
||||||
@sources.include? other
|
@sources.include? other
|
||||||
else
|
else
|
||||||
@sources.find {|x| x.uri.to_s == other.to_s }
|
@sources.find {|x| x.uri.to_s == other.to_s }
|
||||||
@ -137,7 +137,7 @@ class Gem::SourceList
|
|||||||
# Deletes +source+ from the source list which may be a Gem::Source or a URI.
|
# Deletes +source+ from the source list which may be a Gem::Source or a URI.
|
||||||
|
|
||||||
def delete(source)
|
def delete(source)
|
||||||
if source.kind_of? Gem::Source
|
if source.is_a? Gem::Source
|
||||||
@sources.delete source
|
@sources.delete source
|
||||||
else
|
else
|
||||||
@sources.delete_if {|x| x.uri.to_s == source.to_s }
|
@sources.delete_if {|x| x.uri.to_s == source.to_s }
|
||||||
|
@ -125,7 +125,7 @@ class Gem::SpecificationPolicy
|
|||||||
|
|
||||||
metadata.each do |key, value|
|
metadata.each do |key, value|
|
||||||
entry = "metadata['#{key}']"
|
entry = "metadata['#{key}']"
|
||||||
if !key.kind_of?(String)
|
if !key.is_a?(String)
|
||||||
error "metadata keys must be a String"
|
error "metadata keys must be a String"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ class Gem::SpecificationPolicy
|
|||||||
error "metadata key is too large (#{key.size} > 128)"
|
error "metadata key is too large (#{key.size} > 128)"
|
||||||
end
|
end
|
||||||
|
|
||||||
if !value.kind_of?(String)
|
if !value.is_a?(String)
|
||||||
error "#{entry} value must be a String"
|
error "#{entry} value must be a String"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
|
|||||||
String
|
String
|
||||||
end
|
end
|
||||||
|
|
||||||
unless Array === val && val.all? {|x| x.kind_of?(klass) }
|
unless Array === val && val.all? {|x| x.is_a?(klass) }
|
||||||
error "#{field} must be an Array of #{klass}"
|
error "#{field} must be an Array of #{klass}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -54,7 +54,7 @@ class Gem::FakeFetcher
|
|||||||
raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
|
raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
|
||||||
end
|
end
|
||||||
|
|
||||||
if @data[path].kind_of?(Array)
|
if @data[path].is_a?(Array)
|
||||||
@data[path].shift
|
@data[path].shift
|
||||||
else
|
else
|
||||||
@data[path]
|
@data[path]
|
||||||
@ -64,7 +64,7 @@ class Gem::FakeFetcher
|
|||||||
def create_response(uri)
|
def create_response(uri)
|
||||||
data = find_data(uri)
|
data = find_data(uri)
|
||||||
response = data.respond_to?(:call) ? data.call : data
|
response = data.respond_to?(:call) ? data.call : data
|
||||||
raise TypeError, "#{response.class} is not a type of Net::HTTPResponse" unless response.kind_of?(Net::HTTPResponse)
|
raise TypeError, "#{response.class} is not a type of Net::HTTPResponse" unless response.is_a?(Net::HTTPResponse)
|
||||||
|
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user