Bump rubocop to use `v0.50.x` (#6368)

Merge pull request 6368
This commit is contained in:
ashmaroli 2017-09-22 18:36:32 +05:30 committed by jekyllbot
parent e083f93ed8
commit 00bad8bfe5
29 changed files with 45 additions and 50 deletions

View File

@ -21,7 +21,7 @@ Layout/EmptyLinesAroundAccessModifier:
Layout/EmptyLinesAroundModuleBody: Layout/EmptyLinesAroundModuleBody:
Enabled: false Enabled: false
Layout/EndOfLine: Layout/EndOfLine:
EnforcedStyle: lf EnforcedStyle: native
Layout/ExtraSpacing: Layout/ExtraSpacing:
AllowForAlignment: true AllowForAlignment: true
Layout/FirstParameterIndentation: Layout/FirstParameterIndentation:
@ -44,10 +44,14 @@ Layout/SpaceInsideBrackets:
Enabled: false Enabled: false
Lint/EndAlignment: Lint/EndAlignment:
Severity: error Severity: error
Lint/RescueWithoutErrorClass:
Enabled: false
Lint/UnreachableCode: Lint/UnreachableCode:
Severity: error Severity: error
Lint/UselessAccessModifier: Lint/UselessAccessModifier:
Enabled: false Enabled: false
Lint/Void:
Enabled: false
Metrics/AbcSize: Metrics/AbcSize:
Max: 21 Max: 21
Metrics/BlockLength: Metrics/BlockLength:
@ -82,6 +86,10 @@ Metrics/ParameterLists:
Max: 4 Max: 4
Metrics/PerceivedComplexity: Metrics/PerceivedComplexity:
Max: 8 Max: 8
Naming/FileName:
Enabled: false
Naming/HeredocDelimiterNaming:
Enabled: false
Security/MarshalLoad: Security/MarshalLoad:
Exclude: Exclude:
- !ruby/regexp /test\/.*.rb$/ - !ruby/regexp /test\/.*.rb$/
@ -109,8 +117,8 @@ Style/Documentation:
- !ruby/regexp /features\/.*.rb$/ - !ruby/regexp /features\/.*.rb$/
Style/DoubleNegation: Style/DoubleNegation:
Enabled: false Enabled: false
Style/FileName: Style/Encoding:
Enabled: false EnforcedStyle: when_needed
Style/GuardClause: Style/GuardClause:
Enabled: false Enabled: false
Style/HashSyntax: Style/HashSyntax:

View File

@ -30,7 +30,7 @@ group :test do
gem "nokogiri", RUBY_VERSION >= "2.2" ? "~> 1.7" : "~> 1.7.0" gem "nokogiri", RUBY_VERSION >= "2.2" ? "~> 1.7" : "~> 1.7.0"
gem "rspec" gem "rspec"
gem "rspec-mocks" gem "rspec-mocks"
gem "rubocop", "~> 0.49.1" gem "rubocop", "~> 0.50.0"
gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__) gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__)
gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__) gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__)

View File

@ -1,4 +1,3 @@
# coding: utf-8
# frozen_string_literal: true # frozen_string_literal: true
lib = File.expand_path("lib", __dir__) lib = File.expand_path("lib", __dir__)

View File

@ -119,7 +119,7 @@ module Jekyll
# timezone - the IANA Time Zone # timezone - the IANA Time Zone
# #
# Returns nothing # Returns nothing
# rubocop:disable Style/AccessorMethodName # rubocop:disable Naming/AccessorMethodName
def set_timezone(timezone) def set_timezone(timezone)
ENV["TZ"] = if Utils::Platforms.really_windows? ENV["TZ"] = if Utils::Platforms.really_windows?
Utils::WinTZ.calculate(timezone) Utils::WinTZ.calculate(timezone)
@ -127,7 +127,7 @@ module Jekyll
timezone timezone
end end
end end
# rubocop:enable Style/AccessorMethodName # rubocop:enable Naming/AccessorMethodName
# Public: Fetch the logger instance for this Jekyll process. # Public: Fetch the logger instance for this Jekyll process.
# #

View File

@ -86,7 +86,7 @@ module Jekyll
def urls_only_differ_by_case(site) def urls_only_differ_by_case(site)
urls_only_differ_by_case = false urls_only_differ_by_case = false
urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest) urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
urls.each do |_case_insensitive_url, real_urls| urls.each_value do |real_urls|
next unless real_urls.uniq.size > 1 next unless real_urls.uniq.size > 1
urls_only_differ_by_case = true urls_only_differ_by_case = true
Jekyll.logger.warn "Warning:", "The following URLs only differ" \ Jekyll.logger.warn "Warning:", "The following URLs only differ" \

View File

