Enable `Performance/ChainArrayAllocation` cop (#8404)
Merge pull request 8404
This commit is contained in:
parent
166796c448
commit
f7292ec9cc
|
|
@ -160,6 +160,8 @@ Performance/AncestorsInclude:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Performance/BigDecimalWithNumericArgument:
|
Performance/BigDecimalWithNumericArgument:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
Performance/ChainArrayAllocation:
|
||||||
|
Enabled: true
|
||||||
Performance/RedundantSortBlock:
|
Performance/RedundantSortBlock:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Performance/RedundantStringChars:
|
Performance/RedundantStringChars:
|
||||||
|
|
|
||||||
|
|
@ -139,12 +139,8 @@ module Jekyll
|
||||||
# Returns an Array of strings which represent method-specific keys.
|
# Returns an Array of strings which represent method-specific keys.
|
||||||
def content_methods
|
def content_methods
|
||||||
@content_methods ||= (
|
@content_methods ||= (
|
||||||
self.class.instance_methods \
|
self.class.instance_methods - Jekyll::Drops::Drop.instance_methods - NON_CONTENT_METHODS
|
||||||
- Jekyll::Drops::Drop.instance_methods \
|
).map!(&:to_s).tap { |result| result.reject! { |method| method.end_with?("=") } }
|
||||||
- NON_CONTENT_METHODS
|
|
||||||
).map(&:to_s).reject do |method|
|
|
||||||
method.end_with?("=")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if key exists in Drop
|
# Check if key exists in Drop
|
||||||
|
|
|
||||||
|
|
@ -76,13 +76,16 @@ module Jekyll
|
||||||
|
|
||||||
parts = [sanitized_baseurl, input]
|
parts = [sanitized_baseurl, input]
|
||||||
Addressable::URI.parse(
|
Addressable::URI.parse(
|
||||||
parts.compact.map { |part| ensure_leading_slash(part.to_s) }.join
|
parts.map! { |part| ensure_leading_slash(part.to_s) }.join
|
||||||
).normalize.to_s
|
).normalize.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def sanitized_baseurl
|
def sanitized_baseurl
|
||||||
site = @context.registers[:site]
|
site = @context.registers[:site]
|
||||||
site.config["baseurl"].to_s.chomp("/")
|
baseurl = site.config["baseurl"]
|
||||||
|
return "" if baseurl.nil?
|
||||||
|
|
||||||
|
baseurl.to_s.chomp("/")
|
||||||
end
|
end
|
||||||
|
|
||||||
def ensure_leading_slash(input)
|
def ensure_leading_slash(input)
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ module Jekyll
|
||||||
Jekyll.logger.warn set.to_s
|
Jekyll.logger.warn set.to_s
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end.compact
|
end.tap(&:compact!)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sanitizes the given path by removing a leading slash
|
# Sanitizes the given path by removing a leading slash
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ module Jekyll
|
||||||
Document.new(path,
|
Document.new(path,
|
||||||
:site => @site,
|
:site => @site,
|
||||||
:collection => @site.posts)
|
:collection => @site.posts)
|
||||||
end.reject(&:nil?)
|
end.tap(&:compact!)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def most_recent_posts
|
def most_recent_posts
|
||||||
@most_recent_posts ||= (site.posts.docs.last(11).reverse - [post]).first(10)
|
@most_recent_posts ||= (site.posts.docs.last(11).reverse! - [post]).first(10)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns Array of Converter instances.
|
# Returns Array of Converter instances.
|
||||||
def converters
|
def converters
|
||||||
@converters ||= site.converters.select { |c| c.matches(document.extname) }.sort
|
@converters ||= site.converters.select { |c| c.matches(document.extname) }.tap(&:sort!)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Determine the extname the outputted file should have
|
# Determine the extname the outputted file should have
|
||||||
|
|
@ -255,7 +255,7 @@ module Jekyll
|
||||||
def output_exts
|
def output_exts
|
||||||
@output_exts ||= converters.map do |c|
|
@output_exts ||= converters.map do |c|
|
||||||
c.output_ext(document.extname)
|
c.output_ext(document.extname)
|
||||||
end.compact
|
end.tap(&:compact!)
|
||||||
end
|
end
|
||||||
|
|
||||||
def liquid_options
|
def liquid_options
|
||||||
|
|
|
||||||
|
|
@ -310,8 +310,9 @@ module Jekyll
|
||||||
# passed in as argument.
|
# passed in as argument.
|
||||||
|
|
||||||
def instantiate_subclasses(klass)
|
def instantiate_subclasses(klass)
|
||||||
klass.descendants.select { |c| !safe || c.safe }.sort.map do |c|
|
klass.descendants.select { |c| !safe || c.safe }.tap do |result|
|
||||||
c.new(config)
|
result.sort!
|
||||||
|
result.map! { |c| c.new(config) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue