Skip to content

Commit

Permalink
Fix require and include call style
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Dec 14, 2023
1 parent 1bc26d1 commit 070151f
Show file tree
Hide file tree
Showing 37 changed files with 91 additions and 90 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require("rake/extensiontask")
require("bundler/gem_tasks")
require "rake/extensiontask"
require "bundler/gem_tasks"

gemspec = Gem::Specification.load("bootsnap.gemspec")
Rake::ExtensionTask.new do |ext|
Expand Down
6 changes: 3 additions & 3 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require("bundler/setup")
require("bootsnap")
require "bundler/setup"
require "bootsnap"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand All @@ -11,5 +11,5 @@ require("bootsnap")
# require "pry"
# Pry.start

require("irb")
require "irb"
IRB.start(__FILE__)
2 changes: 1 addition & 1 deletion bootsnap.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require("bootsnap/version")
require "bootsnap/version"

Gem::Specification.new do |spec|
spec.name = "bootsnap"
Expand Down
2 changes: 1 addition & 1 deletion ext/bootsnap/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require("mkmf")
require "mkmf"

if %w[ruby truffleruby].include?(RUBY_ENGINE)
$CFLAGS << " -O3 "
Expand Down
8 changes: 4 additions & 4 deletions lib/bootsnap.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

require_relative("bootsnap/version")
require_relative("bootsnap/bundler")
require_relative("bootsnap/load_path_cache")
require_relative("bootsnap/compile_cache")
require_relative "bootsnap/version"
require_relative "bootsnap/bundler"
require_relative "bootsnap/load_path_cache"
require_relative "bootsnap/compile_cache"

module Bootsnap
InvalidConfiguration = Class.new(StandardError)
Expand Down
2 changes: 1 addition & 1 deletion lib/bootsnap/bundler.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Bootsnap
extend(self)
extend self

def bundler?
return false unless defined?(::Bundler)
Expand Down
6 changes: 3 additions & 3 deletions lib/bootsnap/compile_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def UNCOMPILABLE.inspect
def self.setup(cache_dir:, iseq:, yaml:, json:, readonly: false)
if iseq
if supported?
require_relative("compile_cache/iseq")
require_relative "compile_cache/iseq"
Bootsnap::CompileCache::ISeq.install!(cache_dir)
elsif $VERBOSE
warn("[bootsnap/setup] bytecode caching is not supported on this implementation of Ruby")
Expand All @@ -21,7 +21,7 @@ def self.setup(cache_dir:, iseq:, yaml:, json:, readonly: false)

if yaml
if supported?
require_relative("compile_cache/yaml")
require_relative "compile_cache/yaml"
Bootsnap::CompileCache::YAML.install!(cache_dir)
elsif $VERBOSE
warn("[bootsnap/setup] YAML parsing caching is not supported on this implementation of Ruby")
Expand All @@ -30,7 +30,7 @@ def self.setup(cache_dir:, iseq:, yaml:, json:, readonly: false)

if json
if supported?
require_relative("compile_cache/json")
require_relative "compile_cache/json"
Bootsnap::CompileCache::JSON.install!(cache_dir)
elsif $VERBOSE
warn("[bootsnap/setup] JSON parsing caching is not supported on this implementation of Ruby")
Expand Down
4 changes: 2 additions & 2 deletions lib/bootsnap/compile_cache/iseq.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require("bootsnap/bootsnap")
require("zlib")
require "bootsnap/bootsnap"
require "zlib"

module Bootsnap
module CompileCache
Expand Down
6 changes: 3 additions & 3 deletions lib/bootsnap/compile_cache/json.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require("bootsnap/bootsnap")
require "bootsnap/bootsnap"

module Bootsnap
module CompileCache
Expand Down Expand Up @@ -46,8 +46,8 @@ def install!(cache_dir)
end

def init!
require("json")
require("msgpack")
require "json"
require "msgpack"

