diff --git a/.rubocop.yml b/.rubocop.yml index 54886a93..49c69dcc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -286,6 +286,8 @@ Style/BisectedAttrAccessor: Enabled: true Style/CaseLikeIf: Enabled: true +Style/StringChars: + Enabled: true Style/ClassAndModuleChildren: Exclude: - test/**/*.rb diff --git a/lib/jekyll/converters/markdown/kramdown_parser.rb b/lib/jekyll/converters/markdown/kramdown_parser.rb index 35b663f2..3aab42e0 100644 --- a/lib/jekyll/converters/markdown/kramdown_parser.rb +++ b/lib/jekyll/converters/markdown/kramdown_parser.rb @@ -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) diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index 86253e44..63116b1b 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -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 diff --git a/lib/jekyll/frontmatter_defaults.rb b/lib/jekyll/frontmatter_defaults.rb index 3b0d0059..5ad896b2 100644 --- a/lib/jekyll/frontmatter_defaults.rb +++ b/lib/jekyll/frontmatter_defaults.rb @@ -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 diff --git a/lib/jekyll/path_manager.rb b/lib/jekyll/path_manager.rb index 941d1673..5d975222 100644 --- a/lib/jekyll/path_manager.rb +++ b/lib/jekyll/path_manager.rb @@ -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 diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 7be4349e..bf35d087 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -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. diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index aa970333..327545ce 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -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.