From 2c9a349f9aafab1fff4ea15bd4cf52f4cf33d00e Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jan 2016 11:06:12 -0800 Subject: [PATCH] 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