From 31dd0ebed5faa79d68307222403de85db9177f16 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sun, 3 Jan 2016 14:39:01 -0800 Subject: [PATCH] Rubocop: Style/EmptyLiteral - Use array literal [] instead of Array.new - Use hash literal {} instead of Hash.new --- lib/jekyll.rb | 2 +- lib/jekyll/collection.rb | 6 +++--- lib/jekyll/commands/doctor.rb | 2 +- lib/jekyll/document.rb | 2 +- lib/jekyll/readers/page_reader.rb | 2 +- lib/jekyll/readers/static_file_reader.rb | 2 +- lib/jekyll/static_file.rb | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 3d33e52c..24448c26 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -95,7 +95,7 @@ module Jekyll # list of option names and their defaults. # # Returns the final configuration Hash. - def configuration(override = Hash.new) + def configuration(override = {}) config = Configuration[Configuration::DEFAULTS] override = Configuration[override].stringify_keys unless override.delete('skip_config_files') diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index f74ccf6f..a68fbfec 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -76,7 +76,7 @@ module Jekyll # Returns an Array of file paths to the documents in this collection # relative to the collection's directory def entries - return Array.new unless exists? + return [] unless exists? @entries ||= Utils.safe_glob(collection_dir, ["**", "*.*"]).map do |entry| entry["#{collection_dir}/"] = ''; entry @@ -88,7 +88,7 @@ module Jekyll # # Returns a list of filtered entry paths. def filtered_entries - return Array.new unless exists? + return [] unless exists? @filtered_entries ||= Dir.chdir(directory) do entry_filter.filter(entries).reject do |f| @@ -195,7 +195,7 @@ module Jekyll # Returns the metadata for this collection def extract_metadata if site.config['collections'].is_a?(Hash) - site.config['collections'][label] || Hash.new + site.config['collections'][label] || {} else {} end diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index 02e1967d..8ce2c473 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -105,7 +105,7 @@ module Jekyll end def case_insensitive_urls(things, destination) - things.inject(Hash.new) do |memo, thing| + things.inject({}) do |memo, thing| dest = thing.destination(destination) (memo[dest.downcase] ||= []) << dest memo diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 14a0a92e..c906e149 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -52,7 +52,7 @@ module Jekyll # Returns a Hash containing the data. An empty hash is returned if # no data was read. def data - @data ||= Hash.new + @data ||= {} end # Merge some data in with this document's data. diff --git a/lib/jekyll/readers/page_reader.rb b/lib/jekyll/readers/page_reader.rb index 099ebf13..12e70748 100644 --- a/lib/jekyll/readers/page_reader.rb +++ b/lib/jekyll/readers/page_reader.rb @@ -4,7 +4,7 @@ module Jekyll def initialize(site, dir) @site = site @dir = dir - @unfiltered_content = Array.new + @unfiltered_content = [] end # Read all the files in // for Yaml header and create a new Page diff --git a/lib/jekyll/readers/static_file_reader.rb b/lib/jekyll/readers/static_file_reader.rb index 279bea46..b95981a8 100644 --- a/lib/jekyll/readers/static_file_reader.rb +++ b/lib/jekyll/readers/static_file_reader.rb @@ -4,7 +4,7 @@ module Jekyll def initialize(site, dir) @site = site @dir = dir - @unfiltered_content = Array.new + @unfiltered_content = [] end # Read all the files in // for Yaml header and create a new Page diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index 48fa34c5..6f24f7d2 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -1,7 +1,7 @@ module Jekyll class StaticFile # The cache of last modification times [path] -> mtime. - @@mtimes = Hash.new + @@mtimes = {} attr_reader :relative_path, :extname @@ -90,7 +90,7 @@ module Jekyll # # Returns nothing. def self.reset_cache - @@mtimes = Hash.new + @@mtimes = {} nil end