Fix warnings

This removes the following warnings:

- /lib/jekyll/configuration.rb:151: warning: instance variable @default_config_file not initialized
- /lib/jekyll/converter.rb:12: warning: instance variable @highlighter_prefix not initialized
- /lib/jekyll/converter.rb:24: warning: instance variable @highlighter_suffix not initialized
- /lib/jekyll/converters/markdown.rb:9: warning: instance variable @setup not initialized
- /lib/jekyll/converters/markdown/kramdown_parser.rb:60: warning: instance variable @highlighter not initialized
- /lib/jekyll/frontmatter_defaults.rb:97: warning: shadowing outer local variable - path
- /lib/jekyll/plugin.rb:66: warning: instance variable @safe not initialized
- /lib/jekyll/regenerator.rb:147: warning: instance variable @disabled not initialized
- /test/test_convertible.rb:40: warning: ambiguous first argument; put parentheses or a space even after `/' operator
- /test/test_filters.rb:154: warning: ambiguous first argument; put parentheses or a space even after `/' operator
- /test/test_new_command.rb:84: warning: ambiguous first argument; put parentheses or a space even after `/' operator
- /test/test_site.rb:234: warning: assigned but unused variable - site
- /test/test_site.rb:240: warning: assigned but unused variable - site
- /test/test_site.rb:522: warning: assigned but unused variable - source
- /test/test_tags.rb:153: warning: ambiguous first argument; put parentheses or a space even after `/' operator
- /test/test_tags.rb:425: warning: ambiguous first argument; put parentheses or a space even after `/' operator
- /test/test_tags.rb:449: warning: ambiguous first argument; put parentheses or a space even after `/' operator
- /test/test_tags.rb:496: warning: ambiguous first argument; put parentheses or a space even after `/' operator
- /test/test_tags.rb:496: warning: instance variable @result not initialized
- /test/test_tags.rb:511: warning: ambiguous first argument; put parentheses or a space even after `/' operator
- /test/test_tags.rb:773: warning: ambiguous first argument; put parentheses or a space even after `/' operator
- /test/test_tags.rb:773: warning: instance variable @result not initialized
- /test/test_tags.rb:788: warning: ambiguous first argument; put parentheses or a space even after `/' operator
- /test/test_url.rb:66: warning: shadowing outer local variable - doc
- /lib/jekyll/url.rb:119:in `escape_path': warning: URI.escape is obsolete
This commit is contained in:
Florian Thomas 2016-02-17 22:27:38 +01:00
parent f0b8db0d72
commit d213981a24
13 changed files with 33 additions and 25 deletions

View File

@ -148,7 +148,7 @@ module Jekyll
Jekyll.logger.info "Configuration file:", file
next_config
rescue SystemCallError
if @default_config_file
if @default_config_file ||= nil
Jekyll.logger.warn "Configuration file:", "none"
{}
else

View File

@ -8,7 +8,9 @@ module Jekyll
#
# Returns the String prefix.
def self.highlighter_prefix(highlighter_prefix = nil)
@highlighter_prefix = highlighter_prefix if highlighter_prefix
if !defined?(@highlighter_prefix) || !highlighter_prefix.nil?
@highlighter_prefix = highlighter_prefix
end
@highlighter_prefix
end
@ -20,7 +22,9 @@ module Jekyll
#
# Returns the String suffix.
def self.highlighter_suffix(highlighter_suffix = nil)
@highlighter_suffix = highlighter_suffix if highlighter_suffix
if !defined?(@highlighter_suffix) || !highlighter_suffix.nil?
@highlighter_suffix = highlighter_suffix
end
@highlighter_suffix
end

View File

@ -6,7 +6,7 @@ module Jekyll
safe true
def setup
return if @setup
return if @setup ||= false
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"]

View File

@ -18,6 +18,7 @@ module Jekyll
Jekyll::External.require_with_graceful_fail "kramdown"
@main_fallback_highlighter = config["highlighter"] || "rouge"
@config = config["kramdown"] || {}
@highlighter = nil
setup
end

View File

@ -94,8 +94,8 @@ module Jekyll
return true if !scope.key?('path') || scope['path'].empty?
scope_path = Pathname.new(scope['path'])
Pathname.new(sanitize_path(path)).ascend do |path|
if path.to_s == scope_path.to_s
Pathname.new(sanitize_path(path)).ascend do |ascended_path|
if ascended_path.to_s == scope_path.to_s
return true
end
end

View File

@ -60,7 +60,7 @@ module Jekyll
#
# Returns the safety Boolean.
def self.safe(safe = nil)
if safe
if !defined?(@safe) || !safe.nil?
@safe = safe
end
@safe || false

View File

@ -1,6 +1,8 @@
module Jekyll
class Regenerator
attr_reader :site, :metadata, :cache
attr_accessor :disabled
private :disabled, :disabled=
def initialize(site)
@site = site
@ -115,7 +117,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
@ -144,8 +146,8 @@ module Jekyll
#
# Returns a Boolean (true for disabled, false for enabled).
def disabled?
@disabled = !site.incremental? if @disabled.nil?
@disabled
self.disabled = !site.incremental? if disabled.nil?
disabled
end
private

View File

@ -37,7 +37,7 @@ class TestConvertible < JekyllUnitTest
out = capture_stderr do
@convertible.read_yaml(@base, 'exploit_front_matter.erb')
end
refute_match /undefined class\/module DoesNotExist/, out
refute_match(/undefined class\/module DoesNotExist/, out)
end
should "not parse if there is encoding error in file" do

View File

@ -151,7 +151,7 @@ class TestFilters < JekyllUnitTest
end
should "format a time with xmlschema" do
assert_match /2014-05-10T00:10:07/, @filter.date_to_xmlschema(@time_as_numeric)
assert_match(/2014-05-10T00:10:07/, @filter.date_to_xmlschema(@time_as_numeric))
end
should "format a time according to RFC-822" do

View File

@ -81,7 +81,7 @@ class TestNewCommand < JekyllUnitTest
should 'force created folder' do
capture_stdout { Jekyll::Commands::New.process(@args) }
output = capture_stdout { Jekyll::Commands::New.process(@args, '--force') }
assert_match /New jekyll site installed in/, output
assert_match(/New jekyll site installed in/, output)
end
end

View File

@ -231,13 +231,13 @@ class TestSite < JekyllUnitTest
context 'error handling' do
should "raise if destination is included in source" do
assert_raises Jekyll::Errors::FatalException do
site = Site.new(site_configuration('destination' => source_dir))
Site.new(site_configuration('destination' => source_dir))
end
end
should "raise if destination is source" do
assert_raises Jekyll::Errors::FatalException do
site = Site.new(site_configuration('destination' => File.join(source_dir, "..")))
Site.new(site_configuration('destination' => File.join(source_dir, "..")))
end
end
end
@ -519,7 +519,6 @@ class TestSite < JekyllUnitTest
contacts_html = @site.pages.find { |p| p.name == "contacts.html" }
@site.process
source = @site.in_source_dir(contacts_html.path)
dest = File.expand_path(contacts_html.destination(@site.dest))
mtime1 = File.stat(dest).mtime.to_i # first run must generate dest file

View File

@ -150,7 +150,7 @@ CONTENT
end
should "not cause a markdown error" do
refute_match /markdown\-html\-error/, @result
refute_match(/markdown\-html\-error/, @result)
end
should "render markdown with pygments" do
@ -422,7 +422,7 @@ CONTENT
end
should "not cause an error" do
refute_match /markdown\-html\-error/, @result
refute_match(/markdown\-html\-error/, @result)
end
should "have the url to the \"complex\" post from 2008-11-21" do
@ -446,7 +446,7 @@ CONTENT
end
should "not cause an error" do
refute_match /markdown\-html\-error/, @result
refute_match(/markdown\-html\-error/, @result)
end
should "have the url to the \"complex\" post from 2008-11-21" do
@ -493,7 +493,8 @@ title: Include symlink
CONTENT
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
refute_match /SYMLINK TEST/, @result
@result ||= ''
refute_match(/SYMLINK TEST/, @result)
end
should "not expose the existence of symlinked files" do
@ -508,7 +509,7 @@ title: Include symlink
CONTENT
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
assert_match /should exist and should not be a symlink/, ex.message
assert_match(/should exist and should not be a symlink/, ex.message)
end
end
@ -770,7 +771,8 @@ title: Include symlink
CONTENT
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
refute_match /SYMLINK TEST/, @result
@result ||= ''
refute_match(/SYMLINK TEST/, @result)
end
should "not expose the existence of symlinked files" do
@ -785,7 +787,7 @@ title: Include symlink
CONTENT
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
assert_match /should exist and should not be a symlink/, ex.message
assert_match(/should exist and should not be a symlink/, ex.message)
end
end
end

View File

@ -63,12 +63,12 @@ class TestURL < JekyllUnitTest
},
})
site.read
doc = site.collections["methods"].docs.find do |doc|
matching_doc = site.collections["methods"].docs.find do |doc|
doc.relative_path == "_methods/escape-+ #%20[].md"
end
assert_equal '/methods/escape-+-20/escape-20.html', URL.new(
:template => '/methods/:title/:name:output_ext',
:placeholders => doc.url_placeholders
:placeholders => matching_doc.url_placeholders
).to_s
end