enable 'Lint/RescueWithoutErrorClass' Cop (#6482)

Merge pull request 6482
This commit is contained in:
ashmaroli 2017-10-28 20:54:41 +05:30 committed by jekyllbot
parent 63255ae2c1
commit 9632733efa
8 changed files with 9 additions and 9 deletions

View File

@ -44,8 +44,6 @@ 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:

View File

@ -95,7 +95,7 @@ def siteify_file(file, overrides_front_matter = {})
abort "You seem to have misplaced your #{file} file. I can haz?" unless File.exist?(file) abort "You seem to have misplaced your #{file} file. I can haz?" unless File.exist?(file)
title = begin title = begin
File.read(file).match(%r!\A# (.*)$!)[1] File.read(file).match(%r!\A# (.*)$!)[1]
rescue rescue NoMethodError
File.basename(file, ".*").downcase.capitalize File.basename(file, ".*").downcase.capitalize
end end
slug = File.basename(file, ".markdown").downcase slug = File.basename(file, ".markdown").downcase

View File

@ -135,7 +135,9 @@ module Jekyll
def url_valid?(url) def url_valid?(url)
Addressable::URI.parse(url) Addressable::URI.parse(url)
true true
rescue # Addressable::URI#parse only raises a TypeError
# https://git.io/vFfbx
rescue TypeError
Jekyll.logger.warn "Warning:", "The site URL does not seem to be valid, "\ Jekyll.logger.warn "Warning:", "The site URL does not seem to be valid, "\
"check the value of `url` in your config file." "check the value of `url` in your config file."
false false

View File

@ -49,7 +49,7 @@ module Jekyll
rescue SyntaxError => e rescue SyntaxError => e
Jekyll.logger.warn "YAML Exception reading #{filename}: #{e.message}" Jekyll.logger.warn "YAML Exception reading #{filename}: #{e.message}"
raise e if self.site.config["strict_front_matter"] raise e if self.site.config["strict_front_matter"]
rescue => e rescue StandardError => e
Jekyll.logger.warn "Error reading file #{filename}: #{e.message}" Jekyll.logger.warn "Error reading file #{filename}: #{e.message}"
raise e if self.site.config["strict_front_matter"] raise e if self.site.config["strict_front_matter"]
end end

View File

@ -266,7 +266,7 @@ module Jekyll
merge_defaults merge_defaults
read_content(opts) read_content(opts)
read_post_data read_post_data
rescue => e rescue StandardError => e
handle_read_error(e) handle_read_error(e)
end end
end end

View File

@ -96,7 +96,7 @@ module Jekyll
converters.reduce(content) do |output, converter| converters.reduce(content) do |output, converter|
begin begin
converter.convert output converter.convert output
rescue => e rescue StandardError => e
Jekyll.logger.error "Conversion error:", Jekyll.logger.error "Conversion error:",
"#{converter.class} encountered an error while "\ "#{converter.class} encountered an error while "\
"converting '#{document.relative_path}':" "converting '#{document.relative_path}':"

View File

@ -184,7 +184,7 @@ MSG
def realpath_prefixed_with?(path, dir) def realpath_prefixed_with?(path, dir)
File.exist?(path) && File.realpath(path).start_with?(dir) File.exist?(path) && File.realpath(path).start_with?(dir)
rescue rescue StandardError
false false
end end

View File

@ -59,7 +59,7 @@ module Jekyll
@orig_post = post.strip @orig_post = post.strip
begin begin
@post = PostComparer.new(@orig_post) @post = PostComparer.new(@orig_post)
rescue => e rescue StandardError => e
raise Jekyll::Errors::PostURLError, <<-MSG 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'.