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,18 +146,16 @@ 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." )
)
"coderay" "coderay"
else else
@main_fallback_highlighter @main_fallback_highlighter
end end
end
end end
def strip_coderay_prefix(hash) def strip_coderay_prefix(hash)

View File

@ -194,11 +194,9 @@ 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,10 +198,8 @@ 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

View File

@ -36,13 +36,13 @@ 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(
sanitize_and_join(base_directory, questionable_path).freeze base_directory, questionable_path
end ).freeze
end end
end end
private private

View File

@ -304,10 +304,10 @@ 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)
raise("No Converters found for #{klass}") end || \
end raise("No Converters found for #{klass}")
end end
# klass - class or module containing the subclasses. # klass - class or module containing the subclasses.

View File

@ -39,14 +39,11 @@ 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 File.join(*[@base, @site.config["collections_dir"], @dir, @name].compact)
if !@collection.nil? && !@site.config["collections_dir"].empty? else
File.join(*[@base, @site.config["collections_dir"], @dir, @name].compact) File.join(*[@base, @dir, @name].compact)
else end
File.join(*[@base, @dir, @name].compact)
end
end
end end
# Obtain destination path. # Obtain destination path.