Enable Lint/NoReturnInBeginEndBlocks Cop (#8457)
Merge pull request 8457
This commit is contained in:
parent
0dedc09ab3
commit
5054e57fa5
|
|
@ -93,7 +93,7 @@ Lint/NestedPercentLiteral:
|
||||||
Exclude:
|
Exclude:
|
||||||
- test/test_site.rb
|
- test/test_site.rb
|
||||||
Lint/NoReturnInBeginEndBlocks:
|
Lint/NoReturnInBeginEndBlocks:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
Lint/OutOfRangeRegexpRef:
|
Lint/OutOfRangeRegexpRef:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Lint/RaiseException:
|
Lint/RaiseException:
|
||||||
|
|
|
||||||
|
|
@ -37,28 +37,38 @@ module Jekyll
|
||||||
@sanitized_path ||= {}
|
@sanitized_path ||= {}
|
||||||
@sanitized_path[base_directory] ||= {}
|
@sanitized_path[base_directory] ||= {}
|
||||||
@sanitized_path[base_directory][questionable_path] ||= begin
|
@sanitized_path[base_directory][questionable_path] ||= begin
|
||||||
return base_directory.freeze if questionable_path.nil?
|
if questionable_path.nil?
|
||||||
|
base_directory.freeze
|
||||||
clean_path = if questionable_path.start_with?("~")
|
|
||||||
questionable_path.dup.insert(0, "/")
|
|
||||||
else
|
|
||||||
questionable_path
|
|
||||||
end
|
|
||||||
clean_path = File.expand_path(clean_path, "/")
|
|
||||||
return clean_path.freeze if clean_path.eql?(base_directory)
|
|
||||||
|
|
||||||
# remove any remaining extra leading slashes not stripped away by calling
|
|
||||||
# `File.expand_path` above.
|
|
||||||
clean_path.squeeze!("/")
|
|
||||||
|
|
||||||
if clean_path.start_with?(base_directory.sub(%r!\z!, "/"))
|
|
||||||
clean_path.freeze
|
|
||||||
else
|
else
|
||||||
clean_path.sub!(%r!\A\w:/!, "/")
|
sanitize_and_join(base_directory, questionable_path).freeze
|
||||||
join(base_directory, clean_path)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def sanitize_and_join(base_directory, questionable_path)
|
||||||
|
clean_path = if questionable_path.start_with?("~")
|
||||||
|
questionable_path.dup.insert(0, "/")
|
||||||
|
else
|
||||||
|
questionable_path
|
||||||
|
end
|
||||||
|
clean_path = File.expand_path(clean_path, "/")
|
||||||
|
return clean_path if clean_path.eql?(base_directory)
|
||||||
|
|
||||||
|
# remove any remaining extra leading slashes not stripped away by calling
|
||||||
|
# `File.expand_path` above.
|
||||||
|
clean_path.squeeze!("/")
|
||||||
|
return clean_path if clean_path.start_with?(slashed_dir_cache(base_directory))
|
||||||
|
|
||||||
|
clean_path.sub!(%r!\A\w:/!, "/")
|
||||||
|
join(base_directory, clean_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def slashed_dir_cache(base_directory)
|
||||||
|
@slashed_dir_cache ||= {}
|
||||||
|
@slashed_dir_cache[base_directory] ||= base_directory.sub(%r!\z!, "/")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue