From 971d7c84ef01ab77db73e1350c052f5a0b0dae97 Mon Sep 17 00:00:00 2001 From: Marcel Otto Date: Sun, 28 Jan 2024 10:16:31 +0100 Subject: [PATCH] Fix upstream warnings under Elixir 1.16 (#215) * Fix missing parentheses warnings * Remove double parentheses --- config/config.exs | 2 +- lib/exvcr/adapter/hackney.ex | 2 +- lib/exvcr/checker.ex | 2 +- lib/exvcr/iex.ex | 2 +- lib/exvcr/mock.ex | 12 ++++++------ lib/exvcr/mock_lock.ex | 2 +- lib/exvcr/setting.ex | 2 +- lib/exvcr/util.ex | 2 +- lib/mix/tasks.ex | 4 ++-- test/adapter_hackney_test.exs | 2 +- test/config_loader_test.exs | 4 ++-- test/handler_options_test.exs | 2 +- test/iex_test.exs | 2 +- test/ignore_localhost_test.exs | 2 +- test/ignore_urls_test.exs | 2 +- test/strict_mode_test.exs | 2 +- test/test_helper.exs | 2 +- 17 files changed, 24 insertions(+), 24 deletions(-) diff --git a/config/config.exs b/config/config.exs index dfe0613..7e0b861 100644 --- a/config/config.exs +++ b/config/config.exs @@ -15,4 +15,4 @@ config :exvcr, [ strict_mode: false ] -if Mix.env == :test, do: import_config "test.exs" +if Mix.env() == :test, do: import_config "test.exs" diff --git a/lib/exvcr/adapter/hackney.ex b/lib/exvcr/adapter/hackney.ex index b9f91df..68ea821 100644 --- a/lib/exvcr/adapter/hackney.ex +++ b/lib/exvcr/adapter/hackney.ex @@ -9,7 +9,7 @@ defmodule ExVCR.Adapter.Hackney do defmacro __using__(_opts) do quote do - Store.start + Store.start() end end diff --git a/lib/exvcr/checker.ex b/lib/exvcr/checker.ex index 7cfd521..8539fe0 100644 --- a/lib/exvcr/checker.ex +++ b/lib/exvcr/checker.ex @@ -22,7 +22,7 @@ defmodule ExVCR.Checker do def add_server_count(recorder), do: add_count(recorder, :server) defp add_count(recorder, type) do - if ExVCR.Checker.get != [] do + if ExVCR.Checker.get() != [] do ExVCR.Checker.append({type, ExVCR.Recorder.get_file_path(recorder)}) end end diff --git a/lib/exvcr/iex.ex b/lib/exvcr/iex.ex index 4ca19fe..1425bd5 100644 --- a/lib/exvcr/iex.ex +++ b/lib/exvcr/iex.ex @@ -10,7 +10,7 @@ defmodule ExVCR.IEx do """ defmacro print(options \\ [], test) do adapter = options[:adapter] || ExVCR.Adapter.IBrowse - method_name = :"ExVCR.IEx.Sample#{ExVCR.Util.uniq_id}" + method_name = :"ExVCR.IEx.Sample#{ExVCR.Util.uniq_id()}" quote do defmodule unquote(method_name) do diff --git a/lib/exvcr/mock.ex b/lib/exvcr/mock.ex index c06f43e..1f33e41 100644 --- a/lib/exvcr/mock.ex +++ b/lib/exvcr/mock.ex @@ -11,7 +11,7 @@ defmodule ExVCR.Mock do quote do import ExVCR.Mock - :application.start(unquote(adapter).module_name) + :application.start(unquote(adapter).module_name()) use unquote(adapter) def adapter_method() do @@ -36,7 +36,7 @@ defmodule ExVCR.Mock do """ defmacro use_cassette(:stub, options, test) do quote do - stub_fixture = "stub_fixture_#{ExVCR.Util.uniq_id}" + stub_fixture = "stub_fixture_#{ExVCR.Util.uniq_id()}" stub = prepare_stub_records(unquote(options), adapter_method()) recorder = Recorder.start([fixture: stub_fixture, stub: stub, adapter: adapter_method()]) @@ -45,7 +45,7 @@ defmodule ExVCR.Mock do [do: return_value] = unquote(test) return_value after - module_name = adapter_method().module_name + module_name = adapter_method().module_name() unload(module_name) ExVCR.MockLock.release_lock() end @@ -88,7 +88,7 @@ defmodule ExVCR.Mock do quote do recorder_result = Recorder.save(unquote(recorder)) - module_name = adapter_method().module_name + module_name = adapter_method().module_name() unload(module_name) ExVCR.MockLock.release_lock() @@ -101,7 +101,7 @@ defmodule ExVCR.Mock do if ExVCR.Application.global_mock_enabled?() do ExVCR.Actor.CurrentRecorder.set(recorder) else - module_name = adapter.module_name + module_name = adapter.module_name() target_methods = adapter.target_methods(recorder) Enum.each(target_methods, fn({function, callback}) -> :meck.expect(module_name, function, callback) @@ -125,7 +125,7 @@ defmodule ExVCR.Mock do def mock_methods(recorder, adapter) do parent_pid = self() Task.async(fn -> - ExVCR.MockLock.ensure_started + ExVCR.MockLock.ensure_started() ExVCR.MockLock.request_lock(self(), parent_pid) receive do :lock_granted -> diff --git a/lib/exvcr/mock_lock.ex b/lib/exvcr/mock_lock.ex index eb76fc1..ce9e67f 100644 --- a/lib/exvcr/mock_lock.ex +++ b/lib/exvcr/mock_lock.ex @@ -8,7 +8,7 @@ defmodule ExVCR.MockLock do def ensure_started do unless Process.whereis(:mock_lock) do - __MODULE__.start + __MODULE__.start() end end diff --git a/lib/exvcr/setting.ex b/lib/exvcr/setting.ex index fb3970b..d8da328 100644 --- a/lib/exvcr/setting.ex +++ b/lib/exvcr/setting.ex @@ -23,7 +23,7 @@ defmodule ExVCR.Setting do defp setup do if :ets.info(table()) == :undefined do :ets.new(table(), [:set, :public, :named_table]) - ExVCR.ConfigLoader.load_defaults + ExVCR.ConfigLoader.load_defaults() end end diff --git a/lib/exvcr/util.ex b/lib/exvcr/util.ex index 1542904..830ca48 100644 --- a/lib/exvcr/util.ex +++ b/lib/exvcr/util.ex @@ -7,7 +7,7 @@ defmodule ExVCR.Util do Returns uniq_id string based on current timestamp (ex. 1407237617115869) """ def uniq_id do - :os.timestamp |> Tuple.to_list |> Enum.join("") + :os.timestamp() |> Tuple.to_list |> Enum.join("") end @doc """ diff --git a/lib/mix/tasks.ex b/lib/mix/tasks.ex index 68a152f..c90e028 100644 --- a/lib/mix/tasks.ex +++ b/lib/mix/tasks.ex @@ -16,7 +16,7 @@ defmodule Mix.Tasks.Vcr do def run(args) do {options, _, _} = OptionParser.parse(args, aliases: [d: :dir, c: :custom, h: :help], switches: [dir: :string, custom: :string, help: :boolean]) if options[:help] do - ExVCR.Task.Util.print_help_message + ExVCR.Task.Util.print_help_message() else ExVCR.Task.Util.parse_basic_options(options) |> ExVCR.Task.Runner.show_vcr_cassettes end @@ -63,7 +63,7 @@ defmodule Mix.Tasks.Vcr do Mix.env(:test) Mix.Task.run("test") System.at_exit(fn(_) -> - ExVCR.Task.Runner.check_cassettes(ExVCR.Checker.get) + ExVCR.Task.Runner.check_cassettes(ExVCR.Checker.get()) end) end end diff --git a/test/adapter_hackney_test.exs b/test/adapter_hackney_test.exs index 335e1e8..ff53e2a 100644 --- a/test/adapter_hackney_test.exs +++ b/test/adapter_hackney_test.exs @@ -6,7 +6,7 @@ defmodule ExVCR.Adapter.HackneyTest do setup_all do HttpServer.start(path: "/server", port: @port, response: "test_response") - {:ok, _} = HTTPoison.start + {:ok, _} = HTTPoison.start() on_exit fn -> HttpServer.stop(@port) end diff --git a/test/config_loader_test.exs b/test/config_loader_test.exs index b23f076..d8435b6 100644 --- a/test/config_loader_test.exs +++ b/test/config_loader_test.exs @@ -25,7 +25,7 @@ defmodule ExVCR.ConfigLoaderTest do ExVCR.Config.response_headers_blacklist(["Content-Type", "Accept"]) # Load default values (defined in config/config.exs) - ExVCR.ConfigLoader.load_defaults + ExVCR.ConfigLoader.load_defaults() # Verify against default values assert ExVCR.Setting.get(:cassette_library_dir) == "fixture/vcr_cassettes" @@ -48,7 +48,7 @@ defmodule ExVCR.ConfigLoaderTest do Application.delete_env(:exvcr, :response_headers_blacklist) # Load default values - ExVCR.ConfigLoader.load_defaults + ExVCR.ConfigLoader.load_defaults() # Verify against default values assert ExVCR.Setting.get(:cassette_library_dir) == "fixture/vcr_cassettes" diff --git a/test/handler_options_test.exs b/test/handler_options_test.exs index c926c6d..b13fc0b 100644 --- a/test/handler_options_test.exs +++ b/test/handler_options_test.exs @@ -7,7 +7,7 @@ defmodule ExVCR.Adapter.HandlerOptionsTest do @url "http://localhost:#{@port}/server" setup_all do - HTTPotion.start + HTTPotion.start() on_exit fn -> HttpServer.stop(@port) end diff --git a/test/iex_test.exs b/test/iex_test.exs index 86b8134..a9b7a40 100644 --- a/test/iex_test.exs +++ b/test/iex_test.exs @@ -6,7 +6,7 @@ defmodule ExVCR.IExTest do @port 34005 setup_all do - :ibrowse.start + :ibrowse.start() HttpServer.start(path: "/server", port: @port, response: "test_response") on_exit fn -> HttpServer.stop(@port) diff --git a/test/ignore_localhost_test.exs b/test/ignore_localhost_test.exs index 15a22de..6322d67 100644 --- a/test/ignore_localhost_test.exs +++ b/test/ignore_localhost_test.exs @@ -6,7 +6,7 @@ defmodule ExVCR.IgnoreLocalhostTest do @url "http://localhost:#{@port}/server" setup_all do - HTTPotion.start + HTTPotion.start() on_exit fn -> HttpServer.stop(@port) end diff --git a/test/ignore_urls_test.exs b/test/ignore_urls_test.exs index 8bbb87b..2a82c6e 100644 --- a/test/ignore_urls_test.exs +++ b/test/ignore_urls_test.exs @@ -10,7 +10,7 @@ defmodule ExVCR.IgnoreUrlsTest do ] setup_all do - HTTPotion.start + HTTPotion.start() on_exit fn -> HttpServer.stop(@port) end diff --git a/test/strict_mode_test.exs b/test/strict_mode_test.exs index 8062832..a93a657 100644 --- a/test/strict_mode_test.exs +++ b/test/strict_mode_test.exs @@ -16,7 +16,7 @@ defmodule ExVCR.StrictModeTest do :ok end - HTTPotion.start + HTTPotion.start() HttpServer.start(@http_server_opts) :ok end diff --git a/test/test_helper.exs b/test/test_helper.exs index 3fc58de..e29f8c6 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,4 +1,4 @@ -ExUnit.start +ExUnit.start() Application.ensure_all_started(:http_server) Application.ensure_all_started(:telemetry) Finch.start_link(name: ExVCRFinch)