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
Style/CaseLikeIf:
Enabled: true
Style/StringChars:
Enabled: true
Style/ClassAndModuleChildren:
Exclude:
- test/**/*.rb

View File

@ -146,18 +146,16 @@ module Jekyll
]
end
@highlighter = begin
if @config.key?("enable_coderay") && @config["enable_coderay"]
Jekyll::Deprecator.deprecation_message(
"You are using 'enable_coderay', " \
"use syntax_highlighter: coderay in your configuration file."
)
@highlighter = if @config.key?("enable_coderay") && @config["enable_coderay"]
Jekyll::Deprecator.deprecation_message(
"You are using 'enable_coderay', " \
"use syntax_highlighter: coderay in your configuration file."
)
"coderay"
else
@main_fallback_highlighter
end
end
"coderay"
else
@main_fallback_highlighter
end
end
def strip_coderay_prefix(hash)

View File

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

View File

@ -198,10 +198,8 @@ module Jekyll
def matching_sets(path, type)
@matched_set_cache ||= {}
@matched_set_cache[path] ||= {}
@matched_set_cache[path][type] ||= begin
valid_sets.select do |set|
!set.key?("scope") || applies?(set["scope"], path, type)
end
@matched_set_cache[path][type] ||= valid_sets.select do |set|
!set.key?("scope") || applies?(set["scope"], path, type)
end
end

View File

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

View File

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

View File

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