Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

Optimize our requires #822

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "bundler/setup"
require "mixlib/shellout"
require "mixlib/shellout" unless defined?(Mixlib::ShellOut)

require "bundler/gem_tasks"

Expand Down
4 changes: 2 additions & 2 deletions chef_dsl_metadata/Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "appraisal"
require "fileutils"
require "ffi_yajl"
require "fileutils" unless defined?(FileUtils)
require "ffi_yajl" unless defined?(FFI_Yajl)

task :generate_chef_metadata do
require_chef
Expand Down
6 changes: 3 additions & 3 deletions lib/foodcritic.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8

require "pathname"
require "pathname" unless defined?(Pathname)
require "treetop"
require "ripper"
require "ffi_yajl"
require "erubis"
require "ffi_yajl" unless defined?(FFI_Yajl)
require "erubis" unless defined?(Erubis)

require_relative "foodcritic/chef"
require_relative "foodcritic/command_line"
Expand Down
2 changes: 1 addition & 1 deletion lib/foodcritic/api.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "nokogiri"
require "nokogiri" unless defined?(Nokogiri)
require "rufus-lru"

module FoodCritic
Expand Down
4 changes: 2 additions & 2 deletions lib/foodcritic/dsl.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "open-uri"
require "pathname"
require "open-uri" unless defined?(OpenURI)
require "pathname" unless defined?(Pathname)

module FoodCritic
# The DSL methods exposed for defining rules. A minimal example rule:
Expand Down
6 changes: 3 additions & 3 deletions lib/foodcritic/linter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "open-uri"
require "optparse"
require "open-uri" unless defined?(OpenURI)
require "optparse" unless defined?(OptionParser)
require "ripper"
require "set"
require "set" unless defined?(Set)

module FoodCritic
# The main entry point for linting your Chef cookbooks.
Expand Down
2 changes: 1 addition & 1 deletion lib/foodcritic/output.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "set"
require "set" unless defined?(Set)

module FoodCritic
class Output
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "shellwords"
require "shellwords" unless defined?(Shellwords)

require "rspec_command"
require "simplecov"
Expand Down