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
|
||||
Performance/BigDecimalWithNumericArgument:
|
||||
Enabled: true
|
||||
Performance/ChainArrayAllocation:
|
||||
Enabled: true
|
||||
Performance/RedundantSortBlock:
|
||||
Enabled: true
|
||||
Performance/RedundantStringChars:
|
||||
|
|
|
@ -139,12 +139,8 @@ module Jekyll
|
|||
# Returns an Array of strings which represent method-specific keys.
|
||||
def content_methods
|
||||
@content_methods ||= (
|
||||
self.class.instance_methods \
|
||||
- Jekyll::Drops::Drop.instance_methods \
|
||||
- NON_CONTENT_METHODS
|
||||
).map(&:to_s).reject do |method|
|
||||
method.end_with?("=")
|
||||
end
|
||||
self.class.instance_methods - Jekyll::Drops::Drop.instance_methods - NON_CONTENT_METHODS
|
||||
).map!(&:to_s).tap { |result| result.reject! { |method| method.end_with?("=") } }
|
||||
end
|
||||
|
||||
# Check if key exists in Drop
|
||||
|
|
|
@ -76,13 +76,16 @@ module Jekyll
|
|||
|
||||
parts = [sanitized_baseurl, input]
|
||||
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
|
||||
end
|
||||
|
||||
def sanitized_baseurl
|
||||
site = @context.registers[:site]
|
||||
site.config["baseurl"].to_s.chomp("/")
|
||||
baseurl = site.config["baseurl"]
|
||||
return "" if baseurl.nil?
|
||||
|
||||
baseurl.to_s.chomp("/")
|
||||
end
|
||||
|
||||
def ensure_leading_slash(input)
|
||||
|
|
|
@ -223,7 +223,7 @@ module Jekyll
|
|||
Jekyll.logger.warn set.to_s
|
||||
nil
|
||||
end
|
||||
end.compact
|
||||
end.tap(&:compact!)
|
||||
end
|
||||
|
||||
# Sanitizes the given path by removing a leading slash
|
||||
|
|
|
@ -57,7 +57,7 @@ module Jekyll
|
|||
Document.new(path,
|
||||
:site => @site,
|
||||
:collection => @site.posts)
|
||||
end.reject(&:nil?)
|
||||
end.tap(&:compact!)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -46,7 +46,7 @@ module Jekyll
|
|||
end
|
||||
|
||||
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
|
||||
|
|
|
@ -36,7 +36,7 @@ module Jekyll
|
|||
#
|
||||
# Returns Array of Converter instances.
|
||||
def converters
|
||||
@converters ||= site.converters.select { |c| c.matches(document.extname) }.sort
|
||||
@converters ||= site.converters.select { |c| c.matches(document.extname) }.tap(&:sort!)
|
||||
end
|
||||
|
||||
# Determine the extname the outputted file should have
|
||||
|
@ -255,7 +255,7 @@ module Jekyll
|
|||
def output_exts
|
||||
@output_exts ||= converters.map do |c|
|
||||
c.output_ext(document.extname)
|
||||
end.compact
|
||||
end.tap(&:compact!)
|
||||
end
|
||||
|
||||
def liquid_options
|
||||
|
|
|
@ -310,8 +310,9 @@ module Jekyll
|
|||
# passed in as argument.
|
||||
|
||||
def instantiate_subclasses(klass)
|
||||
klass.descendants.select { |c| !safe || c.safe }.sort.map do |c|
|
||||
c.new(config)
|
||||
klass.descendants.select { |c| !safe || c.safe }.tap do |result|
|
||||
result.sort!
|
||||
result.map! { |c| c.new(config) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue