Rubocop: Style/EmptyLiteral

- Use array literal [] instead of Array.new
 - Use hash literal {} instead of Hash.new
This commit is contained in:
Pat Hawks 2016-01-03 14:39:01 -08:00
parent ffdbeb89dd
commit 31dd0ebed5
No known key found for this signature in database
GPG Key ID: F1746FF5F18B3D1B
7 changed files with 10 additions and 10 deletions

View File

@ -95,7 +95,7 @@ module Jekyll
# list of option names and their defaults. # list of option names and their defaults.
# #
# Returns the final configuration Hash. # Returns the final configuration Hash.
def configuration(override = Hash.new) def configuration(override = {})
config = Configuration[Configuration::DEFAULTS] config = Configuration[Configuration::DEFAULTS]
override = Configuration[override].stringify_keys override = Configuration[override].stringify_keys
unless override.delete('skip_config_files') unless override.delete('skip_config_files')

View File

@ -76,7 +76,7 @@ module Jekyll
# Returns an Array of file paths to the documents in this collection # Returns an Array of file paths to the documents in this collection
# relative to the collection's directory # relative to the collection's directory
def entries def entries
return Array.new unless exists? return [] unless exists?
@entries ||= @entries ||=
Utils.safe_glob(collection_dir, ["**", "*.*"]).map do |entry| Utils.safe_glob(collection_dir, ["**", "*.*"]).map do |entry|
entry["#{collection_dir}/"] = ''; entry entry["#{collection_dir}/"] = ''; entry
@ -88,7 +88,7 @@ module Jekyll
# #
# Returns a list of filtered entry paths. # Returns a list of filtered entry paths.
def filtered_entries def filtered_entries
return Array.new unless exists? return [] unless exists?
@filtered_entries ||= @filtered_entries ||=
Dir.chdir(directory) do Dir.chdir(directory) do
entry_filter.filter(entries).reject do |f| entry_filter.filter(entries).reject do |f|
@ -195,7 +195,7 @@ module Jekyll
# Returns the metadata for this collection # Returns the metadata for this collection
def extract_metadata def extract_metadata
if site.config['collections'].is_a?(Hash) if site.config['collections'].is_a?(Hash)
site.config['collections'][label] || Hash.new site.config['collections'][label] || {}
else else
{} {}
end end

View File

@ -105,7 +105,7 @@ module Jekyll
end end
def case_insensitive_urls(things, destination) def case_insensitive_urls(things, destination)
things.inject(Hash.new) do |memo, thing| things.inject({}) do |memo, thing|
dest = thing.destination(destination) dest = thing.destination(destination)
(memo[dest.downcase] ||= []) << dest (memo[dest.downcase] ||= []) << dest
memo memo

View File

@ -52,7 +52,7 @@ module Jekyll
# Returns a Hash containing the data. An empty hash is returned if # Returns a Hash containing the data. An empty hash is returned if
# no data was read. # no data was read.
def data def data
@data ||= Hash.new @data ||= {}
end end
# Merge some data in with this document's data. # Merge some data in with this document's data.

View File

@ -4,7 +4,7 @@ module Jekyll
def initialize(site, dir) def initialize(site, dir)
@site = site @site = site
@dir = dir @dir = dir
@unfiltered_content = Array.new @unfiltered_content = []
end end
# Read all the files in <source>/<dir>/ for Yaml header and create a new Page # Read all the files in <source>/<dir>/ for Yaml header and create a new Page

View File

@ -4,7 +4,7 @@ module Jekyll
def initialize(site, dir) def initialize(site, dir)
@site = site @site = site
@dir = dir @dir = dir
@unfiltered_content = Array.new @unfiltered_content = []
end end
# Read all the files in <source>/<dir>/ for Yaml header and create a new Page # Read all the files in <source>/<dir>/ for Yaml header and create a new Page

View File

@ -1,7 +1,7 @@
module Jekyll module Jekyll
class StaticFile class StaticFile
# The cache of last modification times [path] -> mtime. # The cache of last modification times [path] -> mtime.
@@mtimes = Hash.new @@mtimes = {}
attr_reader :relative_path, :extname attr_reader :relative_path, :extname
@ -90,7 +90,7 @@ module Jekyll
# #
# Returns nothing. # Returns nothing.
def self.reset_cache def self.reset_cache
@@mtimes = Hash.new @@mtimes = {}
nil nil
end end