From 070151f1305f23102365d6b4476a91c02dead35a Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 14 Dec 2023 10:47:17 +0100 Subject: [PATCH] Fix require and include call style --- Rakefile | 4 ++-- bin/console | 6 +++--- bootsnap.gemspec | 2 +- ext/bootsnap/extconf.rb | 2 +- lib/bootsnap.rb | 8 ++++---- lib/bootsnap/bundler.rb | 2 +- lib/bootsnap/compile_cache.rb | 6 +++--- lib/bootsnap/compile_cache/iseq.rb | 4 ++-- lib/bootsnap/compile_cache/json.rb | 6 +++--- lib/bootsnap/compile_cache/yaml.rb | 8 ++++---- lib/bootsnap/load_path_cache.rb | 16 ++++++++-------- lib/bootsnap/load_path_cache/cache.rb | 2 +- lib/bootsnap/load_path_cache/path.rb | 2 +- lib/bootsnap/load_path_cache/path_scanner.rb | 2 +- lib/bootsnap/load_path_cache/store.rb | 4 ++-- lib/bootsnap/setup.rb | 2 +- test/bundler_test.rb | 2 +- test/cli_test.rb | 6 +++--- test/compile_cache/iseq_cache_test.rb | 6 +++--- test/compile_cache/json_test.rb | 4 ++-- test/compile_cache/yaml_test.rb | 4 ++-- test/compile_cache_handler_errors_test.rb | 6 +++--- test/compile_cache_key_format_test.rb | 12 ++++++------ test/compile_cache_test.rb | 8 ++++---- test/helper_test.rb | 6 +++--- test/integration/kernel_test.rb | 2 +- test/load_path_cache/cache_test.rb | 2 +- test/load_path_cache/change_observer_test.rb | 2 +- .../core_ext/kernel_require_test.rb | 2 +- .../loaded_features_index_test.rb | 2 +- test/load_path_cache/path_scanner_test.rb | 2 +- test/load_path_cache/path_test.rb | 7 ++++--- test/load_path_cache/store_test.rb | 6 +++--- test/minimal_support/bootsnap_setup.rb | 4 ++-- test/setup_test.rb | 2 +- test/test_helper.rb | 16 ++++++++-------- test/worker_pool_test.rb | 4 ++-- 37 files changed, 91 insertions(+), 90 deletions(-) diff --git a/Rakefile b/Rakefile index 8b782644..a725b3dd 100644 --- a/Rakefile +++ b/Rakefile @@ -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| diff --git a/bin/console b/bin/console index d8e645e2..09171bf7 100755 --- a/bin/console +++ b/bin/console @@ -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__) diff --git a/bootsnap.gemspec b/bootsnap.gemspec index 4275b10b..c365e9a2 100644 --- a/bootsnap.gemspec +++ b/bootsnap.gemspec @@ -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" diff --git a/ext/bootsnap/extconf.rb b/ext/bootsnap/extconf.rb index d6d48c04..abb5644b 100644 --- a/ext/bootsnap/extconf.rb +++ b/ext/bootsnap/extconf.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require("mkmf") +require "mkmf" if %w[ruby truffleruby].include?(RUBY_ENGINE) $CFLAGS << " -O3 " diff --git a/lib/bootsnap.rb b/lib/bootsnap.rb index 03efc0d3..12939df0 100644 --- a/lib/bootsnap.rb +++ b/lib/bootsnap.rb @@ -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) diff --git a/lib/bootsnap/bundler.rb b/lib/bootsnap/bundler.rb index 0165e569..5e4b7350 100644 --- a/lib/bootsnap/bundler.rb +++ b/lib/bootsnap/bundler.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Bootsnap - extend(self) + extend self def bundler? return false unless defined?(::Bundler) diff --git a/lib/bootsnap/compile_cache.rb b/lib/bootsnap/compile_cache.rb index da917be5..06f22455 100644 --- a/lib/bootsnap/compile_cache.rb +++ b/lib/bootsnap/compile_cache.rb @@ -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") @@ -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") @@ -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") diff --git a/lib/bootsnap/compile_cache/iseq.rb b/lib/bootsnap/compile_cache/iseq.rb index 1b7607a9..39c5e97c 100644 --- a/lib/bootsnap/compile_cache/iseq.rb +++ b/lib/bootsnap/compile_cache/iseq.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require("bootsnap/bootsnap") -require("zlib") +require "bootsnap/bootsnap" +require "zlib" module Bootsnap module CompileCache diff --git a/lib/bootsnap/compile_cache/json.rb b/lib/bootsnap/compile_cache/json.rb index 531d44b4..a040a095 100644 --- a/lib/bootsnap/compile_cache/json.rb +++ b/lib/bootsnap/compile_cache/json.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require("bootsnap/bootsnap") +require "bootsnap/bootsnap" module Bootsnap module CompileCache @@ -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] diff --git a/lib/bootsnap/compile_cache/yaml.rb b/lib/bootsnap/compile_cache/yaml.rb index 1acfcd70..a61676b8 100644 --- a/lib/bootsnap/compile_cache/yaml.rb +++ b/lib/bootsnap/compile_cache/yaml.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require("bootsnap/bootsnap") +require "bootsnap/bootsnap" module Bootsnap module CompileCache @@ -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) diff --git a/lib/bootsnap/load_path_cache.rb b/lib/bootsnap/load_path_cache.rb index e735fa5f..332cd8d9 100644 --- a/lib/bootsnap/load_path_cache.rb +++ b/lib/bootsnap/load_path_cache.rb @@ -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! @@ -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 diff --git a/lib/bootsnap/load_path_cache/cache.rb b/lib/bootsnap/load_path_cache/cache.rb index 4d30c9e0..9f75eb83 100644 --- a/lib/bootsnap/load_path_cache/cache.rb +++ b/lib/bootsnap/load_path_cache/cache.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative("../explicit_require") +require_relative "../explicit_require" module Bootsnap module LoadPathCache diff --git a/lib/bootsnap/load_path_cache/path.rb b/lib/bootsnap/load_path_cache/path.rb index e000c600..56fff8c0 100644 --- a/lib/bootsnap/load_path_cache/path.rb +++ b/lib/bootsnap/load_path_cache/path.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative("path_scanner") +require_relative "path_scanner" module Bootsnap module LoadPathCache diff --git a/lib/bootsnap/load_path_cache/path_scanner.rb b/lib/bootsnap/load_path_cache/path_scanner.rb index 3b21ab8a..1dcd082a 100644 --- a/lib/bootsnap/load_path_cache/path_scanner.rb +++ b/lib/bootsnap/load_path_cache/path_scanner.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative("../explicit_require") +require_relative "../explicit_require" module Bootsnap module LoadPathCache diff --git a/lib/bootsnap/load_path_cache/store.rb b/lib/bootsnap/load_path_cache/store.rb index 6ca696dd..52460b87 100644 --- a/lib/bootsnap/load_path_cache/store.rb +++ b/lib/bootsnap/load_path_cache/store.rb @@ -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 diff --git a/lib/bootsnap/setup.rb b/lib/bootsnap/setup.rb index 232980f1..eeeed662 100644 --- a/lib/bootsnap/setup.rb +++ b/lib/bootsnap/setup.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative("../bootsnap") +require_relative "../bootsnap" Bootsnap.default_setup diff --git a/test/bundler_test.rb b/test/bundler_test.rb index 1b1bc0a0..59719b61 100644 --- a/test/bundler_test.rb +++ b/test/bundler_test.rb @@ -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 diff --git a/test/cli_test.rb b/test/cli_test.rb index a958789f..0e78f8ae 100644 --- a/test/cli_test.rb +++ b/test/cli_test.rb @@ -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 diff --git a/test/compile_cache/iseq_cache_test.rb b/test/compile_cache/iseq_cache_test.rb index 954ac0f1..99e481b7 100644 --- a/test/compile_cache/iseq_cache_test.rb +++ b/test/compile_cache/iseq_cache_test.rb @@ -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) diff --git a/test/compile_cache/json_test.rb b/test/compile_cache/json_test.rb index 49a27b17..c0664fe9 100644 --- a/test/compile_cache/json_test.rb +++ b/test/compile_cache/json_test.rb @@ -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) diff --git a/test/compile_cache/yaml_test.rb b/test/compile_cache/yaml_test.rb index cdbd9ef5..4de86d4d 100644 --- a/test/compile_cache/yaml_test.rb +++ b/test/compile_cache/yaml_test.rb @@ -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) diff --git a/test/compile_cache_handler_errors_test.rb b/test/compile_cache_handler_errors_test.rb index dec55065..f17b7f80 100644 --- a/test/compile_cache_handler_errors_test.rb +++ b/test/compile_cache_handler_errors_test.rb @@ -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 diff --git a/test/compile_cache_key_format_test.rb b/test/compile_cache_key_format_test.rb index 3eda7527..e1a8a3fd 100644 --- a/test/compile_cache_key_format_test.rb +++ b/test/compile_cache_key_format_test.rb @@ -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, diff --git a/test/compile_cache_test.rb b/test/compile_cache_test.rb index 74148bc1..d17452f9 100644 --- a/test/compile_cache_test.rb +++ b/test/compile_cache_test.rb @@ -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 @@ 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?) diff --git a/test/helper_test.rb b/test/helper_test.rb index 322a83c2..68c3624f 100644 --- a/test/helper_test.rb +++ b/test/helper_test.rb @@ -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) diff --git a/test/integration/kernel_test.rb b/test/integration/kernel_test.rb index 2a173263..308b241c 100644 --- a/test/integration/kernel_test.rb +++ b/test/integration/kernel_test.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require("test_helper") +require "test_helper" module Bootsnap class KernelTest < Minitest::Test diff --git a/test/load_path_cache/cache_test.rb b/test/load_path_cache/cache_test.rb index bd839074..eee2d0e7 100644 --- a/test/load_path_cache/cache_test.rb +++ b/test/load_path_cache/cache_test.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require("test_helper") +require "test_helper" module Bootsnap module LoadPathCache diff --git a/test/load_path_cache/change_observer_test.rb b/test/load_path_cache/change_observer_test.rb index 19ff35ce..e2bb40f6 100644 --- a/test/load_path_cache/change_observer_test.rb +++ b/test/load_path_cache/change_observer_test.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require("test_helper") +require "test_helper" module Bootsnap module LoadPathCache diff --git a/test/load_path_cache/core_ext/kernel_require_test.rb b/test/load_path_cache/core_ext/kernel_require_test.rb index 8b212d64..b1a7a937 100644 --- a/test/load_path_cache/core_ext/kernel_require_test.rb +++ b/test/load_path_cache/core_ext/kernel_require_test.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require("test_helper") +require "test_helper" module Bootsnap class KernelRequireTest < Minitest::Test diff --git a/test/load_path_cache/loaded_features_index_test.rb b/test/load_path_cache/loaded_features_index_test.rb index 47fbb5a9..9088dbcd 100644 --- a/test/load_path_cache/loaded_features_index_test.rb +++ b/test/load_path_cache/loaded_features_index_test.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require("test_helper") +require "test_helper" module Bootsnap module LoadPathCache diff --git a/test/load_path_cache/path_scanner_test.rb b/test/load_path_cache/path_scanner_test.rb index 1bd79359..0ae272a1 100644 --- a/test/load_path_cache/path_scanner_test.rb +++ b/test/load_path_cache/path_scanner_test.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require("test_helper") +require "test_helper" module Bootsnap module LoadPathCache diff --git a/test/load_path_cache/path_test.rb b/test/load_path_cache/path_test.rb index 270eddc8..fc8c06ee 100644 --- a/test/load_path_cache/path_test.rb +++ b/test/load_path_cache/path_test.rb @@ -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 @@ def setup 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) diff --git a/test/load_path_cache/store_test.rb b/test/load_path_cache/store_test.rb index 250208f2..21b5a055 100644 --- a/test/load_path_cache/store_test.rb +++ b/test/load_path_cache/store_test.rb @@ -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 diff --git a/test/minimal_support/bootsnap_setup.rb b/test/minimal_support/bootsnap_setup.rb index 80586e00..1813154a 100644 --- a/test/minimal_support/bootsnap_setup.rb +++ b/test/minimal_support/bootsnap_setup.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -require("bundler/setup") -require("bootsnap/setup") +require "bundler/setup" +require "bootsnap/setup" diff --git a/test/setup_test.rb b/test/setup_test.rb index 97026bbe..3cfebfa5 100644 --- a/test/setup_test.rb +++ b/test/setup_test.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require("test_helper") +require "test_helper" module Bootsnap class SetupTest < Minitest::Test diff --git a/test/test_helper.rb b/test/test_helper.rb index 051bc459..33b3f585 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -6,16 +6,16 @@ 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) diff --git a/test/worker_pool_test.rb b/test/worker_pool_test.rb index f7af20a0..3b5fc9a1 100644 --- a/test/worker_pool_test.rb +++ b/test/worker_pool_test.rb @@ -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