@ -27,7 +27,7 @@ module Jekyll
super || super(req, res, ".html") || super(req, res, "#{basename}.html") super || super(req, res, ".html") || super(req, res, "#{basename}.html")
end end
# rubocop:disable Style/MethodName # rubocop:disable Naming/MethodName
def do_GET(req, res) def do_GET(req, res)
rtn = super rtn = super
validate_and_ensure_charset(req, res) validate_and_ensure_charset(req, res)

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
module Jekyll module Jekyll

View File

@ -27,7 +27,7 @@ module Jekyll
# Rubocop does not allow reader methods to have names starting with `get_` # Rubocop does not allow reader methods to have names starting with `get_`
# To ensure compatibility, this check has been disabled on this method # To ensure compatibility, this check has been disabled on this method
# #
# rubocop:disable Style/AccessorMethodName # rubocop:disable Naming/AccessorMethodName
def get_processor def get_processor
case @config["markdown"].downcase case @config["markdown"].downcase
when "redcarpet" then return RedcarpetParser.new(@config) when "redcarpet" then return RedcarpetParser.new(@config)
@ -37,7 +37,7 @@ module Jekyll
custom_processor custom_processor
end end
end end
# rubocop:enable Style/AccessorMethodName # rubocop:enable Naming/AccessorMethodName
# Public: Provides you with a list of processors, the ones we # Public: Provides you with a list of processors, the ones we
# support internally and the ones that you have provided to us (if you # support internally and the ones that you have provided to us (if you

View File

@ -42,12 +42,14 @@ module Jekyll
end end
private private
# rubocop:disable Performance/HashEachMethods
def make_accessible(hash = @config) def make_accessible(hash = @config)
hash.keys.each do |key| hash.keys.each do |key|
hash[key.to_sym] = hash[key] hash[key.to_sym] = hash[key]
make_accessible(hash[key]) if hash[key].is_a?(Hash) make_accessible(hash[key]) if hash[key].is_a?(Hash)
end end
end end
# rubocop:enable Performance/HashEachMethods
# config[kramdown][syntax_higlighter] > # config[kramdown][syntax_higlighter] >
# config[kramdown][enable_coderay] > # config[kramdown][enable_coderay] >

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
require "set" require "set"

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
module Jekyll module Jekyll

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
module Jekyll module Jekyll

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
module Jekyll module Jekyll

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
module Jekyll module Jekyll

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
module Jekyll module Jekyll

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
module Jekyll module Jekyll

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
module Jekyll module Jekyll

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
module Jekyll module Jekyll

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
module Jekyll module Jekyll

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
require "csv" require "csv"
@ -25,7 +24,7 @@ module Jekyll
# Sorts posts, pages, and static files. # Sorts posts, pages, and static files.
def sort_files! def sort_files!
site.collections.values.each { |c| c.docs.sort! } site.collections.each_value { |c| c.docs.sort! }
site.pages.sort_by!(&:name) site.pages.sort_by!(&:name)
site.static_files.sort_by!(&:relative_path) site.static_files.sort_by!(&:relative_path)
end end

View File

@ -14,7 +14,7 @@ module Jekyll
# #
# Returns nothing. # Returns nothing.
def read def read
site.collections.each do |_, collection| site.collections.each_value do |collection|
collection.read unless SPECIAL_COLLECTIONS.include?(collection.label) collection.read unless SPECIAL_COLLECTIONS.include?(collection.label)
end end
end end

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
module Jekyll module Jekyll

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
require "csv" require "csv"
@ -85,11 +84,11 @@ module Jekyll
# #
# Returns nothing # Returns nothing
def reset def reset
if config["time"] self.time = if config["time"]
self.time = Utils.parse_date(config["time"].to_s, "Invalid time in _config.yml.") Utils.parse_date(config["time"].to_s, "Invalid time in _config.yml.")
else else
self.time = Time.now Time.now
end end
self.layouts = {} self.layouts = {}
self.pages = [] self.pages = []
self.static_files = [] self.static_files = []
@ -238,7 +237,7 @@ module Jekyll
posts.docs.each do |p| posts.docs.each do |p|
p.data[post_attr].each { |t| hash[t] << p } if p.data[post_attr] p.data[post_attr].each { |t| hash[t] << p } if p.data[post_attr]
end end
hash.values.each { |posts| posts.sort!.reverse! } hash.each_value { |posts| posts.sort!.reverse! }
hash hash
end end
@ -449,7 +448,7 @@ module Jekyll
private private
def render_docs(payload) def render_docs(payload)
collections.each do |_, collection| collections.each_value do |collection|
collection.docs.each do |document| collection.docs.each do |document|
if regenerator.regenerate?(document) if regenerator.regenerate?(document)
document.output = Jekyll::Renderer.new(self, document, payload).run document.output = Jekyll::Renderer.new(self, document, payload).run

View File

