Lint Ruby code with rubocop-jekyll gem (#302)

Merge pull request 302
This commit is contained in:
Ashwin Maroli 2018-07-22 05:57:36 +05:30 committed by jekyllbot
parent 7383259267
commit d8dba4bffa
4 changed files with 13 additions and 13 deletions

View File

@ -1,5 +1,6 @@
require: rubocop-jekyll
inherit_gem:
jekyll: .rubocop.yml
rubocop-jekyll: .rubocop.yml
AllCops:
TargetRubyVersion: 2.3

View File

@ -32,5 +32,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.15"
spec.add_development_dependency "html-proofer", "~> 3.7"
spec.add_development_dependency "rspec", "~> 3.5"
spec.add_development_dependency "rubocop", "~> 0.56.0"
spec.add_development_dependency "rubocop-jekyll", "~> 0.1.0"
end

View File

@ -47,11 +47,12 @@ module Jekyll
def payload
# site_payload is an instance of UnifiedPayloadDrop. See https://git.io/v5ajm
Jekyll::Utils.deep_merge_hashes(context.registers[:site].site_payload, {
Jekyll::Utils.deep_merge_hashes(
context.registers[:site].site_payload,
"page" => context.registers[:page],
"paginator" => context["paginator"],
"seo_tag" => drop,
})
"seo_tag" => drop
)
end
def drop

View File

@ -6,8 +6,8 @@ module Jekyll
include Jekyll::SeoTag::UrlHelper
TITLE_SEPARATOR = " | "
FORMAT_STRING_METHODS = %i[
markdownify strip_html normalize_whitespace escape_once
FORMAT_STRING_METHODS = [
:markdownify, :strip_html, :normalize_whitespace, :escape_once,
].freeze
HOMEPAGE_OR_ABOUT_REGEX = %r!^/(about/)?(index.html?)?$!
@ -43,6 +43,7 @@ module Jekyll
end
# Page title with site title or description appended
# rubocop:disable Metrics/CyclomaticComplexity
def title
@title ||= begin
if site_title && page_title != site_title
@ -54,12 +55,11 @@ module Jekyll
end
end
if page_number
return page_number + @title
end
return page_number + @title if page_number
@title
end
# rubocop:enable Metrics/CyclomaticComplexity
def name
return @name if defined?(@name)
@ -187,9 +187,7 @@ module Jekyll
current = @context["paginator"]["page"]
total = @context["paginator"]["total_pages"]
if current > 1
return "Page #{current} of #{total} for "
end
return "Page #{current} of #{total} for " if current > 1
end
attr_reader :context