styles: Rubocop 1.12

This commit is contained in:
Frank Taillandier 2021-03-27 16:29:18 +01:00
parent 734cf2324e
commit 6c170f11af
7 changed files with 36 additions and 44 deletions

View File

@ -286,6 +286,8 @@ Style/BisectedAttrAccessor:
Enabled: true Enabled: true
Style/CaseLikeIf: Style/CaseLikeIf:
Enabled: true Enabled: true
Style/StringChars:
Enabled: true
Style/ClassAndModuleChildren: Style/ClassAndModuleChildren:
Exclude: Exclude:
- test/**/*.rb - test/**/*.rb

View File

@ -146,8 +146,7 @@ module Jekyll
] ]
end end
@highlighter = begin @highlighter = if @config.key?("enable_coderay") && @config["enable_coderay"]
if @config.key?("enable_coderay") && @config["enable_coderay"]
Jekyll::Deprecator.deprecation_message( Jekyll::Deprecator.deprecation_message(
"You are using 'enable_coderay', " \ "You are using 'enable_coderay', " \
"use syntax_highlighter: coderay in your configuration file." "use syntax_highlighter: coderay in your configuration file."
@ -158,7 +157,6 @@ module Jekyll
@main_fallback_highlighter @main_fallback_highlighter
end end
end end
end
def strip_coderay_prefix(hash) def strip_coderay_prefix(hash)
hash.each_with_object({}) do |(key, val), hsh| hash.each_with_object({}) do |(key, val), hsh|

View File

@ -194,12 +194,10 @@ module Jekyll
@where_filter_cache[input_id][property] ||= {} @where_filter_cache[input_id][property] ||= {}
# stash or retrive results to return # stash or retrive results to return
@where_filter_cache[input_id][property][value] ||= begin @where_filter_cache[input_id][property][value] ||= input.select do |object|
input.select do |object|
compare_property_vs_target(item_property(object, property), value) compare_property_vs_target(item_property(object, property), value)
end.to_a end.to_a
end end
end
# Filters an array of objects against an expression # Filters an array of objects against an expression
# #
@ -249,11 +247,10 @@ module Jekyll
# stash or retrive results to return # stash or retrive results to return
# Since `enum.find` can return nil or false, we use a placeholder string "<__NO MATCH__>" # Since `enum.find` can return nil or false, we use a placeholder string "<__NO MATCH__>"
# to validate caching. # to validate caching.
result = @find_filter_cache[input_id][property][value] ||= begin result = @find_filter_cache[input_id][property][value] ||= input.find do |object|
input.find do |object|
compare_property_vs_target(item_property(object, property), value) compare_property_vs_target(item_property(object, property), value)
end || "<__NO MATCH__>" end || "<__NO MATCH__>"
end
return nil if result == "<__NO MATCH__>" return nil if result == "<__NO MATCH__>"
result result

View File

@ -198,12 +198,10 @@ module Jekyll
def matching_sets(path, type) def matching_sets(path, type)
@matched_set_cache ||= {} @matched_set_cache ||= {}
@matched_set_cache[path] ||= {} @matched_set_cache[path] ||= {}
@matched_set_cache[path][type] ||= begin @matched_set_cache[path][type] ||= valid_sets.select do |set|
valid_sets.select do |set|
!set.key?("scope") || applies?(set["scope"], path, type) !set.key?("scope") || applies?(set["scope"], path, type)
end end
end end
end
# Returns a list of valid sets # Returns a list of valid sets
# #

View File

@ -36,12 +36,12 @@ module Jekyll
def sanitized_path(base_directory, questionable_path) def sanitized_path(base_directory, questionable_path)
@sanitized_path ||= {} @sanitized_path ||= {}
@sanitized_path[base_directory] ||= {} @sanitized_path[base_directory] ||= {}
@sanitized_path[base_directory][questionable_path] ||= begin @sanitized_path[base_directory][questionable_path] ||= if questionable_path.nil?
if questionable_path.nil?
base_directory.freeze base_directory.freeze
else else
sanitize_and_join(base_directory, questionable_path).freeze sanitize_and_join(
end base_directory, questionable_path
).freeze
end end
end end

View File

@ -304,11 +304,11 @@ module Jekyll
# klass - The Class of the Converter to fetch. # klass - The Class of the Converter to fetch.
def find_converter_instance(klass) def find_converter_instance(klass)
@find_converter_instance ||= {} @find_converter_instance ||= {}
@find_converter_instance[klass] ||= begin @find_converter_instance[klass] ||= converters.find do |converter|
converters.find { |converter| converter.instance_of?(klass) } || \ converter.instance_of?(klass)
end || \
raise("No Converters found for #{klass}") raise("No Converters found for #{klass}")
end end
end
# klass - class or module containing the subclasses. # klass - class or module containing the subclasses.
# Returns array of instances of subclasses of parameter. # Returns array of instances of subclasses of parameter.

View File

@ -39,15 +39,12 @@ module Jekyll
# Returns source file path. # Returns source file path.
def path def path
@path ||= begin @path ||= if !@collection.nil? && !@site.config["collections_dir"].empty?
# Static file is from a collection inside custom collections directory
if !@collection.nil? && !@site.config["collections_dir"].empty?
File.join(*[@base, @site.config["collections_dir"], @dir, @name].compact) File.join(*[@base, @site.config["collections_dir"], @dir, @name].compact)
else else
File.join(*[@base, @dir, @name].compact) File.join(*[@base, @dir, @name].compact)
end end
end end
end
# Obtain destination path. # Obtain destination path.
# #