Fix require and include call style

This commit is contained in:
Jean Boussier 2023-12-14 10:47:17 +01:00
parent 1bc26d1ada
commit 070151f130
37 changed files with 91 additions and 90 deletions

View File

@ -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|

View File

@ -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.
@ -11,5 +11,5 @@ require("bootsnap")
# require "pry"
# Pry.start
require("irb")
require "irb"
IRB.start(__FILE__)

View File

@ -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"

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require("mkmf")
require "mkmf"
if %w[ruby truffleruby].include?(RUBY_ENGINE)
$CFLAGS << " -O3 "

View File

@ -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)

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Bootsnap
extend(self)
extend self
def bundler?
return false unless defined?(::Bundler)

View File

@ -12,7 +12,7 @@ module Bootsnap
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")
@ -21,7 +21,7 @@ module Bootsnap
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")
@ -30,7 +30,7 @@ module Bootsnap
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")

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
require("bootsnap/bootsnap")
require("zlib")
require "bootsnap/bootsnap"
require "zlib"
module Bootsnap
module CompileCache

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require("bootsnap/bootsnap")
require "bootsnap/bootsnap"
module Bootsnap
module CompileCache
@ -46,8 +46,8 @@ module Bootsnap
end
def init!
require("json")
require("msgpack")
require "json"
require "msgpack"
self.msgpack_factory = MessagePack::Factory.new
self.supported_options = [:symbolize_names]

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require("bootsnap/bootsnap")
require "bootsnap/bootsnap"
module Bootsnap
module CompileCache
@ -55,9 +55,9 @@ module Bootsnap
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)

View File

@ -41,8 +41,8 @@ module Bootsnap
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!
@ -71,10 +71,10 @@ module Bootsnap
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

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require_relative("../explicit_require")
require_relative "../explicit_require"
module Bootsnap
module LoadPathCache

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require_relative("path_scanner")
require_relative "path_scanner"
module Bootsnap
module LoadPathCache

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require_relative("../explicit_require")
require_relative "../explicit_require"
module Bootsnap
module LoadPathCache

View File

@ -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

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
require_relative("../bootsnap")
require_relative "../bootsnap"
Bootsnap.default_setup

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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,

View File

@ -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
@ -21,7 +21,7 @@ class CompileCacheTest < Minitest::Test
def test_coverage_running?
refute(Bootsnap::CompileCache::Native.coverage_running?)
require("coverage")
require "coverage"
begin
Coverage.start
assert(Bootsnap::CompileCache::Native.coverage_running?)

View File

@ -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)

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require("test_helper")
require "test_helper"
module Bootsnap
class KernelTest < Minitest::Test

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require("test_helper")
require "test_helper"
module Bootsnap
module LoadPathCache

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require("test_helper")
require "test_helper"
module Bootsnap
module LoadPathCache

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require("test_helper")
require "test_helper"
module Bootsnap
class KernelRequireTest < Minitest::Test

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require("test_helper")
require "test_helper"
module Bootsnap
module LoadPathCache

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require("test_helper")
require "test_helper"
module Bootsnap
module LoadPathCache

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
require("test_helper")
require("bootsnap/load_path_cache")
require "test_helper"
require "bootsnap/load_path_cache"
module Bootsnap
module LoadPathCache
@ -14,7 +14,8 @@ module Bootsnap
end
def test_stability
require("time")
require "time"
time_file = Time.method(:rfc2822).source_location[0]
volatile = Path.new(__FILE__)
stable = Path.new(time_file)

View File

@ -1,8 +1,8 @@
# frozen_string_literal: true
require("test_helper")
require("tmpdir")
require("fileutils")
require "test_helper"
require "tmpdir"
require "fileutils"
module Bootsnap
module LoadPathCache

View File

@ -1,4 +1,4 @@
# frozen_string_literal: true
require("bundler/setup")
require("bootsnap/setup")
require "bundler/setup"
require "bootsnap/setup"

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require("test_helper")
require "test_helper"
module Bootsnap
class SetupTest < Minitest::Test

View File

@ -6,16 +6,16 @@ if Warning.respond_to?(:[]=)
Warning[:deprecated] = true
end
require("bundler/setup")
require("bootsnap")
require("bootsnap/compile_cache/yaml")
require("bootsnap/compile_cache/json")
require "bundler/setup"
require "bootsnap"
require "bootsnap/compile_cache/yaml"
require "bootsnap/compile_cache/json"
require("tmpdir")
require("fileutils")
require "tmpdir"
require "fileutils"
require("minitest/autorun")
require("mocha/minitest")
require "minitest/autorun"
require "mocha/minitest"
cache_dir = File.expand_path("../tmp/bootsnap/compile-cache", __dir__)
Bootsnap::CompileCache.setup(cache_dir: cache_dir, iseq: true, yaml: false, json: false)

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
require("test_helper")
require("bootsnap/cli")
require "test_helper"
require "bootsnap/cli"
module Bootsnap
class WorkerPoolTestTest < Minitest::Test