self.msgpack_factory = MessagePack::Factory.new
self.supported_options = [:symbolize_names]
Expand Down
8 changes: 4 additions & 4 deletions lib/bootsnap/compile_cache/yaml.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require("bootsnap/bootsnap")
require "bootsnap/bootsnap"

module Bootsnap
module CompileCache
Expand Down Expand Up @@ -55,9 +55,9 @@ def unpack(payload)
end

def init!
require("yaml")
require("msgpack")
require("date")
require "yaml"
require "msgpack"
require "date"

@implementation = ::YAML::VERSION >= "4" ? Psych4 : Psych3
if @implementation::Patch.method_defined?(:unsafe_load_file) && !::YAML.respond_to?(:unsafe_load_file)
Expand Down
16 changes: 8 additions & 8 deletions lib/bootsnap/load_path_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def setup(cache_path:, development_mode:, ignore_directories:, readonly: false)
PathScanner.ignored_directories = ignore_directories if ignore_directories
@load_path_cache = Cache.new(store, $LOAD_PATH, development_mode: development_mode)
@enabled = true
require_relative("load_path_cache/core_ext/kernel_require")
require_relative("load_path_cache/core_ext/loaded_features")
require_relative "load_path_cache/core_ext/kernel_require"
require_relative "load_path_cache/core_ext/loaded_features"
end

def unload!
Expand Down Expand Up @@ -71,10 +71,10 @@ def supported?
end

if Bootsnap::LoadPathCache.supported?
require_relative("load_path_cache/path_scanner")
require_relative("load_path_cache/path")
require_relative("load_path_cache/cache")
require_relative("load_path_cache/store")
require_relative("load_path_cache/change_observer")
require_relative("load_path_cache/loaded_features_index")
require_relative "load_path_cache/path_scanner"
require_relative "load_path_cache/path"
require_relative "load_path_cache/cache"
require_relative "load_path_cache/store"
require_relative "load_path_cache/change_observer"
require_relative "load_path_cache/loaded_features_index"
end
2 changes: 1 addition & 1 deletion lib/bootsnap/load_path_cache/cache.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require_relative("../explicit_require")
require_relative "../explicit_require"

module Bootsnap
module LoadPathCache
Expand Down
2 changes: 1 addition & 1 deletion lib/bootsnap/load_path_cache/path.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require_relative("path_scanner")
require_relative "path_scanner"

module Bootsnap
module LoadPathCache
Expand Down
2 changes: 1 addition & 1 deletion lib/bootsnap/load_path_cache/path_scanner.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require_relative("../explicit_require")
require_relative "../explicit_require"

module Bootsnap
module LoadPathCache
Expand Down
4 changes: 2 additions & 2 deletions lib/bootsnap/load_path_cache/store.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require_relative("../explicit_require")
require_relative "../explicit_require"

Bootsnap::ExplicitRequire.with_gems("msgpack") { require("msgpack") }
Bootsnap::ExplicitRequire.with_gems("msgpack") { require "msgpack" }

module Bootsnap
module LoadPathCache
Expand Down
2 changes: 1 addition & 1 deletion lib/bootsnap/setup.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

require_relative("../bootsnap")
require_relative "../bootsnap"

Bootsnap.default_setup
2 changes: 1 addition & 1 deletion test/bundler_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require("test_helper")
require "test_helper"

class BundlerTest < Minitest::Test
def test_bundler_with_bundle_bin_path_env
Expand Down
6 changes: 3 additions & 3 deletions test/cli_test.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

require("test_helper")
require("bootsnap/cli")
require "test_helper"
require "bootsnap/cli"

module Bootsnap
class CLITest < Minitest::Test
include(TmpdirHelper)
include TmpdirHelper

def setup
super
Expand Down
6 changes: 3 additions & 3 deletions test/compile_cache/iseq_cache_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require("test_helper")
require "test_helper"