@ -18,13 +18,13 @@ module Jekyll
@lang = Regexp.last_match(1).downcase @lang = Regexp.last_match(1).downcase
@highlight_options = parse_options(Regexp.last_match(2)) @highlight_options = parse_options(Regexp.last_match(2))
else else
raise SyntaxError, <<-eos raise SyntaxError, <<-MSG
Syntax Error in tag 'highlight' while parsing the following markup: Syntax Error in tag 'highlight' while parsing the following markup:
#{markup} #{markup}
Valid syntax: highlight <lang> [linenos] Valid syntax: highlight <lang> [linenos]
eos MSG
end end
end end
@ -95,14 +95,14 @@ eos
) )
if highlighted_code.nil? if highlighted_code.nil?
Jekyll.logger.error <<eos Jekyll.logger.error <<-MSG
There was an error highlighting your code: There was an error highlighting your code:
#{code} #{code}
While attempting to convert the above code, Pygments.rb returned an unacceptable value. While attempting to convert the above code, Pygments.rb returned an unacceptable value.
This is usually a timeout problem solved by running `jekyll build` again. This is usually a timeout problem solved by running `jekyll build` again.
eos MSG
raise ArgumentError, "Pygments.rb returned an unacceptable value "\ raise ArgumentError, "Pygments.rb returned an unacceptable value "\
"when attempting to highlight some code." "when attempting to highlight some code."
end end

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
module Jekyll module Jekyll
@ -61,7 +60,7 @@ module Jekyll
def validate_file_name(file) def validate_file_name(file)
if file !~ %r!^[a-zA-Z0-9_/\.-]+$! || file =~ %r!\./! || file =~ %r!/\.! if file !~ %r!^[a-zA-Z0-9_/\.-]+$! || file =~ %r!\./! || file =~ %r!/\.!
raise ArgumentError, <<-eos raise ArgumentError, <<-MSG
Invalid syntax for include tag. File contains invalid characters or sequences: Invalid syntax for include tag. File contains invalid characters or sequences:
#{file} #{file}
@ -70,14 +69,14 @@ Valid syntax:
#{syntax_example} #{syntax_example}
eos MSG
end end
end end
def validate_params def validate_params
full_valid_syntax = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z! full_valid_syntax = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z!
unless @params =~ full_valid_syntax unless @params =~ full_valid_syntax
raise ArgumentError, <<-eos raise ArgumentError, <<-MSG
Invalid syntax for include tag: Invalid syntax for include tag:
#{@params} #{@params}
@ -86,7 +85,7 @@ Valid syntax:
#{syntax_example} #{syntax_example}
eos MSG
end end
end end

View File

@ -24,11 +24,11 @@ module Jekyll
return item.url if item.relative_path == "/#{@relative_path}" return item.url if item.relative_path == "/#{@relative_path}"
end end
raise ArgumentError, <<eos raise ArgumentError, <<-MSG
Could not find document '#{@relative_path}' in tag '#{self.class.tag_name}'. Could not find document '#{@relative_path}' in tag '#{self.class.tag_name}'.
Make sure the document exists and the path is correct. Make sure the document exists and the path is correct.
eos MSG
end end
end end
end end

View File

@ -60,13 +60,13 @@ module Jekyll
begin begin
@post = PostComparer.new(@orig_post) @post = PostComparer.new(@orig_post)
rescue => e rescue => e
raise Jekyll::Errors::PostURLError, <<-eos raise Jekyll::Errors::PostURLError, <<-MSG
Could not parse name of post "#{@orig_post}" in tag 'post_url'. Could not parse name of post "#{@orig_post}" in tag 'post_url'.
Make sure the post exists and the name is correct. Make sure the post exists and the name is correct.
#{e.class}: #{e.message} #{e.class}: #{e.message}
eos MSG
end end
end end
@ -90,11 +90,11 @@ eos
return p.url return p.url
end end
raise Jekyll::Errors::PostURLError, <<-eos raise Jekyll::Errors::PostURLError, <<-MSG
Could not find post "#{@orig_post}" in tag 'post_url'. Could not find post "#{@orig_post}" in tag 'post_url'.
Make sure the post exists and the name is correct. Make sure the post exists and the name is correct.
eos MSG
end end
end end
end end

View File

@ -8,7 +8,7 @@ class TestAnsi < JekyllUnitTest
@subject = Jekyll::Utils::Ansi @subject = Jekyll::Utils::Ansi
end end
Jekyll::Utils::Ansi::COLORS.each do |color, _val| Jekyll::Utils::Ansi::COLORS.each_key do |color|
should "respond_to? #{color}" do should "respond_to? #{color}" do
assert @subject.respond_to?(color) assert @subject.respond_to?(color)
end end

View File

@ -1,3 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true # frozen_string_literal: true
require "helper" require "helper"