From 31dd0ebed5faa79d68307222403de85db9177f16 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 14:39:01 -0800 Subject: [PATCH 01/37] Rubocop: Style/EmptyLiteral - Use array literal [] instead of Array.new - Use hash literal {} instead of Hash.new --- lib/jekyll.rb | 2 +- lib/jekyll/collection.rb | 6 +++--- lib/jekyll/commands/doctor.rb | 2 +- lib/jekyll/document.rb | 2 +- lib/jekyll/readers/page_reader.rb | 2 +- lib/jekyll/readers/static_file_reader.rb | 2 +- lib/jekyll/static_file.rb | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 3d33e52c..24448c26 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -95,7 +95,7 @@ module Jekyll # list of option names and their defaults. # # Returns the final configuration Hash. - def configuration(override = Hash.new) + def configuration(override = {}) config = Configuration[Configuration::DEFAULTS] override = Configuration[override].stringify_keys unless override.delete('skip_config_files') diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index f74ccf6f..a68fbfec 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -76,7 +76,7 @@ module Jekyll # Returns an Array of file paths to the documents in this collection # relative to the collection's directory def entries - return Array.new unless exists? + return [] unless exists? @entries ||= Utils.safe_glob(collection_dir, ["**", "*.*"]).map do |entry| entry["#{collection_dir}/"] = ''; entry @@ -88,7 +88,7 @@ module Jekyll # # Returns a list of filtered entry paths. def filtered_entries - return Array.new unless exists? + return [] unless exists? @filtered_entries ||= Dir.chdir(directory) do entry_filter.filter(entries).reject do |f| @@ -195,7 +195,7 @@ module Jekyll # Returns the metadata for this collection def extract_metadata if site.config['collections'].is_a?(Hash) - site.config['collections'][label] || Hash.new + site.config['collections'][label] || {} else {} end diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index 02e1967d..8ce2c473 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -105,7 +105,7 @@ module Jekyll end def case_insensitive_urls(things, destination) - things.inject(Hash.new) do |memo, thing| + things.inject({}) do |memo, thing| dest = thing.destination(destination) (memo[dest.downcase] ||= []) << dest memo diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 14a0a92e..c906e149 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -52,7 +52,7 @@ module Jekyll # Returns a Hash containing the data. An empty hash is returned if # no data was read. def data - @data ||= Hash.new + @data ||= {} end # Merge some data in with this document's data. diff --git a/lib/jekyll/readers/page_reader.rb b/lib/jekyll/readers/page_reader.rb index 099ebf13..12e70748 100644 --- a/lib/jekyll/readers/page_reader.rb +++ b/lib/jekyll/readers/page_reader.rb @@ -4,7 +4,7 @@ module Jekyll def initialize(site, dir) @site = site @dir = dir - @unfiltered_content = Array.new + @unfiltered_content = [] end # Read all the files in // for Yaml header and create a new Page diff --git a/lib/jekyll/readers/static_file_reader.rb b/lib/jekyll/readers/static_file_reader.rb index 279bea46..b95981a8 100644 --- a/lib/jekyll/readers/static_file_reader.rb +++ b/lib/jekyll/readers/static_file_reader.rb @@ -4,7 +4,7 @@ module Jekyll def initialize(site, dir) @site = site @dir = dir - @unfiltered_content = Array.new + @unfiltered_content = [] end # Read all the files in // for Yaml header and create a new Page diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index 48fa34c5..6f24f7d2 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -1,7 +1,7 @@ module Jekyll class StaticFile # The cache of last modification times [path] -> mtime. - @@mtimes = Hash.new + @@mtimes = {} attr_reader :relative_path, :extname @@ -90,7 +90,7 @@ module Jekyll # # Returns nothing. def self.reset_cache - @@mtimes = Hash.new + @@mtimes = {} nil end From 44d2995277276e3e34ae2931a90c29b291c0ca8b Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 14:40:45 -0800 Subject: [PATCH 02/37] Rubocop: Style/Semicolon - Do not use semicolons to terminate expressions --- lib/jekyll/collection.rb | 3 ++- lib/jekyll/commands/serve.rb | 3 ++- lib/jekyll/tags/include.rb | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index a68fbfec..9b9f6593 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -79,7 +79,8 @@ module Jekyll return [] unless exists? @entries ||= Utils.safe_glob(collection_dir, ["**", "*.*"]).map do |entry| - entry["#{collection_dir}/"] = ''; entry + entry["#{collection_dir}/"] = '' + entry end end diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index aa8fc6a8..4dad7600 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -168,7 +168,8 @@ module Jekyll raise RuntimeError, "--ssl-cert or --ssl-key missing." end - require "openssl"; require "webrick/https" + require "openssl" + require "webrick/https" source_key = Jekyll.sanitized_path(opts[:JekyllOptions]["source"], opts[:JekyllOptions]["ssl_key" ]) source_certificate = Jekyll.sanitized_path(opts[:JekyllOptions]["source"], opts[:JekyllOptions]["ssl_cert"]) opts[:SSLCertificate] = OpenSSL::X509::Certificate.new(File.read(source_certificate)) diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index 2e39738e..6082a4cc 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -25,7 +25,7 @@ module Jekyll @file = matched['variable'].strip @params = matched['params'].strip else - @file, @params = markup.strip.split(' ', 2); + @file, @params = markup.strip.split(' ', 2) end validate_params if @params @tag_name = tag_name From 0eae36aec2b6ce7043277ff463e780b4e85fbf78 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 14:41:49 -0800 Subject: [PATCH 03/37] Rubocop: Style/LineEndConcatenation - Use \ instead of + or << to concatenate those strings --- lib/jekyll/commands/doctor.rb | 10 ++++----- lib/jekyll/configuration.rb | 38 +++++++++++++++++------------------ lib/jekyll/filters.rb | 2 +- lib/jekyll/hooks.rb | 2 +- lib/jekyll/plugin_manager.rb | 4 ++-- lib/jekyll/site.rb | 8 ++++---- lib/jekyll/tags/highlight.rb | 2 +- lib/jekyll/tags/post_url.rb | 6 +++--- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index 8ce2c473..a29cbf7e 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -39,8 +39,8 @@ module Jekyll def deprecated_relative_permalinks(site) if site.config['relative_permalinks'] - Jekyll::Deprecator.deprecation_message "Your site still uses relative" + - " permalinks, which was removed in" + + Jekyll::Deprecator.deprecation_message "Your site still uses relative" \ + " permalinks, which was removed in" \ " Jekyll v3.0.0." return true end @@ -54,7 +54,7 @@ module Jekyll urls.each do |url, paths| if paths.size > 1 conflicting_urls = true - Jekyll.logger.warn "Conflict:", "The URL '#{url}' is the destination" + + Jekyll.logger.warn "Conflict:", "The URL '#{url}' is the destination" \ " for the following pages: #{paths.join(", ")}" end end @@ -83,8 +83,8 @@ module Jekyll urls.each do |case_insensitive_url, real_urls| if real_urls.uniq.size > 1 urls_only_differ_by_case = true - Jekyll.logger.warn "Warning:", "The following URLs only differ" + - " by case. On a case-insensitive file system one of the URLs" + + Jekyll.logger.warn "Warning:", "The following URLs only differ" \ + " by case. On a case-insensitive file system one of the URLs" \ " will be overwritten by the other: #{real_urls.join(", ")}" end end diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index e01f798c..21929f3f 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -173,7 +173,7 @@ module Jekyll configuration = Utils.deep_merge_hashes(configuration, new_config) end rescue ArgumentError => err - Jekyll.logger.warn "WARNING:", "Error reading configuration. " + + Jekyll.logger.warn "WARNING:", "Error reading configuration. " \ "Using defaults (and options)." $stderr.puts "#{err}" end @@ -198,16 +198,16 @@ module Jekyll config = clone # Provide backwards-compatibility if config.key?('auto') || config.key?('watch') - Jekyll::Deprecator.deprecation_message "Auto-regeneration can no longer" + - " be set from your configuration file(s). Use the"+ + Jekyll::Deprecator.deprecation_message "Auto-regeneration can no longer" \ + " be set from your configuration file(s). Use the"\ " --[no-]watch/-w command-line option instead." config.delete('auto') config.delete('watch') end if config.key? 'server' - Jekyll::Deprecator.deprecation_message "The 'server' configuration option" + - " is no longer accepted. Use the 'jekyll serve'" + + Jekyll::Deprecator.deprecation_message "The 'server' configuration option" \ + " is no longer accepted. Use the 'jekyll serve'" \ " subcommand to serve your site with WEBrick." config.delete('server') end @@ -218,9 +218,9 @@ module Jekyll renamed_key 'data_source', 'data_dir', config if config.key? 'pygments' - Jekyll::Deprecator.deprecation_message "The 'pygments' configuration option" + - " has been renamed to 'highlighter'. Please update your" + - " config file accordingly. The allowed values are 'rouge', " + + Jekyll::Deprecator.deprecation_message "The 'pygments' configuration option" \ + " has been renamed to 'highlighter'. Please update your" \ + " config file accordingly. The allowed values are 'rouge', " \ "'pygments' or null." config['highlighter'] = 'pygments' if config['pygments'] @@ -230,9 +230,9 @@ module Jekyll %w[include exclude].each do |option| config[option] ||= [] if config[option].is_a?(String) - Jekyll::Deprecator.deprecation_message "The '#{option}' configuration option" + - " must now be specified as an array, but you specified" + - " a string. For now, we've treated the string you provided" + + Jekyll::Deprecator.deprecation_message "The '#{option}' configuration option" \ + " must now be specified as an array, but you specified" \ + " a string. For now, we've treated the string you provided" \ " as a list of comma-separated values." config[option] = csv_to_array(config[option]) end @@ -240,16 +240,16 @@ module Jekyll end if (config['kramdown'] || {}).key?('use_coderay') - Jekyll::Deprecator.deprecation_message "Please change 'use_coderay'" + + Jekyll::Deprecator.deprecation_message "Please change 'use_coderay'" \ " to 'enable_coderay' in your configuration file." config['kramdown']['use_coderay'] = config['kramdown'].delete('enable_coderay') end if config.fetch('markdown', 'kramdown').to_s.downcase.eql?("maruku") - Jekyll.logger.abort_with "Error:", "You're using the 'maruku' " + - "Markdown processor, which has been removed as of 3.0.0. " + - "We recommend you switch to Kramdown. To do this, replace " + - "`markdown: maruku` with `markdown: kramdown` in your " + + Jekyll.logger.abort_with "Error:", "You're using the 'maruku' " \ + "Markdown processor, which has been removed as of 3.0.0. " \ + "We recommend you switch to Kramdown. To do this, replace " \ + "`markdown: maruku` with `markdown: kramdown` in your " \ "`_config.yml` file." end @@ -260,7 +260,7 @@ module Jekyll config = clone if config.key?('paginate') && (!config['paginate'].is_a?(Integer) || config['paginate'] < 1) - Jekyll.logger.warn "Config Warning:", "The `paginate` key must be a" + + Jekyll.logger.warn "Config Warning:", "The `paginate` key must be a" \ " positive integer or nil. It's currently set to '#{config['paginate'].inspect}'." config['paginate'] = nil end @@ -285,8 +285,8 @@ module Jekyll def renamed_key(old, new, config, allowed_values = nil) if config.key?(old) - Jekyll::Deprecator.deprecation_message "The '#{old}' configuration" + - "option has been renamed to '#{new}'. Please update your config " + + Jekyll::Deprecator.deprecation_message "The '#{old}' configuration" \ + "option has been renamed to '#{new}'. Please update your config " \ "file accordingly." config[new] = config.delete(old) end diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index 2b1bf1af..2ba0fac3 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -234,7 +234,7 @@ module Jekyll when nils == "last" order = + 1 else - raise ArgumentError.new("Invalid nils order: " + + raise ArgumentError.new("Invalid nils order: " \ "'#{nils}' is not a valid nils order. It must be 'first' or 'last'.") end diff --git a/lib/jekyll/hooks.rb b/lib/jekyll/hooks.rb index a9a5e735..74c01bbb 100644 --- a/lib/jekyll/hooks.rb +++ b/lib/jekyll/hooks.rb @@ -67,7 +67,7 @@ module Jekyll } unless @registry[owner][event] - raise NotAvailable, "Invalid hook. #{owner} supports only the " << + raise NotAvailable, "Invalid hook. #{owner} supports only the " \ "following hooks #{@registry[owner].keys.inspect}" end diff --git a/lib/jekyll/plugin_manager.rb b/lib/jekyll/plugin_manager.rb index 11db89d1..da7bf121 100644 --- a/lib/jekyll/plugin_manager.rb +++ b/lib/jekyll/plugin_manager.rb @@ -86,8 +86,8 @@ module Jekyll def deprecation_checks pagination_included = (site.config['gems'] || []).include?('jekyll-paginate') || defined?(Jekyll::Paginate) if site.config['paginate'] && !pagination_included - Jekyll::Deprecator.deprecation_message "You appear to have pagination " + - "turned on, but you haven't included the `jekyll-paginate` gem. " + + Jekyll::Deprecator.deprecation_message "You appear to have pagination " \ + "turned on, but you haven't included the `jekyll-paginate` gem. " \ "Ensure you have `gems: [jekyll-paginate]` in your configuration file." end end diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 4dc3ac84..2575eba2 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -292,10 +292,10 @@ module Jekyll # Returns def relative_permalinks_are_deprecated if config['relative_permalinks'] - Jekyll.logger.abort_with "Since v3.0, permalinks for pages" + - " in subfolders must be relative to the" + - " site source directory, not the parent" + - " directory. Check http://jekyllrb.com/docs/upgrading/"+ + Jekyll.logger.abort_with "Since v3.0, permalinks for pages" \ + " in subfolders must be relative to the" \ + " site source directory, not the parent" \ + " directory. Check http://jekyllrb.com/docs/upgrading/"\ " for more info." end end diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index 3e64bc8b..616dfdbf 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -88,7 +88,7 @@ eos puts Jekyll.logger.error code puts - Jekyll.logger.error "While attempting to convert the above code, Pygments.rb" + + Jekyll.logger.error "While attempting to convert the above code, Pygments.rb" \ " returned an unacceptable value." Jekyll.logger.error "This is usually a timeout problem solved by running `jekyll build` again." raise ArgumentError.new("Pygments.rb returned an unacceptable value when attempting to highlight some code.") diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb index 5b0d6479..2da26ec0 100644 --- a/lib/jekyll/tags/post_url.rb +++ b/lib/jekyll/tags/post_url.rb @@ -70,9 +70,9 @@ eos site.posts.docs.each do |p| if @post.deprecated_equality p - Jekyll::Deprecator.deprecation_message "A call to '{{ post_url #{@post.name} }}' did not match " + - "a post using the new matching method of checking name " + - "(path-date-slug) equality. Please make sure that you " + + Jekyll::Deprecator.deprecation_message "A call to '{{ post_url #{@post.name} }}' did not match " \ + "a post using the new matching method of checking name " \ + "(path-date-slug) equality. Please make sure that you " \ "change this tag to match the post's name exactly." return p.url end From 8223ebd86109c9b13339c93b660ef7e1215fd0fa Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 15:24:18 -0800 Subject: [PATCH 04/37] Use select and find instead of conditional loop --- lib/jekyll/commands/doctor.rb | 22 +++++++++------------- lib/jekyll/tags/post_url.rb | 22 ++++++++++------------ 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index a29cbf7e..953c2623 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -51,12 +51,10 @@ module Jekyll urls = {} urls = collect_urls(urls, site.pages, site.dest) urls = collect_urls(urls, site.posts.docs, site.dest) - urls.each do |url, paths| - if paths.size > 1 - conflicting_urls = true - Jekyll.logger.warn "Conflict:", "The URL '#{url}' is the destination" \ - " for the following pages: #{paths.join(", ")}" - end + urls.select { |_, p| p.size > 1 }.each do |url, paths| + conflicting_urls = true + Jekyll.logger.warn "Conflict:", "The URL '#{url}' is the destination" \ + " for the following pages: #{paths.join(", ")}" end conflicting_urls end @@ -80,13 +78,11 @@ module Jekyll def urls_only_differ_by_case(site) urls_only_differ_by_case = false urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest) - urls.each do |case_insensitive_url, real_urls| - if real_urls.uniq.size > 1 - urls_only_differ_by_case = true - Jekyll.logger.warn "Warning:", "The following URLs only differ" \ - " by case. On a case-insensitive file system one of the URLs" \ - " will be overwritten by the other: #{real_urls.join(", ")}" - end + urls.select { |_, p| p.size > 1 }.each do |_, real_urls| + urls_only_differ_by_case = true + Jekyll.logger.warn "Warning:", "The following URLs only differ" \ + " by case. On a case-insensitive file system one of the URLs" \ + " will be overwritten by the other: #{real_urls.join(", ")}" end urls_only_differ_by_case end diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb index 2da26ec0..723eafd7 100644 --- a/lib/jekyll/tags/post_url.rb +++ b/lib/jekyll/tags/post_url.rb @@ -59,23 +59,21 @@ eos def render(context) site = context.registers[:site] - site.posts.docs.each do |p| - if @post == p - return p.url - end + post = site.posts.docs.find { |p| @post == p } + if post + return post.url end # New matching method did not match, fall back to old method # with deprecation warning if this matches - site.posts.docs.each do |p| - if @post.deprecated_equality p - Jekyll::Deprecator.deprecation_message "A call to '{{ post_url #{@post.name} }}' did not match " \ - "a post using the new matching method of checking name " \ - "(path-date-slug) equality. Please make sure that you " \ - "change this tag to match the post's name exactly." - return p.url - end + post = site.posts.docs.find { |p| @post.deprecated_equality p } + if post + Jekyll::Deprecator.deprecation_message "A call to '{{ post_url #{@post.name} }}' did not match " \ + "a post using the new matching method of checking name " \ + "(path-date-slug) equality. Please make sure that you " \ + "change this tag to match the post's name exactly." + return post.url end raise ArgumentError.new <<-eos From 6550867051f54f879ea71305f3751c637e04f0b9 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 15:29:49 -0800 Subject: [PATCH 05/37] Rubocop: Style/SpecialGlobalVars - Prefer $LOAD_PATH over $: --- bin/jekyll | 2 +- lib/jekyll.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/jekyll b/bin/jekyll index 67705b51..26754040 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -1,7 +1,7 @@ #!/usr/bin/env ruby STDOUT.sync = true -$:.unshift File.join(File.dirname(__FILE__), *%w{ .. lib }) +$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w{ .. lib }) require 'jekyll' require 'mercenary' diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 24448c26..ad8a3395 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -1,4 +1,4 @@ -$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed +$LOAD_PATH.unshift File.dirname(__FILE__) # For use/testing when no gem is installed # Require all of the Ruby files in the given directory. # From fb0457bf3d863cc2eacdb14960265affba88cced Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 15:30:26 -0800 Subject: [PATCH 06/37] Rubocop: Style/AndOr - Use && instead of and - Use || instead of or --- lib/jekyll/regenerator.rb | 2 +- lib/jekyll/static_file.rb | 2 +- lib/jekyll/stevenson.rb | 2 +- lib/jekyll/tags/highlight.rb | 2 +- lib/jekyll/tags/include.rb | 2 +- lib/jekyll/utils.rb | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/jekyll/regenerator.rb b/lib/jekyll/regenerator.rb index 2d84ee34..c7d47c59 100644 --- a/lib/jekyll/regenerator.rb +++ b/lib/jekyll/regenerator.rb @@ -76,7 +76,7 @@ module Jekyll # # returns a boolean def source_modified_or_dest_missing?(source_path, dest_path) - modified?(source_path) || (dest_path and !File.exist?(dest_path)) + modified?(source_path) || (dest_path && !File.exist?(dest_path)) end # Checks if a path's (or one of its dependencies) diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index 6f24f7d2..efa836d1 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -75,7 +75,7 @@ module Jekyll def write(dest) dest_path = destination(dest) - return false if File.exist?(dest_path) and !modified? + return false if File.exist?(dest_path) && !modified? @@mtimes[path] = mtime FileUtils.mkdir_p(File.dirname(dest_path)) diff --git a/lib/jekyll/stevenson.rb b/lib/jekyll/stevenson.rb index 9a9f412e..ea26c8b5 100644 --- a/lib/jekyll/stevenson.rb +++ b/lib/jekyll/stevenson.rb @@ -14,7 +14,7 @@ module Jekyll severity ||= UNKNOWN @logdev = set_logdevice(severity) - if @logdev.nil? or severity < @level + if @logdev.nil? || severity < @level return true end progname ||= @progname diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index 616dfdbf..13c4e8e8 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -27,7 +27,7 @@ module Jekyll @highlight_options[key.to_sym] = value || true end end - @highlight_options[:linenos] = "inline" if @highlight_options.key?(:linenos) and @highlight_options[:linenos] == true + @highlight_options[:linenos] = "inline" if @highlight_options.key?(:linenos) && @highlight_options[:linenos] == true else raise SyntaxError.new <<-eos Syntax Error in tag 'highlight' while parsing the following markup: diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index 6082a4cc..e3bee115 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -115,7 +115,7 @@ eos validate_path(path, dir, site.safe) # Add include to dependency tree - if context.registers[:page] and context.registers[:page].has_key? "path" + if context.registers[:page] && context.registers[:page].has_key?("path") site.regenerator.add_dependency( site.in_source_dir(context.registers[:page]["path"]), path diff --git a/lib/jekyll/utils.rb b/lib/jekyll/utils.rb index c0c56579..d18b41c7 100644 --- a/lib/jekyll/utils.rb +++ b/lib/jekyll/utils.rb @@ -31,8 +31,8 @@ module Jekyll # Thanks to whoever made it. def deep_merge_hashes!(target, overwrite) overwrite.each_key do |key| - if (overwrite[key].is_a?(Hash) or overwrite[key].is_a?(Drops::Drop)) and - (target[key].is_a?(Hash) or target[key].is_a?(Drops::Drop)) + if (overwrite[key].is_a?(Hash) || overwrite[key].is_a?(Drops::Drop)) && + (target[key].is_a?(Hash) || target[key].is_a?(Drops::Drop)) target[key] = Utils.deep_merge_hashes(target[key], overwrite[key]) next end From 98a19cdf2b24fbf9d18ea38ee183929eabc032d0 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 15:32:11 -0800 Subject: [PATCH 07/37] Rubocop: Style/PercentLiteralDelimiters - %w-literals should be delimited by ( and ) Rubocop: Style/WordArray - Use %w or %W for array of words --- bin/jekyll | 2 +- lib/jekyll/configuration.rb | 4 ++-- lib/jekyll/converters/markdown.rb | 2 +- lib/jekyll/converters/markdown/redcarpet_parser.rb | 4 ++-- lib/jekyll/convertible.rb | 2 +- lib/jekyll/deprecator.rb | 2 +- lib/jekyll/document.rb | 4 ++-- lib/jekyll/external.rb | 4 ++-- lib/jekyll/liquid_renderer/table.rb | 2 +- lib/jekyll/page.rb | 4 ++-- lib/jekyll/readers/collection_reader.rb | 2 +- lib/jekyll/site.rb | 4 ++-- lib/jekyll/utils.rb | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/bin/jekyll b/bin/jekyll index 26754040..297e1175 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -1,7 +1,7 @@ #!/usr/bin/env ruby STDOUT.sync = true -$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w{ .. lib }) +$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w( .. lib )) require 'jekyll' require 'mercenary' diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index 21929f3f..a2e5e381 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -128,7 +128,7 @@ module Jekyll # Get configuration from /_config.yml or / config_files = override.delete('config') if config_files.to_s.empty? - default = %w[yml yaml].find(Proc.new { 'yml' }) do |ext| + default = %w(yml yaml).find(Proc.new { 'yml' }) do |ext| File.exist?(Jekyll.sanitized_path(source(override), "_config.#{ext}")) end config_files = Jekyll.sanitized_path(source(override), "_config.#{default}") @@ -227,7 +227,7 @@ module Jekyll config.delete('pygments') end - %w[include exclude].each do |option| + %w(include exclude).each do |option| config[option] ||= [] if config[option].is_a?(String) Jekyll::Deprecator.deprecation_message "The '#{option}' configuration option" \ diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 711c0a31..8e297dca 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -41,7 +41,7 @@ module Jekyll def third_party_processors self.class.constants - \ - %w[KramdownParser RDiscountParser RedcarpetParser PRIORITIES].map( + %w(KramdownParser RDiscountParser RedcarpetParser PRIORITIES).map( &:to_sym ) end diff --git a/lib/jekyll/converters/markdown/redcarpet_parser.rb b/lib/jekyll/converters/markdown/redcarpet_parser.rb index 6788d96e..7f5adcee 100644 --- a/lib/jekyll/converters/markdown/redcarpet_parser.rb +++ b/lib/jekyll/converters/markdown/redcarpet_parser.rb @@ -71,10 +71,10 @@ module Jekyll end when "rouge" Class.new(Redcarpet::Render::HTML) do - Jekyll::External.require_with_graceful_fail(%w[ + Jekyll::External.require_with_graceful_fail(%w( rouge rouge/plugins/redcarpet - ]) + )) unless Gem::Version.new(Rouge.version) > Gem::Version.new("1.3.0") abort "Please install Rouge 1.3.0 or greater and try running Jekyll again." diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index db34307a..b510d306 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -160,7 +160,7 @@ module Jekyll # # Returns true if extname == .sass or .scss, false otherwise. def sass_file? - %w[.sass .scss].include?(ext) + %w(.sass .scss).include?(ext) end # Determine whether the document is a CoffeeScript file. diff --git a/lib/jekyll/deprecator.rb b/lib/jekyll/deprecator.rb index 8fda510b..d4ea3c88 100644 --- a/lib/jekyll/deprecator.rb +++ b/lib/jekyll/deprecator.rb @@ -21,7 +21,7 @@ module Jekyll end def no_subcommand(args) - if args.size > 0 && args.first =~ /^--/ && !%w[--help --version].include?(args.first) + if args.size > 0 && args.first =~ /^--/ && !%w(--help --version).include?(args.first) deprecation_message "Jekyll now uses subcommands instead of just switches. Run `jekyll --help` to find out more." abort end diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index c906e149..f3eda04f 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -127,7 +127,7 @@ module Jekyll # # Returns true if the extname is either .yml or .yaml, false otherwise. def yaml_file? - %w[.yaml .yml].include?(extname) + %w(.yaml .yml).include?(extname) end # Determine whether the document is an asset file. @@ -143,7 +143,7 @@ module Jekyll # # Returns true if extname == .sass or .scss, false otherwise. def sass_file? - %w[.sass .scss].include?(extname) + %w(.sass .scss).include?(extname) end # Determine whether the document is a CoffeeScript file. diff --git a/lib/jekyll/external.rb b/lib/jekyll/external.rb index 04dbb6f2..81248051 100644 --- a/lib/jekyll/external.rb +++ b/lib/jekyll/external.rb @@ -7,10 +7,10 @@ module Jekyll # Usually contain subcommands. # def blessed_gems - %w{ + %w( jekyll-docs jekyll-import - } + ) end # diff --git a/lib/jekyll/liquid_renderer/table.rb b/lib/jekyll/liquid_renderer/table.rb index 32b09cb3..15a802b0 100644 --- a/lib/jekyll/liquid_renderer/table.rb +++ b/lib/jekyll/liquid_renderer/table.rb @@ -72,7 +72,7 @@ module Jekyll sorted = @stats.sort_by{ |filename, file_stats| -file_stats[:time] } sorted = sorted.slice(0, n) - table = [[ 'Filename', 'Count', 'Bytes', 'Time' ]] + table = [%w(Filename Count Bytes Time)] sorted.each do |filename, file_stats| row = [] diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 0644e1b6..fb46f324 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -8,13 +8,13 @@ module Jekyll attr_accessor :data, :content, :output # Attributes for Liquid templates - ATTRIBUTES_FOR_LIQUID = %w[ + ATTRIBUTES_FOR_LIQUID = %w( content dir name path url - ] + ) # A set of extensions that are considered HTML or HTML-like so we # should not alter them, this includes .xhtml through XHTM5. diff --git a/lib/jekyll/readers/collection_reader.rb b/lib/jekyll/readers/collection_reader.rb index 6a54321d..8d522551 100644 --- a/lib/jekyll/readers/collection_reader.rb +++ b/lib/jekyll/readers/collection_reader.rb @@ -1,6 +1,6 @@ module Jekyll class CollectionReader - SPECIAL_COLLECTIONS = %w{posts data}.freeze + SPECIAL_COLLECTIONS = %w(posts data).freeze attr_reader :site, :content def initialize(site) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 2575eba2..2859355c 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -19,8 +19,8 @@ module Jekyll def initialize(config) @config = config.clone - %w[safe lsi highlighter baseurl exclude include future unpublished - show_drafts limit_posts keep_files gems].each do |opt| + %w(safe lsi highlighter baseurl exclude include future unpublished + show_drafts limit_posts keep_files gems).each do |opt| self.send("#{opt}=", config[opt]) end diff --git a/lib/jekyll/utils.rb b/lib/jekyll/utils.rb index d18b41c7..d5c68ae4 100644 --- a/lib/jekyll/utils.rb +++ b/lib/jekyll/utils.rb @@ -4,7 +4,7 @@ module Jekyll autoload :Ansi, "jekyll/utils/ansi" # Constants for use in #slugify - SLUGIFY_MODES = %w{raw default pretty} + SLUGIFY_MODES = %w(raw default pretty) SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze SLUGIFY_DEFAULT_REGEXP = Regexp.new('[^[:alnum:]]+').freeze SLUGIFY_PRETTY_REGEXP = Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze From ff5f7b71202663e5c693cec41f2108fbbb73ff2d Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 15:41:04 -0800 Subject: [PATCH 08/37] Rubocop: Style/DeprecatedHashMethods - Hash#has_key? is deprecated in favor of Hash#key? Add method `key?` to Drop --- lib/jekyll/drops/drop.rb | 13 +++++++++++++ lib/jekyll/frontmatter_defaults.rb | 4 ++-- lib/jekyll/regenerator.rb | 2 +- lib/jekyll/tags/include.rb | 4 ++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/drops/drop.rb b/lib/jekyll/drops/drop.rb index 98eb864a..23237a08 100644 --- a/lib/jekyll/drops/drop.rb +++ b/lib/jekyll/drops/drop.rb @@ -83,6 +83,19 @@ module Jekyll end end + # Check if key exists in Drop + # + # key - the string key whose value to fetch + # + # Returns true if the given key is present + def key?(key) + if self.class.mutable && @mutations.key?(key) + true + else + respond_to?(key) || fallback_data.key?(key) + end + end + # Generates a list of keys with user content as their values. # This gathers up the Drop methods and keys of the mutations and # underlying data hashes and performs a set union to ensure a list diff --git a/lib/jekyll/frontmatter_defaults.rb b/lib/jekyll/frontmatter_defaults.rb index 673d9a99..edf70969 100644 --- a/lib/jekyll/frontmatter_defaults.rb +++ b/lib/jekyll/frontmatter_defaults.rb @@ -90,7 +90,7 @@ module Jekyll end def applies_path?(scope, path) - return true if !scope.has_key?('path') || scope['path'].empty? + return true if !scope.key?('path') || scope['path'].empty? scope_path = Pathname.new(scope['path']) Pathname.new(sanitize_path(path)).ascend do |path| @@ -150,7 +150,7 @@ module Jekyll # Returns an array of hashes def matching_sets(path, type) valid_sets.select do |set| - !set.has_key?('scope') || applies?(set['scope'], path, type) + !set.key?('scope') || applies?(set['scope'], path, type) end end diff --git a/lib/jekyll/regenerator.rb b/lib/jekyll/regenerator.rb index c7d47c59..52ff5178 100644 --- a/lib/jekyll/regenerator.rb +++ b/lib/jekyll/regenerator.rb @@ -90,7 +90,7 @@ module Jekyll return true if path.nil? # Check for path in cache - if cache.has_key? path + if cache.key? path return cache[path] end diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index e3bee115..4152e7ef 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -115,7 +115,7 @@ eos validate_path(path, dir, site.safe) # Add include to dependency tree - if context.registers[:page] && context.registers[:page].has_key?("path") + if context.registers[:page] && context.registers[:page].key?("path") site.regenerator.add_dependency( site.in_source_dir(context.registers[:page]["path"]), path @@ -138,7 +138,7 @@ eos context.registers[:cached_partials] ||= {} cached_partial = context.registers[:cached_partials] - if cached_partial.has_key?(path) + if cached_partial.key?(path) cached_partial[path] else cached_partial[path] = context.registers[:site].liquid_renderer.file(path).parse(read_file(path, context)) From d157a04c6d4f3c0d23ec5cf396003b321e245ca3 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 15:47:31 -0800 Subject: [PATCH 09/37] Rubocop: Performance/StringReplacement - Use delete! instead of gsub! - Use tr instead of gsub --- lib/jekyll/tags/highlight.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index 13c4e8e8..575fb57e 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -21,7 +21,7 @@ module Jekyll key, value = opt.split('=') # If a quoted list, convert to array if value && value.include?("\"") - value.gsub!(/"/, "") + value.delete!('"') value = value.split end @highlight_options[key.to_sym] = value || true @@ -110,7 +110,7 @@ eos def add_code_tag(code) code_attributes = [ - "class=\"language-#{@lang.to_s.gsub('+', '-')}\"", + "class=\"language-#{@lang.to_s.tr('+', '-')}\"", "data-lang=\"#{@lang.to_s}\"" ].join(" ") "
#{code.chomp}
" From 2530a8cdfc4e0112e7642349b4a718ec95493b09 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 15:49:22 -0800 Subject: [PATCH 10/37] Rubocop: Style/HashSyntax - Use hash rockets syntax --- lib/jekyll/collection.rb | 2 +- lib/jekyll/document.rb | 6 ++-- lib/jekyll/drops/url_drop.rb | 4 +-- lib/jekyll/filters.rb | 2 +- lib/jekyll/hooks.rb | 48 +++++++++++++++---------------- lib/jekyll/readers/post_reader.rb | 4 +-- lib/jekyll/renderer.rb | 4 +-- lib/jekyll/static_file.rb | 14 ++++----- lib/jekyll/tags/highlight.rb | 2 +- 9 files changed, 43 insertions(+), 43 deletions(-) diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index 9b9f6593..5d6b2728 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -56,7 +56,7 @@ module Jekyll full_path = collection_dir(file_path) next if File.directory?(full_path) if Utils.has_yaml_header? full_path - doc = Jekyll::Document.new(full_path, { site: site, collection: self }) + doc = Jekyll::Document.new(full_path, { :site => site, :collection => self }) doc.read if site.publisher.publish?(doc) || !write? docs << doc diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index f3eda04f..d757839f 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -197,9 +197,9 @@ module Jekyll # Returns the computed URL for the document. def url @url = URL.new({ - template: url_template, - placeholders: url_placeholders, - permalink: permalink + :template => url_template, + :placeholders => url_placeholders, + :permalink => permalink }).to_s end diff --git a/lib/jekyll/drops/url_drop.rb b/lib/jekyll/drops/url_drop.rb index a2bf6262..32aae194 100644 --- a/lib/jekyll/drops/url_drop.rb +++ b/lib/jekyll/drops/url_drop.rb @@ -19,8 +19,8 @@ module Jekyll end def title - Utils.slugify(@obj.data['slug'], mode: "pretty", cased: true) || - Utils.slugify(@obj.basename_without_ext, mode: "pretty", cased: true) + Utils.slugify(@obj.data['slug'], :mode => "pretty", :cased => true) || + Utils.slugify(@obj.basename_without_ext, :mode => "pretty", :cased => true) end def slug diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index 2ba0fac3..ef40adb9 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -45,7 +45,7 @@ module Jekyll # Returns the given filename or title as a lowercase URL String. # See Utils.slugify for more detail. def slugify(input, mode=nil) - Utils.slugify(input, mode: mode) + Utils.slugify(input, :mode => mode) end # Format a date in short format e.g. "27 Jan 2011". diff --git a/lib/jekyll/hooks.rb b/lib/jekyll/hooks.rb index 74c01bbb..a9bf79f5 100644 --- a/lib/jekyll/hooks.rb +++ b/lib/jekyll/hooks.rb @@ -4,37 +4,37 @@ module Jekyll # compatibility layer for octopress-hooks users PRIORITY_MAP = { - low: 10, - normal: 20, - high: 30, + :low => 10, + :normal => 20, + :high => 30, }.freeze # initial empty hooks @registry = { :site => { - after_reset: [], - post_read: [], - pre_render: [], - post_render: [], - post_write: [], + :after_reset => [], + :post_read => [], + :pre_render => [], + :post_render => [], + :post_write => [], }, :pages => { - post_init: [], - pre_render: [], - post_render: [], - post_write: [], + :post_init => [], + :pre_render => [], + :post_render => [], + :post_write => [], }, :posts => { - post_init: [], - pre_render: [], - post_render: [], - post_write: [], + :post_init => [], + :pre_render => [], + :post_render => [], + :post_write => [], }, :documents => { - post_init: [], - pre_render: [], - post_render: [], - post_write: [], + :post_init => [], + :pre_render => [], + :post_render => [], + :post_write => [], }, } @@ -60,10 +60,10 @@ module Jekyll # register a single hook to be called later, internal API def self.register_one(owner, event, priority, &block) @registry[owner] ||={ - post_init: [], - pre_render: [], - post_render: [], - post_write: [], + :post_init => [], + :pre_render => [], + :post_render => [], + :post_write => [], } unless @registry[owner][event] diff --git a/lib/jekyll/readers/post_reader.rb b/lib/jekyll/readers/post_reader.rb index c41ef10a..1bf8ca29 100644 --- a/lib/jekyll/readers/post_reader.rb +++ b/lib/jekyll/readers/post_reader.rb @@ -53,8 +53,8 @@ module Jekyll next unless entry =~ matcher path = @site.in_source_dir(File.join(dir, magic_dir, entry)) Document.new(path, { - site: @site, - collection: @site.posts + :site => @site, + :collection => @site.posts }) end.reject(&:nil?) end diff --git a/lib/jekyll/renderer.rb b/lib/jekyll/renderer.rb index 09763cca..f7bfed3d 100644 --- a/lib/jekyll/renderer.rb +++ b/lib/jekyll/renderer.rb @@ -43,8 +43,8 @@ module Jekyll document.trigger_hooks(:pre_render, payload) info = { - filters: [Jekyll::Filters], - registers: { :site => site, :page => payload.page } + :filters => [Jekyll::Filters], + :registers => { :site => site, :page => payload.page } } # render and transform content (this becomes the final content of the object) diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index efa836d1..881e44b1 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -104,12 +104,12 @@ module Jekyll def placeholders { - collection: @collection.label, - path: relative_path[ + :collection => @collection.label, + :path => relative_path[ @collection.relative_directory.size..relative_path.size], - output_ext: '', - name: '', - title: '', + :output_ext => '', + :name => '', + :title => '', } end @@ -121,8 +121,8 @@ module Jekyll relative_path else ::Jekyll::URL.new({ - template: @collection.url_template, - placeholders: placeholders, + :template => @collection.url_template, + :placeholders => placeholders, }) end.to_s.gsub /\/$/, '' end diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index 575fb57e..a487b404 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -99,7 +99,7 @@ eos def render_rouge(code) Jekyll::External.require_with_graceful_fail('rouge') - formatter = Rouge::Formatters::HTML.new(line_numbers: @highlight_options[:linenos], wrap: false) + formatter = Rouge::Formatters::HTML.new(:line_numbers => @highlight_options[:linenos], :wrap => false) lexer = Rouge::Lexer.find_fancy(@lang, code) || Rouge::Lexers::PlainText formatter.format(lexer.lex(code)) end From cda226de45cd052e89210ec70ed0364ee632bdd0 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 15:55:33 -0800 Subject: [PATCH 11/37] Rubocop: Style/EmptyLinesAroundClassBody - Extra empty line detected at class body end --- lib/jekyll.rb | 1 - lib/jekyll/command.rb | 4 ---- lib/jekyll/commands/build.rb | 4 ---- lib/jekyll/commands/clean.rb | 2 -- lib/jekyll/commands/doctor.rb | 2 -- lib/jekyll/commands/help.rb | 2 -- lib/jekyll/configuration.rb | 1 - lib/jekyll/converters/markdown/redcarpet_parser.rb | 1 - lib/jekyll/drops/collection_drop.rb | 1 - lib/jekyll/drops/document_drop.rb | 1 - lib/jekyll/drops/drop.rb | 1 - lib/jekyll/drops/site_drop.rb | 1 - lib/jekyll/drops/unified_payload_drop.rb | 1 - lib/jekyll/external.rb | 2 -- lib/jekyll/plugin_manager.rb | 1 - lib/jekyll/readers/collection_reader.rb | 1 - lib/jekyll/related_posts.rb | 1 - lib/jekyll/renderer.rb | 2 -- lib/jekyll/tags/highlight.rb | 1 - lib/jekyll/tags/include.rb | 1 - lib/jekyll/url.rb | 1 - 21 files changed, 32 deletions(-) diff --git a/lib/jekyll.rb b/lib/jekyll.rb index ad8a3395..6c5d8f10 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -165,7 +165,6 @@ module Jekyll # Conditional optimizations Jekyll::External.require_if_present('liquid-c') - end end diff --git a/lib/jekyll/command.rb b/lib/jekyll/command.rb index f3c89dfd..afe72a5b 100644 --- a/lib/jekyll/command.rb +++ b/lib/jekyll/command.rb @@ -1,8 +1,6 @@ module Jekyll class Command - class << self - # A list of subclasses of Jekyll::Command def subclasses @subclasses ||= [] @@ -62,8 +60,6 @@ module Jekyll c.option 'verbose', '-V', '--verbose', 'Print verbose output.' c.option 'incremental', '-I', '--incremental', 'Enable incremental rebuild.' end - end - end end diff --git a/lib/jekyll/commands/build.rb b/lib/jekyll/commands/build.rb index de0cc8bc..b75194ef 100644 --- a/lib/jekyll/commands/build.rb +++ b/lib/jekyll/commands/build.rb @@ -1,9 +1,7 @@ module Jekyll module Commands class Build < Command - class << self - # Create the Mercenary command for the Jekyll CLI for this Command def init_with_program(prog) prog.command(:build) do |c| @@ -71,9 +69,7 @@ module Jekyll External.require_with_graceful_fail 'jekyll-watch' Jekyll::Watcher.watch(options) end - end # end of class << self - end end end diff --git a/lib/jekyll/commands/clean.rb b/lib/jekyll/commands/clean.rb index 94f9bf97..b7f9a953 100644 --- a/lib/jekyll/commands/clean.rb +++ b/lib/jekyll/commands/clean.rb @@ -2,7 +2,6 @@ module Jekyll module Commands class Clean < Command class << self - def init_with_program(prog) prog.command(:clean) do |c| c.syntax 'clean [subcommand]' @@ -37,7 +36,6 @@ module Jekyll Jekyll.logger.info "Nothing to do for #{metadata_file}." end end - end end end diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index 953c2623..ba98e653 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -2,7 +2,6 @@ module Jekyll module Commands class Doctor < Command class << self - def init_with_program(prog) prog.command(:doctor) do |c| c.syntax 'doctor' @@ -108,7 +107,6 @@ module Jekyll end end end - end end end diff --git a/lib/jekyll/commands/help.rb b/lib/jekyll/commands/help.rb index 421d87e5..01bf3280 100644 --- a/lib/jekyll/commands/help.rb +++ b/lib/jekyll/commands/help.rb @@ -2,7 +2,6 @@ module Jekyll module Commands class Help < Command class << self - def init_with_program(prog) prog.command(:help) do |c| c.syntax 'help [subcommand]' @@ -26,7 +25,6 @@ module Jekyll Jekyll.logger.error "Error:", "Hmm... we don't know what the '#{cmd}' command is." Jekyll.logger.info "Valid commands:", prog.commands.keys.join(", ") end - end end end diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index a2e5e381..f8ecd3ed 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -2,7 +2,6 @@ module Jekyll class Configuration < Hash - # Default options. Overridden by values in _config.yml. # Strings rather than symbols are used for compatibility with YAML. DEFAULTS = Configuration[{ diff --git a/lib/jekyll/converters/markdown/redcarpet_parser.rb b/lib/jekyll/converters/markdown/redcarpet_parser.rb index 7f5adcee..8378cb5d 100644 --- a/lib/jekyll/converters/markdown/redcarpet_parser.rb +++ b/lib/jekyll/converters/markdown/redcarpet_parser.rb @@ -2,7 +2,6 @@ module Jekyll module Converters class Markdown class RedcarpetParser - module CommonMethods def add_code_tags(code, lang) code = code.to_s diff --git a/lib/jekyll/drops/collection_drop.rb b/lib/jekyll/drops/collection_drop.rb index 26913230..5f5025b1 100644 --- a/lib/jekyll/drops/collection_drop.rb +++ b/lib/jekyll/drops/collection_drop.rb @@ -17,7 +17,6 @@ module Jekyll private def_delegator :@obj, :metadata, :fallback_data - end end end diff --git a/lib/jekyll/drops/document_drop.rb b/lib/jekyll/drops/document_drop.rb index f6e03fec..69933752 100644 --- a/lib/jekyll/drops/document_drop.rb +++ b/lib/jekyll/drops/document_drop.rb @@ -22,7 +22,6 @@ module Jekyll private def_delegator :@obj, :data, :fallback_data - end end end diff --git a/lib/jekyll/drops/drop.rb b/lib/jekyll/drops/drop.rb index 23237a08..2ad107e8 100644 --- a/lib/jekyll/drops/drop.rb +++ b/lib/jekyll/drops/drop.rb @@ -135,7 +135,6 @@ module Jekyll def each_key(&block) keys.each(&block) end - end end end diff --git a/lib/jekyll/drops/site_drop.rb b/lib/jekyll/drops/site_drop.rb index ec4f0910..4d07ebe8 100644 --- a/lib/jekyll/drops/site_drop.rb +++ b/lib/jekyll/drops/site_drop.rb @@ -33,7 +33,6 @@ module Jekyll private def_delegator :@obj, :config, :fallback_data - end end end diff --git a/lib/jekyll/drops/unified_payload_drop.rb b/lib/jekyll/drops/unified_payload_drop.rb index 26b9104b..b642bda2 100644 --- a/lib/jekyll/drops/unified_payload_drop.rb +++ b/lib/jekyll/drops/unified_payload_drop.rb @@ -20,7 +20,6 @@ module Jekyll def fallback_data @fallback_data ||= {} end - end end end diff --git a/lib/jekyll/external.rb b/lib/jekyll/external.rb index 81248051..d213364b 100644 --- a/lib/jekyll/external.rb +++ b/lib/jekyll/external.rb @@ -1,7 +1,6 @@ module Jekyll module External class << self - # # Gems that, if installed, should be loaded. # Usually contain subcommands. @@ -54,7 +53,6 @@ If you run into trouble, you can find helpful resources at http://jekyllrb.com/h end end end - end end end diff --git a/lib/jekyll/plugin_manager.rb b/lib/jekyll/plugin_manager.rb index da7bf121..d4ad9951 100644 --- a/lib/jekyll/plugin_manager.rb +++ b/lib/jekyll/plugin_manager.rb @@ -91,6 +91,5 @@ module Jekyll "Ensure you have `gems: [jekyll-paginate]` in your configuration file." end end - end end diff --git a/lib/jekyll/readers/collection_reader.rb b/lib/jekyll/readers/collection_reader.rb index 8d522551..062be42a 100644 --- a/lib/jekyll/readers/collection_reader.rb +++ b/lib/jekyll/readers/collection_reader.rb @@ -16,6 +16,5 @@ module Jekyll collection.read unless SPECIAL_COLLECTIONS.include?(collection.label) end end - end end diff --git a/lib/jekyll/related_posts.rb b/lib/jekyll/related_posts.rb index fbc2837b..eb57a7fc 100644 --- a/lib/jekyll/related_posts.rb +++ b/lib/jekyll/related_posts.rb @@ -1,6 +1,5 @@ module Jekyll class RelatedPosts - class << self attr_accessor :lsi end diff --git a/lib/jekyll/renderer.rb b/lib/jekyll/renderer.rb index f7bfed3d..f9c1b88c 100644 --- a/lib/jekyll/renderer.rb +++ b/lib/jekyll/renderer.rb @@ -2,7 +2,6 @@ module Jekyll class Renderer - attr_reader :document, :site, :payload def initialize(site, document, site_payload = nil) @@ -161,6 +160,5 @@ module Jekyll output end - end end diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index a487b404..0a5b790b 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -115,7 +115,6 @@ eos ].join(" ") "
#{code.chomp}
" end - end end end diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index 4152e7ef..c8f08a6c 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -12,7 +12,6 @@ module Jekyll end class IncludeTag < Liquid::Tag - attr_reader :includes_dir VALID_SYNTAX = /([\w-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+))/ diff --git a/lib/jekyll/url.rb b/lib/jekyll/url.rb index 3f00cfd3..367872c0 100644 --- a/lib/jekyll/url.rb +++ b/lib/jekyll/url.rb @@ -11,7 +11,6 @@ require 'uri' # module Jekyll class URL - # options - One of :permalink or :template must be supplied. # :template - The String used as template for URL generation, # for example "/:path/:basename:output_ext", where From a70d89a86231ddff7d518248ac615521a5324c3d Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 15:56:44 -0800 Subject: [PATCH 12/37] Rubocop: Style/SpaceAfterComma - Space missing after comma --- lib/jekyll/commands/serve.rb | 2 +- lib/jekyll/configuration.rb | 4 ++-- lib/jekyll/converters/markdown/redcarpet_parser.rb | 2 +- lib/jekyll/reader.rb | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index 4dad7600..507a8c71 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -103,7 +103,7 @@ module Jekyll WEBrick::Config::FileHandler.merge({ :FancyIndexing => true, :NondisclosureName => [ - '.ht*','~*' + '.ht*', '~*' ] }) end diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index f8ecd3ed..1b459eb7 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -18,7 +18,7 @@ module Jekyll 'safe' => false, 'include' => ['.htaccess'], 'exclude' => [], - 'keep_files' => ['.git','.svn'], + 'keep_files' => ['.git', '.svn'], 'encoding' => 'utf-8', 'markdown_ext' => 'markdown,mkdown,mkdn,mkd,md', @@ -77,7 +77,7 @@ module Jekyll # # Return a copy of the hash where all its keys are strings def stringify_keys - reduce({}) { |hsh,(k,v)| hsh.merge(k.to_s => v) } + reduce({}) { |hsh, (k, v)| hsh.merge(k.to_s => v) } end def get_config_value_with_override(config_key, override) diff --git a/lib/jekyll/converters/markdown/redcarpet_parser.rb b/lib/jekyll/converters/markdown/redcarpet_parser.rb index 8378cb5d..64e69ecc 100644 --- a/lib/jekyll/converters/markdown/redcarpet_parser.rb +++ b/lib/jekyll/converters/markdown/redcarpet_parser.rb @@ -6,7 +6,7 @@ module Jekyll def add_code_tags(code, lang) code = code.to_s code = code.sub(/
/, "
")
-            code = code.sub(/<\/pre>/,"
") + code = code.sub(/<\/pre>/, "
") end end diff --git a/lib/jekyll/reader.rb b/lib/jekyll/reader.rb index 45a20422..92d2528c 100644 --- a/lib/jekyll/reader.rb +++ b/lib/jekyll/reader.rb @@ -38,9 +38,9 @@ module Jekyll base = site.in_source_dir(dir) dot = Dir.chdir(base) { filter_entries(Dir.entries('.'), base) } - dot_dirs = dot.select{ |file| File.directory?(@site.in_source_dir(base,file)) } + dot_dirs = dot.select{ |file| File.directory?(@site.in_source_dir(base, file)) } dot_files = (dot - dot_dirs) - dot_pages = dot_files.select{ |file| Utils.has_yaml_header?(@site.in_source_dir(base,file)) } + dot_pages = dot_files.select{ |file| Utils.has_yaml_header?(@site.in_source_dir(base, file)) } dot_static_files = dot_files - dot_pages retrieve_posts(dir) @@ -69,7 +69,7 @@ module Jekyll # Returns nothing. def retrieve_dirs(base, dir, dot_dirs) dot_dirs.map { |file| - dir_path = site.in_source_dir(dir,file) + dir_path = site.in_source_dir(dir, file) rel_path = File.join(dir, file) @site.reader.read_directories(rel_path) unless @site.dest.sub(/\/$/, '') == dir_path } From 663a2d3279ac8ac569a3b5ec6f48c71ff93481ff Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 15:58:02 -0800 Subject: [PATCH 13/37] Rubocop: Style/SpaceBeforeBlockBraces Rubocop: Style/SpaceInsideBlockBraces --- lib/jekyll/configuration.rb | 2 +- lib/jekyll/document.rb | 6 +++--- lib/jekyll/filters.rb | 2 +- lib/jekyll/liquid_renderer/table.rb | 2 +- lib/jekyll/reader.rb | 6 +++--- lib/jekyll/readers/page_reader.rb | 4 ++-- lib/jekyll/readers/static_file_reader.rb | 2 +- lib/jekyll/tags/highlight.rb | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index 1b459eb7..089c231a 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -273,7 +273,7 @@ module Jekyll return config if config['collections'].nil? if config['collections'].is_a?(Array) - config['collections'] = Hash[config['collections'].map{|c| [c, {}]}] + config['collections'] = Hash[config['collections'].map { |c| [c, {}] }] end config['collections']['posts'] ||= {} config['collections']['posts']['output'] = true diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index d757839f..4ec70127 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -291,7 +291,7 @@ module Jekyll "ext" => ext }) merge_data!({"date" => date}) if data['date'].nil? || data['date'].to_i == site.time.to_i - data['title'] ||= slug.split('-').select {|w| w.capitalize! || w }.join(' ') + data['title'] ||= slug.split('-').select { |w| w.capitalize! || w }.join(' ') end populate_categories populate_tags @@ -386,7 +386,7 @@ module Jekyll end def next_doc - pos = collection.docs.index {|post| post.equal?(self) } + pos = collection.docs.index { |post| post.equal?(self) } if pos && pos < collection.docs.length - 1 collection.docs[pos + 1] else @@ -395,7 +395,7 @@ module Jekyll end def previous_doc - pos = collection.docs.index {|post| post.equal?(self) } + pos = collection.docs.index { |post| post.equal?(self) } if pos && pos > 0 collection.docs[pos - 1] else diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index ef40adb9..be3efa62 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -337,7 +337,7 @@ module Jekyll pairs = item.map { |k, v| as_liquid([k, v]) } Hash[pairs] when Array - item.map{ |i| as_liquid(i) } + item.map { |i| as_liquid(i) } else if item.respond_to?(:to_liquid) liquidated = item.to_liquid diff --git a/lib/jekyll/liquid_renderer/table.rb b/lib/jekyll/liquid_renderer/table.rb index 15a802b0..74ec6066 100644 --- a/lib/jekyll/liquid_renderer/table.rb +++ b/lib/jekyll/liquid_renderer/table.rb @@ -69,7 +69,7 @@ module Jekyll end def data_for_table(n) - sorted = @stats.sort_by{ |filename, file_stats| -file_stats[:time] } + sorted = @stats.sort_by { |filename, file_stats| -file_stats[:time] } sorted = sorted.slice(0, n) table = [%w(Filename Count Bytes Time)] diff --git a/lib/jekyll/reader.rb b/lib/jekyll/reader.rb index 92d2528c..bc72c657 100644 --- a/lib/jekyll/reader.rb +++ b/lib/jekyll/reader.rb @@ -22,7 +22,7 @@ module Jekyll # Sorts posts, pages, and static files. def sort_files! - site.collections.values.each{|c| c.docs.sort!} + site.collections.values.each { |c| c.docs.sort! } site.pages.sort_by!(&:name) site.static_files.sort_by!(&:relative_path) end @@ -38,9 +38,9 @@ module Jekyll base = site.in_source_dir(dir) dot = Dir.chdir(base) { filter_entries(Dir.entries('.'), base) } - dot_dirs = dot.select{ |file| File.directory?(@site.in_source_dir(base, file)) } + dot_dirs = dot.select { |file| File.directory?(@site.in_source_dir(base, file)) } dot_files = (dot - dot_dirs) - dot_pages = dot_files.select{ |file| Utils.has_yaml_header?(@site.in_source_dir(base, file)) } + dot_pages = dot_files.select { |file| Utils.has_yaml_header?(@site.in_source_dir(base, file)) } dot_static_files = dot_files - dot_pages retrieve_posts(dir) diff --git a/lib/jekyll/readers/page_reader.rb b/lib/jekyll/readers/page_reader.rb index 12e70748..97748c01 100644 --- a/lib/jekyll/readers/page_reader.rb +++ b/lib/jekyll/readers/page_reader.rb @@ -14,8 +14,8 @@ module Jekyll # # Returns an array of static pages. def read(files) - files.map{ |page| @unfiltered_content << Page.new(@site, @site.source, @dir, page) } - @unfiltered_content.select{ |page| site.publisher.publish?(page) } + files.map { |page| @unfiltered_content << Page.new(@site, @site.source, @dir, page) } + @unfiltered_content.select { |page| site.publisher.publish?(page) } end end end diff --git a/lib/jekyll/readers/static_file_reader.rb b/lib/jekyll/readers/static_file_reader.rb index b95981a8..8def1365 100644 --- a/lib/jekyll/readers/static_file_reader.rb +++ b/lib/jekyll/readers/static_file_reader.rb @@ -14,7 +14,7 @@ module Jekyll # # Returns an array of static files. def read(files) - files.map{ |file| @unfiltered_content << StaticFile.new(@site, @site.source, @dir, file)} + files.map { |file| @unfiltered_content << StaticFile.new(@site, @site.source, @dir, file) } @unfiltered_content end end diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index 0a5b790b..d0d70882 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -68,7 +68,7 @@ eos [:linenos, opts.fetch(:linenos, nil)], [:encoding, opts.fetch(:encoding, 'utf-8')], [:cssclass, opts.fetch(:cssclass, nil)] - ].reject {|f| f.last.nil? }] + ].reject { |f| f.last.nil? }] else opts end From 704ca6b8cc4eee5e263f088ca91c383c6ec7f0fa Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 15:59:12 -0800 Subject: [PATCH 14/37] Rubocop: Style/NegatedIf - Favor unless over if for negative conditions --- lib/jekyll/cleaner.rb | 2 +- lib/jekyll/commands/doctor.rb | 2 +- lib/jekyll/commands/serve/servlet.rb | 2 +- lib/jekyll/converters/markdown.rb | 2 +- lib/jekyll/regenerator.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/cleaner.rb b/lib/jekyll/cleaner.rb index ca8a0ca9..6c89e2bc 100644 --- a/lib/jekyll/cleaner.rb +++ b/lib/jekyll/cleaner.rb @@ -13,7 +13,7 @@ module Jekyll # Cleans up the site's destination directory def cleanup! FileUtils.rm_rf(obsolete_files) - FileUtils.rm_rf(metadata_file) if !@site.incremental? + FileUtils.rm_rf(metadata_file) unless @site.incremental? end private diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index ba98e653..42bb0110 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -59,7 +59,7 @@ module Jekyll end def fsnotify_buggy?(site) - return true if !Utils::Platforms.osx? + return true unless Utils::Platforms.osx? if Dir.pwd != `pwd`.strip Jekyll.logger.error " " + <<-STR.strip.gsub(/\n\s+/, "\n ") We have detected that there might be trouble using fsevent on your diff --git a/lib/jekyll/commands/serve/servlet.rb b/lib/jekyll/commands/serve/servlet.rb index fa376f61..7930eb61 100644 --- a/lib/jekyll/commands/serve/servlet.rb +++ b/lib/jekyll/commands/serve/servlet.rb @@ -52,7 +52,7 @@ module Jekyll def set_defaults hash_ = @jekyll_opts.fetch("webrick", {}).fetch("headers", {}) DEFAULTS.each_with_object(@headers = hash_) do |(key, val), hash| - hash[key] = val if !hash.key?(key) + hash[key] = val unless hash.key?(key) end end end diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 8e297dca..07675427 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -7,7 +7,7 @@ module Jekyll def setup return if @setup - if (!@parser = get_processor) + unless (@parser = get_processor) Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"] Jekyll.logger.info "", "Custom processors are not loaded in safe mode" if @config["safe"] Jekyll.logger.error "", "Available processors are: #{valid_processors.join(", ")}" diff --git a/lib/jekyll/regenerator.rb b/lib/jekyll/regenerator.rb index 52ff5178..cd672830 100644 --- a/lib/jekyll/regenerator.rb +++ b/lib/jekyll/regenerator.rb @@ -119,7 +119,7 @@ module Jekyll def add_dependency(path, dependency) return if (metadata[path].nil? || @disabled) - if !metadata[path]["deps"].include? dependency + unless metadata[path]["deps"].include? dependency metadata[path]["deps"] << dependency add(dependency) unless metadata.include?(dependency) end From af5d51289f6c425f48be89a9064200f222b0eb29 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 16:02:32 -0800 Subject: [PATCH 15/37] Rubocop: Style/SymbolProc - Pass &:to_sym as an argument to map instead of a block - Pass &:capitalize as an argument to select instead of a block - Pass &:to_s as an argument to map instead of a block --- lib/jekyll/converters/markdown/rdiscount_parser.rb | 2 +- lib/jekyll/document.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/converters/markdown/rdiscount_parser.rb b/lib/jekyll/converters/markdown/rdiscount_parser.rb index fb5172e7..daf8874e 100644 --- a/lib/jekyll/converters/markdown/rdiscount_parser.rb +++ b/lib/jekyll/converters/markdown/rdiscount_parser.rb @@ -5,7 +5,7 @@ module Jekyll def initialize(config) Jekyll::External.require_with_graceful_fail "rdiscount" @config = config - @rdiscount_extensions = @config['rdiscount']['extensions'].map { |e| e.to_sym } + @rdiscount_extensions = @config['rdiscount']['extensions'].map(&:to_sym) end def convert(content) diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 4ec70127..9e588ded 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -291,7 +291,7 @@ module Jekyll "ext" => ext }) merge_data!({"date" => date}) if data['date'].nil? || data['date'].to_i == site.time.to_i - data['title'] ||= slug.split('-').select { |w| w.capitalize! || w }.join(' ') + data['title'] ||= slug.split('-').select(&:capitalize).join(' ') end populate_categories populate_tags @@ -317,7 +317,7 @@ module Jekyll merge_data!({ 'categories' => ( Array(data['categories']) + Utils.pluralized_array_from_hash(data, 'category', 'categories') - ).map { |c| c.to_s }.flatten.uniq + ).map(&:to_s).flatten.uniq }) end From 7ca4f7cd62d5d9d6a6375d96cbda8bc223cd4abe Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 16:18:26 -0800 Subject: [PATCH 16/37] Rubocop: Style/Proc - Use proc instead of Proc.new ...and use lambda instead of proc --- lib/jekyll/configuration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index 089c231a..353e437a 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -127,7 +127,7 @@ module Jekyll # Get configuration from /_config.yml or / config_files = override.delete('config') if config_files.to_s.empty? - default = %w(yml yaml).find(Proc.new { 'yml' }) do |ext| + default = %w(yml yaml).find(-> { 'yml' }) do |ext| File.exist?(Jekyll.sanitized_path(source(override), "_config.#{ext}")) end config_files = Jekyll.sanitized_path(source(override), "_config.#{default}") From 11f0aab4b1c257fa87f73d87c71af41268dc127a Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 16:24:13 -0800 Subject: [PATCH 17/37] Rubocop: Lint/UnusedBlockArgument - Unused block argument --- bin/jekyll | 2 +- lib/jekyll/commands/build.rb | 2 +- lib/jekyll/commands/clean.rb | 2 +- lib/jekyll/commands/doctor.rb | 2 +- lib/jekyll/document.rb | 2 +- lib/jekyll/drops/drop.rb | 2 +- lib/jekyll/liquid_renderer.rb | 2 +- lib/jekyll/liquid_renderer/table.rb | 2 +- lib/jekyll/page.rb | 2 +- lib/jekyll/site.rb | 2 +- lib/jekyll/stevenson.rb | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/jekyll b/bin/jekyll index 297e1175..173a58d3 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -28,7 +28,7 @@ Mercenary.program(:jekyll) do |p| Jekyll::Command.subclasses.each { |c| c.init_with_program(p) } - p.action do |args, options| + p.action do |args, _| if args.empty? Jekyll.logger.error "A subcommand is required." puts p diff --git a/lib/jekyll/commands/build.rb b/lib/jekyll/commands/build.rb index b75194ef..cf6d7ea0 100644 --- a/lib/jekyll/commands/build.rb +++ b/lib/jekyll/commands/build.rb @@ -11,7 +11,7 @@ module Jekyll add_build_options(c) - c.action do |args, options| + c.action do |_, options| options["serving"] = false Jekyll::Commands::Build.process(options) end diff --git a/lib/jekyll/commands/clean.rb b/lib/jekyll/commands/clean.rb index b7f9a953..371b7043 100644 --- a/lib/jekyll/commands/clean.rb +++ b/lib/jekyll/commands/clean.rb @@ -9,7 +9,7 @@ module Jekyll add_build_options(c) - c.action do |args, options| + c.action do |_, options| Jekyll::Commands::Clean.process(options) end end diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index 42bb0110..32600741 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -10,7 +10,7 @@ module Jekyll c.option '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file' - c.action do |args, options| + c.action do |_, options| Jekyll::Commands::Doctor.process(options) end end diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 9e588ded..5b8c9044 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -32,7 +32,7 @@ module Jekyll categories_from_path(collection.relative_directory) end - data.default_proc = proc do |hash, key| + data.default_proc = proc do |_, key| site.frontmatter_defaults.find(relative_path, collection.label, key) end diff --git a/lib/jekyll/drops/drop.rb b/lib/jekyll/drops/drop.rb index 2ad107e8..c194a5ba 100644 --- a/lib/jekyll/drops/drop.rb +++ b/lib/jekyll/drops/drop.rb @@ -114,7 +114,7 @@ module Jekyll # # Returns a Hash with all the keys and values resolved. def to_h - keys.each_with_object({}) do |(key, val), result| + keys.each_with_object({}) do |(key, _), result| result[key] = self[key] end end diff --git a/lib/jekyll/liquid_renderer.rb b/lib/jekyll/liquid_renderer.rb index 0edeb44b..70f7b0d1 100644 --- a/lib/jekyll/liquid_renderer.rb +++ b/lib/jekyll/liquid_renderer.rb @@ -15,7 +15,7 @@ module Jekyll def file(filename) filename = @site.in_source_dir(filename).sub(/\A#{Regexp.escape(@site.source)}\//, '') - LiquidRenderer::File.new(self, filename).tap do |file| + LiquidRenderer::File.new(self, filename).tap do @stats[filename] ||= {} @stats[filename][:count] ||= 0 @stats[filename][:count] += 1 diff --git a/lib/jekyll/liquid_renderer/table.rb b/lib/jekyll/liquid_renderer/table.rb index 74ec6066..e3e0c8af 100644 --- a/lib/jekyll/liquid_renderer/table.rb +++ b/lib/jekyll/liquid_renderer/table.rb @@ -69,7 +69,7 @@ module Jekyll end def data_for_table(n) - sorted = @stats.sort_by { |filename, file_stats| -file_stats[:time] } + sorted = @stats.sort_by { |_, file_stats| -file_stats[:time] } sorted = sorted.slice(0, n) table = [%w(Filename Count Bytes Time)] diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index fb46f324..aaf472cf 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -41,7 +41,7 @@ module Jekyll process(name) read_yaml(File.join(base, dir), name) - data.default_proc = proc do |hash, key| + data.default_proc = proc do |_, key| site.frontmatter_defaults.find(File.join(dir, name), type, key) end diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 2859355c..3ed60c12 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -165,7 +165,7 @@ module Jekyll Jekyll::Hooks.trigger :site, :pre_render, self, payload - collections.each do |label, collection| + collections.each do |_, collection| collection.docs.each do |document| if regenerator.regenerate?(document) document.output = Jekyll::Renderer.new(self, document, payload).run diff --git a/lib/jekyll/stevenson.rb b/lib/jekyll/stevenson.rb index ea26c8b5..d6dd5434 100644 --- a/lib/jekyll/stevenson.rb +++ b/lib/jekyll/stevenson.rb @@ -5,7 +5,7 @@ module Jekyll @level = DEBUG @default_formatter = Formatter.new @logdev = $stdout - @formatter = proc do |severity, datetime, progname, msg| + @formatter = proc do |_, _, _, msg| "#{msg}" end end From e3189e38282d17b894d6984dfb35f9c86dd33a80 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 17:07:39 -0800 Subject: [PATCH 18/37] Rubocop: Lint/UnusedMethodArgument --- lib/jekyll/commands/build.rb | 2 +- lib/jekyll/commands/doctor.rb | 2 +- lib/jekyll/commands/serve/servlet.rb | 2 +- lib/jekyll/configuration.rb | 2 +- lib/jekyll/converters/identity.rb | 2 +- lib/jekyll/converters/markdown.rb | 2 +- lib/jekyll/converters/markdown/redcarpet_parser.rb | 2 +- lib/jekyll/reader.rb | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/jekyll/commands/build.rb b/lib/jekyll/commands/build.rb index cf6d7ea0..d505e2fb 100644 --- a/lib/jekyll/commands/build.rb +++ b/lib/jekyll/commands/build.rb @@ -65,7 +65,7 @@ module Jekyll # options - A Hash of options passed to the command # # Returns nothing. - def watch(site, options) + def watch(_site, options) External.require_with_graceful_fail 'jekyll-watch' Jekyll::Watcher.watch(options) end diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index 32600741..c6ba4fd4 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -58,7 +58,7 @@ module Jekyll conflicting_urls end - def fsnotify_buggy?(site) + def fsnotify_buggy?(_site) return true unless Utils::Platforms.osx? if Dir.pwd != `pwd`.strip Jekyll.logger.error " " + <<-STR.strip.gsub(/\n\s+/, "\n ") diff --git a/lib/jekyll/commands/serve/servlet.rb b/lib/jekyll/commands/serve/servlet.rb index 7930eb61..cf495216 100644 --- a/lib/jekyll/commands/serve/servlet.rb +++ b/lib/jekyll/commands/serve/servlet.rb @@ -37,7 +37,7 @@ module Jekyll # private - def validate_and_ensure_charset(req, res) + def validate_and_ensure_charset(_req, res) key = res.header.keys.grep(/content-type/i).first typ = res.header[key] diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index 353e437a..0229e073 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -282,7 +282,7 @@ module Jekyll config end - def renamed_key(old, new, config, allowed_values = nil) + def renamed_key(old, new, config, _ = nil) if config.key?(old) Jekyll::Deprecator.deprecation_message "The '#{old}' configuration" \ "option has been renamed to '#{new}'. Please update your config " \ diff --git a/lib/jekyll/converters/identity.rb b/lib/jekyll/converters/identity.rb index 69171b00..9574769d 100644 --- a/lib/jekyll/converters/identity.rb +++ b/lib/jekyll/converters/identity.rb @@ -5,7 +5,7 @@ module Jekyll priority :lowest - def matches(ext) + def matches(_ext) true end diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 07675427..e6efabf5 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -56,7 +56,7 @@ module Jekyll extname_list.include?(ext.downcase) end - def output_ext(ext) + def output_ext(_ext) ".html" end diff --git a/lib/jekyll/converters/markdown/redcarpet_parser.rb b/lib/jekyll/converters/markdown/redcarpet_parser.rb index 64e69ecc..fd1b0461 100644 --- a/lib/jekyll/converters/markdown/redcarpet_parser.rb +++ b/lib/jekyll/converters/markdown/redcarpet_parser.rb @@ -47,7 +47,7 @@ module Jekyll end protected - def rouge_formatter(lexer) + def rouge_formatter(_lexer) Rouge::Formatters::HTML.new(:wrap => false) end end diff --git a/lib/jekyll/reader.rb b/lib/jekyll/reader.rb index bc72c657..2926971b 100644 --- a/lib/jekyll/reader.rb +++ b/lib/jekyll/reader.rb @@ -67,7 +67,7 @@ module Jekyll # dot_dirs - The Array of subdirectories in the dir. # # Returns nothing. - def retrieve_dirs(base, dir, dot_dirs) + def retrieve_dirs(_base, dir, dot_dirs) dot_dirs.map { |file| dir_path = site.in_source_dir(dir, file) rel_path = File.join(dir, file) From fd8fdd87d32f2be1a9bdccfd475c32e291969163 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 17:10:39 -0800 Subject: [PATCH 19/37] Rubocop: Style/RegexpLiteral --- lib/jekyll/static_file.rb | 2 +- lib/jekyll/url.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index 881e44b1..72c26741 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -124,7 +124,7 @@ module Jekyll :template => @collection.url_template, :placeholders => placeholders, }) - end.to_s.gsub /\/$/, '' + end.to_s.gsub(/\/$/, '') end # Returns the type of the collection if present, nil otherwise. diff --git a/lib/jekyll/url.rb b/lib/jekyll/url.rb index 367872c0..950945a7 100644 --- a/lib/jekyll/url.rb +++ b/lib/jekyll/url.rb @@ -92,7 +92,7 @@ module Jekyll # as well as the beginning "/" so we can enforce and ensure it. def sanitize_url(str) - "/" + str.gsub(/\/{2,}/, "/").gsub(%r!\.+\/|\A/+!, "") + "/" + str.gsub(/\/{2,}/, "/").gsub(/\.+\/|\A\/+/, "") end # Escapes a path to be a valid URL path segment From 4c5d77a4b54866df0d6d862a68a5fa22b4f98cf1 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 17:14:41 -0800 Subject: [PATCH 20/37] Rubocop: Style/EmptyLines --- lib/jekyll/converters/markdown/redcarpet_parser.rb | 1 - lib/jekyll/page.rb | 1 - lib/jekyll/regenerator.rb | 2 -- lib/jekyll/related_posts.rb | 1 - lib/jekyll/utils.rb | 1 - 5 files changed, 6 deletions(-) diff --git a/lib/jekyll/converters/markdown/redcarpet_parser.rb b/lib/jekyll/converters/markdown/redcarpet_parser.rb index fd1b0461..12b4f3fb 100644 --- a/lib/jekyll/converters/markdown/redcarpet_parser.rb +++ b/lib/jekyll/converters/markdown/redcarpet_parser.rb @@ -52,7 +52,6 @@ module Jekyll end end - def initialize(config) External.require_with_graceful_fail("redcarpet") @config = config diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index aaf472cf..019cb095 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -37,7 +37,6 @@ module Jekyll @dir = dir @name = name - process(name) read_yaml(File.join(base, dir), name) diff --git a/lib/jekyll/regenerator.rb b/lib/jekyll/regenerator.rb index cd672830..1e751f7d 100644 --- a/lib/jekyll/regenerator.rb +++ b/lib/jekyll/regenerator.rb @@ -62,7 +62,6 @@ module Jekyll clear_cache end - # Clear just the cache # # Returns nothing @@ -70,7 +69,6 @@ module Jekyll @cache = {} end - # Checks if the source has been modified or the # destination is missing # diff --git a/lib/jekyll/related_posts.rb b/lib/jekyll/related_posts.rb index eb57a7fc..51ae8d8f 100644 --- a/lib/jekyll/related_posts.rb +++ b/lib/jekyll/related_posts.rb @@ -23,7 +23,6 @@ module Jekyll end end - def build_index self.class.lsi ||= begin lsi = ClassifierReborn::LSI.new(:auto_rebuild => false) diff --git a/lib/jekyll/utils.rb b/lib/jekyll/utils.rb index d5c68ae4..0760d9e3 100644 --- a/lib/jekyll/utils.rb +++ b/lib/jekyll/utils.rb @@ -225,7 +225,6 @@ module Jekyll template end - # Work the same way as Dir.glob but seperating the input into two parts # ('dir' + '/' + 'pattern') to make sure the first part('dir') does not act # as a pattern. From 13c980c8967bb0d6e7e65868908be32d4e05e633 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 17:16:17 -0800 Subject: [PATCH 21/37] Rubocop: Style/TrailingComma --- lib/jekyll/hooks.rb | 14 +++++++------- lib/jekyll/static_file.rb | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/jekyll/hooks.rb b/lib/jekyll/hooks.rb index a9bf79f5..869bcc1f 100644 --- a/lib/jekyll/hooks.rb +++ b/lib/jekyll/hooks.rb @@ -6,7 +6,7 @@ module Jekyll PRIORITY_MAP = { :low => 10, :normal => 20, - :high => 30, + :high => 30 }.freeze # initial empty hooks @@ -16,26 +16,26 @@ module Jekyll :post_read => [], :pre_render => [], :post_render => [], - :post_write => [], + :post_write => [] }, :pages => { :post_init => [], :pre_render => [], :post_render => [], - :post_write => [], + :post_write => [] }, :posts => { :post_init => [], :pre_render => [], :post_render => [], - :post_write => [], + :post_write => [] }, :documents => { :post_init => [], :pre_render => [], :post_render => [], - :post_write => [], - }, + :post_write => [] + } } # map of all hooks and their priorities @@ -63,7 +63,7 @@ module Jekyll :post_init => [], :pre_render => [], :post_render => [], - :post_write => [], + :post_write => [] } unless @registry[owner][event] diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index 72c26741..7938a050 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -109,7 +109,7 @@ module Jekyll @collection.relative_directory.size..relative_path.size], :output_ext => '', :name => '', - :title => '', + :title => '' } end @@ -122,7 +122,7 @@ module Jekyll else ::Jekyll::URL.new({ :template => @collection.url_template, - :placeholders => placeholders, + :placeholders => placeholders }) end.to_s.gsub(/\/$/, '') end From f221b925b4fee632ec62653f3f9848e2d7763c22 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 17:16:58 -0800 Subject: [PATCH 22/37] Rubocop: Lint/StringConversionInInterpolation - Redundant use of Object#to_s in interpolation --- lib/jekyll/tags/highlight.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index d0d70882..027865cd 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -111,7 +111,7 @@ eos def add_code_tag(code) code_attributes = [ "class=\"language-#{@lang.to_s.tr('+', '-')}\"", - "data-lang=\"#{@lang.to_s}\"" + "data-lang=\"#{@lang}\"" ].join(" ") "
#{code.chomp}
" end From 2c9a349f9aafab1fff4ea15bd4cf52f4cf33d00e Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 11:06:12 -0800 Subject: [PATCH 23/37] Rubocop: Style/Next - Use next to skip iteration --- lib/jekyll/commands/doctor.rb | 6 ++++-- lib/jekyll/tags/post_url.rb | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index c6ba4fd4..3a263501 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -50,7 +50,8 @@ module Jekyll urls = {} urls = collect_urls(urls, site.pages, site.dest) urls = collect_urls(urls, site.posts.docs, site.dest) - urls.select { |_, p| p.size > 1 }.each do |url, paths| + urls.each do |url, paths| + next unless paths.size > 1 conflicting_urls = true Jekyll.logger.warn "Conflict:", "The URL '#{url}' is the destination" \ " for the following pages: #{paths.join(", ")}" @@ -77,7 +78,8 @@ module Jekyll def urls_only_differ_by_case(site) urls_only_differ_by_case = false urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest) - urls.select { |_, p| p.size > 1 }.each do |_, real_urls| + urls.each do |case_insensitive_url, real_urls| + next unless real_urls.uniq.size > 1 urls_only_differ_by_case = true Jekyll.logger.warn "Warning:", "The following URLs only differ" \ " by case. On a case-insensitive file system one of the URLs" \ diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb index 723eafd7..5b3df093 100644 --- a/lib/jekyll/tags/post_url.rb +++ b/lib/jekyll/tags/post_url.rb @@ -59,21 +59,21 @@ eos def render(context) site = context.registers[:site] - post = site.posts.docs.find { |p| @post == p } - if post - return post.url + site.posts.docs.each do |p| + return p.url if @post == p end # New matching method did not match, fall back to old method # with deprecation warning if this matches - post = site.posts.docs.find { |p| @post.deprecated_equality p } - if post + + site.posts.docs.each do |p| + next unless @post.deprecated_equality p Jekyll::Deprecator.deprecation_message "A call to '{{ post_url #{@post.name} }}' did not match " \ "a post using the new matching method of checking name " \ "(path-date-slug) equality. Please make sure that you " \ "change this tag to match the post's name exactly." - return post.url + return p.url end raise ArgumentError.new <<-eos From f6fd9014bae10df4404a3bab0b4b607146ccd743 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 11:15:37 -0800 Subject: [PATCH 24/37] Rubocop: Style/CaseIndentation - Indent when as deep as case --- lib/jekyll/converters/markdown.rb | 6 +++--- lib/jekyll/frontmatter_defaults.rb | 27 ++++++++++++++------------- lib/jekyll/readers/data_reader.rb | 14 +++++++------- lib/jekyll/utils.rb | 21 +++++++++++---------- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index e6efabf5..bb7b7ffa 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -19,9 +19,9 @@ module Jekyll def get_processor case @config["markdown"].downcase - when "redcarpet" then return RedcarpetParser.new(@config) - when "kramdown" then return KramdownParser.new(@config) - when "rdiscount" then return RDiscountParser.new(@config) + when "redcarpet" then return RedcarpetParser.new(@config) + when "kramdown" then return KramdownParser.new(@config) + when "rdiscount" then return RDiscountParser.new(@config) else get_custom_processor end diff --git a/lib/jekyll/frontmatter_defaults.rb b/lib/jekyll/frontmatter_defaults.rb index edf70969..877f517e 100644 --- a/lib/jekyll/frontmatter_defaults.rb +++ b/lib/jekyll/frontmatter_defaults.rb @@ -13,19 +13,20 @@ module Jekyll def update_deprecated_types(set) return set unless set.key?('scope') && set['scope'].key?('type') - set['scope']['type'] = case set['scope']['type'] - when 'page' - Deprecator.defaults_deprecate_type('page', 'pages') - 'pages' - when 'post' - Deprecator.defaults_deprecate_type('post', 'posts') - 'posts' - when 'draft' - Deprecator.defaults_deprecate_type('draft', 'drafts') - 'drafts' - else - set['scope']['type'] - end + set['scope']['type'] = + case set['scope']['type'] + when 'page' + Deprecator.defaults_deprecate_type('page', 'pages') + 'pages' + when 'post' + Deprecator.defaults_deprecate_type('post', 'posts') + 'posts' + when 'draft' + Deprecator.defaults_deprecate_type('draft', 'drafts') + 'drafts' + else + set['scope']['type'] + end set end diff --git a/lib/jekyll/readers/data_reader.rb b/lib/jekyll/readers/data_reader.rb index cbb24be3..870fc2dc 100644 --- a/lib/jekyll/readers/data_reader.rb +++ b/lib/jekyll/readers/data_reader.rb @@ -50,13 +50,13 @@ module Jekyll # Returns the contents of the data file. def read_data_file(path) case File.extname(path).downcase - when '.csv' - CSV.read(path, { - :headers => true, - :encoding => site.config['encoding'] - }).map(&:to_hash) - else - SafeYAML.load_file(path) + when '.csv' + CSV.read(path, { + :headers => true, + :encoding => site.config['encoding'] + }).map(&:to_hash) + else + SafeYAML.load_file(path) end end diff --git a/lib/jekyll/utils.rb b/lib/jekyll/utils.rb index 0760d9e3..1d81e0f0 100644 --- a/lib/jekyll/utils.rb +++ b/lib/jekyll/utils.rb @@ -164,16 +164,17 @@ module Jekyll end # Replace each character sequence with a hyphen - re = case mode - when 'raw' - SLUGIFY_RAW_REGEXP - when 'default' - SLUGIFY_DEFAULT_REGEXP - when 'pretty' - # "._~!$&'()+,;=@" is human readable (not URI-escaped) in URL - # and is allowed in both extN and NTFS. - SLUGIFY_PRETTY_REGEXP - end + re = + case mode + when 'raw' + SLUGIFY_RAW_REGEXP + when 'default' + SLUGIFY_DEFAULT_REGEXP + when 'pretty' + # "._~!$&'()+,;=@" is human readable (not URI-escaped) in URL + # and is allowed in both extN and NTFS. + SLUGIFY_PRETTY_REGEXP + end # Strip according to the mode slug = string.gsub(re, '-') From af9ec6831d7652c423e29a32aff418da783757d0 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 11:23:06 -0800 Subject: [PATCH 25/37] Rubocop: Style/ElseAlignment - Align else with if Rubocop: Lint/EndAlignment - Align end with if --- lib/jekyll/regenerator.rb | 23 ++++++++++++----------- lib/jekyll/static_file.rb | 14 +++++++------- lib/jekyll/tags/include.rb | 12 ++++++------ 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/lib/jekyll/regenerator.rb b/lib/jekyll/regenerator.rb index 1e751f7d..bb9284aa 100644 --- a/lib/jekyll/regenerator.rb +++ b/lib/jekyll/regenerator.rb @@ -155,20 +155,21 @@ module Jekyll # # Returns the read metadata. def read_metadata - @metadata = if !disabled? && File.file?(metadata_file) - content = File.binread(metadata_file) + @metadata = + if !disabled? && File.file?(metadata_file) + content = File.binread(metadata_file) - begin - Marshal.load(content) - rescue TypeError - SafeYAML.load(content) - rescue ArgumentError => e - Jekyll.logger.warn("Failed to load #{metadata_file}: #{e}") + begin + Marshal.load(content) + rescue TypeError + SafeYAML.load(content) + rescue ArgumentError => e + Jekyll.logger.warn("Failed to load #{metadata_file}: #{e}") + {} + end + else {} end - else - {} - end end end end diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index 7938a050..0ed0fbfe 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -118,13 +118,13 @@ module Jekyll # be overriden in the collection's configuration in _config.yml. def url @url ||= if @collection.nil? - relative_path - else - ::Jekyll::URL.new({ - :template => @collection.url_template, - :placeholders => placeholders - }) - end.to_s.gsub(/\/$/, '') + relative_path + else + ::Jekyll::URL.new({ + :template => @collection.url_template, + :placeholders => placeholders + }) + end.to_s.gsub(/\/$/, '') end # Returns the type of the collection if present, nil otherwise. diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index c8f08a6c..b92e5b85 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -42,12 +42,12 @@ module Jekyll markup = markup[match.end(0)..-1] value = if match[2] - match[2].gsub(/\\"/, '"') - elsif match[3] - match[3].gsub(/\\'/, "'") - elsif match[4] - context[match[4]] - end + match[2].gsub(/\\"/, '"') + elsif match[3] + match[3].gsub(/\\'/, "'") + elsif match[4] + context[match[4]] + end params[match[1]] = value end From f9926edbc44a2b5ef74b693e2da186577ed5eb02 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 11:39:14 -0800 Subject: [PATCH 26/37] Rubocop: Style/TrivialAccessors - Use `attr_writer` to define trivial writer methods --- lib/jekyll/document.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 5b8c9044..0d23ac88 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -4,7 +4,8 @@ module Jekyll class Document include Comparable - attr_reader :path, :site, :extname, :output_ext, :content, :output, :collection + attr_reader :path, :site, :extname, :output_ext, :collection + attr_accessor :content, :output YAML_FRONT_MATTER_REGEXP = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m DATELESS_FILENAME_MATCHER = /^(.*)(\.[^.]+)$/ @@ -39,14 +40,6 @@ module Jekyll trigger_hooks(:post_init) end - def output=(output) - @output = output - end - - def content=(content) - @content = content - end - # Fetch the Document's data. # # Returns a Hash containing the data. An empty hash is returned if From 78e9f3389e17231ef0c3af934a63a3a8ef8fbe93 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 11:42:17 -0800 Subject: [PATCH 27/37] Rubocop: Style/IndentationWidth --- lib/jekyll/collection.rb | 2 +- lib/jekyll/document.rb | 2 +- lib/jekyll/filters.rb | 2 +- lib/jekyll/tags/highlight.rb | 2 +- lib/jekyll/tags/include.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index 5d6b2728..ea6a81b6 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -187,7 +187,7 @@ module Jekyll # Returns the URL template to render collection's documents at. def url_template metadata.fetch('permalink') do - Utils.add_permalink_suffix("/:collection/:path", site.permalink_style) + Utils.add_permalink_suffix("/:collection/:path", site.permalink_style) end end diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 0d23ac88..7d7e6bb4 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -60,7 +60,7 @@ module Jekyll end Utils.deep_merge_hashes!(data, other) if data.key?('date') && !data['date'].is_a?(Time) - data['date'] = Utils.parse_date(data['date'].to_s, "Document '#{relative_path}' does not have a valid date in the YAML front matter.") + data['date'] = Utils.parse_date(data['date'].to_s, "Document '#{relative_path}' does not have a valid date in the YAML front matter.") end data end diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index be3efa62..734457cb 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -223,7 +223,7 @@ module Jekyll # Returns the filtered array of objects def sort(input, property = nil, nils = "first") if input.nil? - raise ArgumentError.new("Cannot sort a null object.") + raise ArgumentError.new("Cannot sort a null object.") end if property.nil? input.sort diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index 027865cd..5881fa58 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -21,7 +21,7 @@ module Jekyll key, value = opt.split('=') # If a quoted list, convert to array if value && value.include?("\"") - value.delete!('"') + value.delete!('"') value = value.split end @highlight_options[key.to_sym] = value || true diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index b92e5b85..847e6638 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -56,7 +56,7 @@ module Jekyll def validate_file_name(file) if file !~ /^[a-zA-Z0-9_\/\.-]+$/ || file =~ /\.\// || file =~ /\/\./ - raise ArgumentError.new <<-eos + raise ArgumentError.new <<-eos Invalid syntax for include tag. File contains invalid characters or sequences: #{file} From 085a778b0a9b7e87f9b1698e31fc745ac9de2118 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 11:46:25 -0800 Subject: [PATCH 28/37] Rubocop: Style/NestedTernaryOperator - Ternary operators must not be nested. Prefer if/else constructs instead. --- lib/jekyll/commands/serve.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index 507a8c71..29408fe2 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -123,7 +123,14 @@ module Jekyll private def launch_browser(server, opts) - command = Utils::Platforms.windows?? "start" : Utils::Platforms.osx?? "open" : "xdg-open" + command = + if Utils::Platforms.windows? + "start" + elsif Utils::Platforms.osx? + "open" + else + "xdg-open" + end system command, server_address(server, opts) end From ec83ef60b5731cf6fac391f9c7f889a0f35bd7df Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 11:49:54 -0800 Subject: [PATCH 29/37] Rubocop: Lint/UselessAssignment --- lib/jekyll/converters/markdown/redcarpet_parser.rb | 1 + lib/jekyll/document.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/converters/markdown/redcarpet_parser.rb b/lib/jekyll/converters/markdown/redcarpet_parser.rb index 12b4f3fb..79133a2a 100644 --- a/lib/jekyll/converters/markdown/redcarpet_parser.rb +++ b/lib/jekyll/converters/markdown/redcarpet_parser.rb @@ -7,6 +7,7 @@ module Jekyll code = code.to_s code = code.sub(/
/, "
")
             code = code.sub(/<\/pre>/, "
") + code end end diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 7d7e6bb4..42881309 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -278,7 +278,7 @@ module Jekyll def post_read if DATE_FILENAME_MATCHER =~ relative_path - m, cats, date, slug, ext = *relative_path.match(DATE_FILENAME_MATCHER) + _, _, date, slug, ext = *relative_path.match(DATE_FILENAME_MATCHER) merge_data!({ "slug" => slug, "ext" => ext From be3666fcf05b3f61208df606911000071e7d895f Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 11:51:14 -0800 Subject: [PATCH 30/37] Rubocop: Do not use unless with else - Rewrite these with the positive case first --- lib/jekyll.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 6c5d8f10..8b92a045 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -156,10 +156,10 @@ module Jekyll clean_path = File.expand_path(questionable_path, "/") clean_path = clean_path.sub(/\A\w\:\//, '/') - unless clean_path.start_with?(base_directory.sub(/\A\w\:\//, '/')) - File.join(base_directory, clean_path) - else + if clean_path.start_with?(base_directory.sub(/\A\w\:\//, '/')) clean_path + else + File.join(base_directory, clean_path) end end From 086e85ca9eab3c5a6f78babd3452428afa88089b Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 12:01:23 -0800 Subject: [PATCH 31/37] Rubocop: Style/PerlBackrefs - Avoid the use of Perl-style backrefs --- lib/jekyll/convertible.rb | 2 +- lib/jekyll/document.rb | 2 +- lib/jekyll/tags/highlight.rb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index b510d306..d9298f4f 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -47,7 +47,7 @@ module Jekyll merged_file_read_opts(opts)) if content =~ /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m self.content = $POSTMATCH - self.data = SafeYAML.load($1) + self.data = SafeYAML.load(Regexp.last_match(1)) end rescue SyntaxError => e Jekyll.logger.warn "YAML Exception reading #{File.join(base, name)}: #{e.message}" diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 42881309..8d7c92f4 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -263,7 +263,7 @@ module Jekyll self.content = File.read(path, merged_file_read_opts(opts)) if content =~ YAML_FRONT_MATTER_REGEXP self.content = $POSTMATCH - data_file = SafeYAML.load($1) + data_file = SafeYAML.load(Regexp.last_match(1)) merge_data!(data_file) if data_file end diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index 5881fa58..a7dbd519 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -13,11 +13,11 @@ module Jekyll def initialize(tag_name, markup, tokens) super if markup.strip =~ SYNTAX - @lang = $1.downcase + @lang = Regexp.last_match(1).downcase @highlight_options = {} - if defined?($2) && $2 != '' + if defined?(Regexp.last_match(2)) && Regexp.last_match(2) != '' # Split along 3 possible forms -- key="", key=value, or key - $2.scan(/(?:\w="[^"]*"|\w=\w|\w)+/) do |opt| + Regexp.last_match(2).scan(/(?:\w="[^"]*"|\w=\w|\w)+/) do |opt| key, value = opt.split('=') # If a quoted list, convert to array if value && value.include?("\"") From 6711234d5fba1419e89ae442519e4bbb7c89985e Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 12:05:54 -0800 Subject: [PATCH 32/37] Rubocop: Style/BlockDelimiters - Avoid using {...} for multi-line blocks --- lib/jekyll/convertible.rb | 8 ++++---- lib/jekyll/filters.rb | 4 ++-- lib/jekyll/reader.rb | 4 ++-- lib/jekyll/site.rb | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index d9298f4f..c61807f9 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -87,9 +87,9 @@ module Jekyll if converters.all? { |c| c.is_a?(Jekyll::Converters::Identity) } ext else - converters.map { |c| + converters.map do |c| c.output_ext(ext) unless c.is_a?(Jekyll::Converters::Identity) - }.compact.last + end.compact.last end end @@ -122,9 +122,9 @@ module Jekyll # # Returns the Hash representation of this Convertible. def to_liquid(attrs = nil) - further_data = Hash[(attrs || self.class::ATTRIBUTES_FOR_LIQUID).map { |attribute| + further_data = Hash[(attrs || self.class::ATTRIBUTES_FOR_LIQUID).map do |attribute| [attribute, send(attribute)] - }] + end] defaults = site.frontmatter_defaults.all(relative_path, type) Utils.deep_merge_hashes defaults, Utils.deep_merge_hashes(data, further_data) diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index 734457cb..9b2cad9d 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -238,7 +238,7 @@ module Jekyll "'#{nils}' is not a valid nils order. It must be 'first' or 'last'.") end - input.sort { |apple, orange| + input.sort do |apple, orange| apple_property = item_property(apple, property) orange_property = item_property(orange, property) @@ -249,7 +249,7 @@ module Jekyll else apple_property <=> orange_property end - } + end end end diff --git a/lib/jekyll/reader.rb b/lib/jekyll/reader.rb index 2926971b..c9ded560 100644 --- a/lib/jekyll/reader.rb +++ b/lib/jekyll/reader.rb @@ -68,11 +68,11 @@ module Jekyll # # Returns nothing. def retrieve_dirs(_base, dir, dot_dirs) - dot_dirs.map { |file| + dot_dirs.map do |file| dir_path = site.in_source_dir(dir, file) rel_path = File.join(dir, file) @site.reader.read_directories(rel_path) unless @site.dest.sub(/\/$/, '') == dir_path - } + end end # Retrieve all the pages from the current directory, diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 3ed60c12..fcd4bf77 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -196,9 +196,9 @@ module Jekyll # # Returns nothing. def write - each_site_file { |item| + each_site_file do |item| item.write(dest) if regenerator.regenerate?(item) - } + end regenerator.write_metadata Jekyll::Hooks.trigger :site, :post_write, self end From 04e635b10cc991a742e210079be776cda133f34b Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 12:06:40 -0800 Subject: [PATCH 33/37] Rubocop: Style/SpaceInsideRangeLiteral - Space inside range literal --- lib/jekyll/document.rb | 2 +- lib/jekyll/page.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 8d7c92f4..3b41076c 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -113,7 +113,7 @@ module Jekyll # Returns the cleaned relative path of the document. def cleaned_relative_path @cleaned_relative_path ||= - relative_path[0 .. -extname.length - 1].sub(collection.relative_directory, "") + relative_path[0..-extname.length - 1].sub(collection.relative_directory, "") end # Determine whether the document is a YAML file. diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 019cb095..78f7e041 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -106,7 +106,7 @@ module Jekyll # Returns nothing. def process(name) self.ext = File.extname(name) - self.basename = name[0 .. -ext.length - 1] + self.basename = name[0..-ext.length - 1] end # Add any necessary layouts to this post From c1c8b6dbf733ccacfe1b260e7c23927aeb7aa34f Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 12:07:34 -0800 Subject: [PATCH 34/37] Rubocop: Style/SpaceInsideHashLiteralBraces --- lib/jekyll/document.rb | 2 +- lib/jekyll/filters.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 3b41076c..38ced675 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -283,7 +283,7 @@ module Jekyll "slug" => slug, "ext" => ext }) - merge_data!({"date" => date}) if data['date'].nil? || data['date'].to_i == site.time.to_i + merge_data!({ "date" => date }) if data['date'].nil? || data['date'].to_i == site.time.to_i data['title'] ||= slug.split('-').select(&:capitalize).join(' ') end populate_categories diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index 9b2cad9d..36760d65 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -194,7 +194,7 @@ module Jekyll input.group_by do |item| item_property(item, property).to_s end.inject([]) do |memo, i| - memo << {"name" => i.first, "items" => i.last} + memo << { "name" => i.first, "items" => i.last } end else input From cce848d3d81b1b6a992911289bf634bb9abffdea Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 12:12:17 -0800 Subject: [PATCH 35/37] Rubocop: Avoid single-line method definitions --- lib/jekyll/drops/url_drop.rb | 54 ++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/lib/jekyll/drops/url_drop.rb b/lib/jekyll/drops/url_drop.rb index 32aae194..2815edf7 100644 --- a/lib/jekyll/drops/url_drop.rb +++ b/lib/jekyll/drops/url_drop.rb @@ -35,17 +35,49 @@ module Jekyll category_set.to_a.join('/') end - def year; @obj.date.strftime("%Y"); end - def month; @obj.date.strftime("%m"); end - def day; @obj.date.strftime("%d"); end - def hour; @obj.date.strftime("%H"); end - def minute; @obj.date.strftime("%M"); end - def second; @obj.date.strftime("%S"); end - def i_day; @obj.date.strftime("%-d"); end - def i_month; @obj.date.strftime("%-m"); end - def short_month; @obj.date.strftime("%b"); end - def short_year; @obj.date.strftime("%y"); end - def y_day; @obj.date.strftime("%j"); end + def year + @obj.date.strftime("%Y") + end + + def month + @obj.date.strftime("%m") + end + + def day + @obj.date.strftime("%d") + end + + def hour + @obj.date.strftime("%H") + end + + def minute + @obj.date.strftime("%M") + end + + def second + @obj.date.strftime("%S") + end + + def i_day + @obj.date.strftime("%-d") + end + + def i_month + @obj.date.strftime("%-m") + end + + def short_month + @obj.date.strftime("%b") + end + + def short_year + @obj.date.strftime("%y") + end + + def y_day + @obj.date.strftime("%j") + end end end end From ab3d906e04dc21bc8385829e2d356f0f4a814ac2 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 12:14:00 -0800 Subject: [PATCH 36/37] Rubocop: Style/ParenthesesAroundCondition - Don't use parentheses around the condition of an if --- lib/jekyll/plugin_manager.rb | 2 +- lib/jekyll/regenerator.rb | 2 +- lib/jekyll/utils.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/plugin_manager.rb b/lib/jekyll/plugin_manager.rb index d4ad9951..502c4a73 100644 --- a/lib/jekyll/plugin_manager.rb +++ b/lib/jekyll/plugin_manager.rb @@ -76,7 +76,7 @@ module Jekyll # # Returns an Array of plugin search paths def plugins_path - if (site.config['plugins_dir'] == Jekyll::Configuration::DEFAULTS['plugins_dir']) + if site.config['plugins_dir'] == Jekyll::Configuration::DEFAULTS['plugins_dir'] [site.in_source_dir(site.config['plugins_dir'])] else Array(site.config['plugins_dir']).map { |d| File.expand_path(d) } diff --git a/lib/jekyll/regenerator.rb b/lib/jekyll/regenerator.rb index bb9284aa..20522350 100644 --- a/lib/jekyll/regenerator.rb +++ b/lib/jekyll/regenerator.rb @@ -115,7 +115,7 @@ module Jekyll # # Returns nothing. def add_dependency(path, dependency) - return if (metadata[path].nil? || @disabled) + return if metadata[path].nil? || @disabled unless metadata[path]["deps"].include? dependency metadata[path]["deps"] << dependency diff --git a/lib/jekyll/utils.rb b/lib/jekyll/utils.rb index 1d81e0f0..6b6e8f1c 100644 --- a/lib/jekyll/utils.rb +++ b/lib/jekyll/utils.rb @@ -62,7 +62,7 @@ module Jekyll end def value_from_singular_key(hash, key) - hash[key] if (hash.key?(key) || (hash.default_proc && hash[key])) + hash[key] if hash.key?(key) || (hash.default_proc && hash[key]) end def value_from_plural_key(hash, key) From 060904d8096a691e73d87fd4784993f358036bdb Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 12:16:36 -0800 Subject: [PATCH 37/37] Rubocop: Style/TrailingWhitespace - Trailing whitespace detected Rubocop: Style/EmptyLines - Extra blank line detected Rubocop: Style/EmptyLinesAroundBlockBody - Extra empty line detected at block body beginning --- lib/jekyll/tags/post_url.rb | 1 - lib/jekyll/utils/ansi.rb | 2 +- lib/jekyll/utils/platforms.rb | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb index 5b3df093..6c4c9f8e 100644 --- a/lib/jekyll/tags/post_url.rb +++ b/lib/jekyll/tags/post_url.rb @@ -66,7 +66,6 @@ eos # New matching method did not match, fall back to old method # with deprecation warning if this matches - site.posts.docs.each do |p| next unless @post.deprecated_equality p Jekyll::Deprecator.deprecation_message "A call to '{{ post_url #{@post.name} }}' did not match " \ diff --git a/lib/jekyll/utils/ansi.rb b/lib/jekyll/utils/ansi.rb index 05f38429..933b4323 100644 --- a/lib/jekyll/utils/ansi.rb +++ b/lib/jekyll/utils/ansi.rb @@ -33,7 +33,7 @@ module Jekyll def has?(str) !!(str =~ MATCH) end - + # Reset the color back to the default color so that you do not leak any # colors when you move onto the next line. This is probably normally # used as part of a wrapper so that we don't leak colors. diff --git a/lib/jekyll/utils/platforms.rb b/lib/jekyll/utils/platforms.rb index abc1598c..d431021f 100644 --- a/lib/jekyll/utils/platforms.rb +++ b/lib/jekyll/utils/platforms.rb @@ -19,7 +19,6 @@ module Jekyll { :windows? => /mswin|mingw|cygwin/, :linux? => /linux/, \ :osx? => /darwin|mac os/, :unix? => /solaris|bsd/ }.each do |k, v| - define_method k do !!( RbConfig::CONFIG["host_os"] =~ v