class CompileCacheISeqTest < Minitest::Test
include(CompileCacheISeqHelper)
include(TmpdirHelper)
include CompileCacheISeqHelper
include TmpdirHelper

def test_ruby_bug_18250
Help.set_file("a.rb", "def foo(*); ->{ super }; end; def foo(**); ->{ super }; end", 100)
Expand Down
4 changes: 2 additions & 2 deletions test/compile_cache/json_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

require("test_helper")
require "test_helper"

class CompileCacheJSONTest < Minitest::Test
include(TmpdirHelper)
include TmpdirHelper

module FakeJson
Fallback = Class.new(StandardError)
Expand Down
4 changes: 2 additions & 2 deletions test/compile_cache/yaml_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

require("test_helper")
require "test_helper"

class CompileCacheYAMLTest < Minitest::Test
include(TmpdirHelper)
include TmpdirHelper

module FakeYaml
Fallback = Class.new(StandardError)
Expand Down
6 changes: 3 additions & 3 deletions test/compile_cache_handler_errors_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require("test_helper")
require "test_helper"

class CompileCacheHandlerErrorsTest < Minitest::Test
include(CompileCacheISeqHelper)
include(TmpdirHelper)
include CompileCacheISeqHelper
include TmpdirHelper

# now test three failure modes of each handler method:
# 1. unexpected type
Expand Down
12 changes: 6 additions & 6 deletions test/compile_cache_key_format_test.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

require("test_helper")
require("tempfile")
require("tmpdir")
require("fileutils")
require "test_helper"
require "tempfile"
require "tmpdir"
require "fileutils"

class CompileCacheKeyFormatTest < Minitest::Test
FILE = File.expand_path(__FILE__)
include(CompileCacheISeqHelper)
include(TmpdirHelper)
include CompileCacheISeqHelper
include TmpdirHelper

R = {
version: 0...4,
Expand Down
8 changes: 4 additions & 4 deletions test/compile_cache_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require("test_helper")
require "test_helper"

class CompileCacheTest < Minitest::Test
include(CompileCacheISeqHelper)
include(TmpdirHelper)
include CompileCacheISeqHelper
include TmpdirHelper

def teardown
super
Expand All @@ -21,7 +21,7 @@ def test_compile_option_crc32

def test_coverage_running?
refute(Bootsnap::CompileCache::Native.coverage_running?)
require("coverage")
require "coverage"
begin
Coverage.start
assert(Bootsnap::CompileCache::Native.coverage_running?)
Expand Down
6 changes: 3 additions & 3 deletions test/helper_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require("test_helper")
require "test_helper"

class HelperTest < Minitest::Test
include(CompileCacheISeqHelper)
include(TmpdirHelper)
include CompileCacheISeqHelper
include TmpdirHelper

def test_validate_cache_path
path = Help.set_file("a.rb", "a = a = 3", 100)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/kernel_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require("test_helper")
require "test_helper"

module Bootsnap
class KernelTest < Minitest::Test
Expand Down
2 changes: 1 addition & 1 deletion test/load_path_cache/cache_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require("test_helper")
require "test_helper"

module Bootsnap
module LoadPathCache
Expand Down
2 changes: 1 addition & 1 deletion test/load_path_cache/change_observer_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require("test_helper")
require "test_helper"

module Bootsnap
module LoadPathCache
Expand Down
2 changes: 1 addition & 1 deletion test/load_path_cache/core_ext/kernel_require_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require("test_helper")
require "test_helper"

module Bootsnap
class KernelRequireTest < Minitest::Test
Expand Down
2 changes: 1 addition & 1 deletion test/load_path_cache/loaded_features_index_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require("test_helper")
require "test_helper"

module Bootsnap
module LoadPathCache
Expand Down
2 changes: 1 addition & 1 deletion test/load_path_cache/path_scanner_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require("test_helper")
require "test_helper"

module Bootsnap
module LoadPathCache
Expand Down
Loading

0 comments on commit 070151f

Please sign in to comment.