From e776b2cb7d191a29498fccd94f413938bca90b4c Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Thu, 8 Aug 2024 00:16:58 -0400 Subject: [PATCH] chore: address warnings --- lib/igniter.ex | 6 +++--- lib/igniter/code/module.ex | 2 +- lib/igniter/project/application.ex | 2 +- lib/igniter/project/config.ex | 12 +++++------ lib/igniter/project/deps.ex | 2 +- lib/igniter/project/formatter.ex | 4 ++-- test/igniter/code/module_test.exs | 10 +++++----- test/igniter/project/config_test.exs | 30 ++++++++++++++-------------- test/igniter/project/test_test.exs | 4 ++-- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/lib/igniter.ex b/lib/igniter.ex index 20826a0..90cc2ec 100644 --- a/lib/igniter.ex +++ b/lib/igniter.ex @@ -796,12 +796,12 @@ defmodule Igniter do "**/.formatter.exs" |> Path.wildcard() |> Enum.reduce(igniter, fn path, igniter -> - Igniter.include_existing_elixir_file(igniter, path) + Igniter.include_existing_file(igniter, path) end) igniter = if File.exists?(".formatter.exs") do - Igniter.include_existing_elixir_file(igniter, ".formatter.exs") + Igniter.include_existing_file(igniter, ".formatter.exs") else igniter end @@ -1038,7 +1038,7 @@ defmodule Igniter do read_source!(path, Rewrite.Source.Ex) end - defp read_source!(path, source_handler \\ Rewrite.Source) do + defp read_source!(path, source_handler) do source = source_handler.read!(path) content = diff --git a/lib/igniter/code/module.ex b/lib/igniter/code/module.ex index daa04ae..77ea041 100644 --- a/lib/igniter/code/module.ex +++ b/lib/igniter/code/module.ex @@ -65,7 +65,7 @@ defmodule Igniter.Code.Module do path end - Igniter.create_new_elixir_file(igniter, location, contents) + Igniter.create_new_file(igniter, location, contents) end @doc "Checks if a module is defined somewhere in the project. The returned igniter should not be discarded." diff --git a/lib/igniter/project/application.ex b/lib/igniter/project/application.ex index 58c0e02..9725462 100644 --- a/lib/igniter/project/application.ex +++ b/lib/igniter/project/application.ex @@ -114,7 +114,7 @@ defmodule Igniter.Project.Application do end """ - Igniter.create_new_elixir_file(igniter, path, contents) + Igniter.create_new_file(igniter, path, contents) end defp point_to_application_in_mix_exs(igniter, application) do diff --git a/lib/igniter/project/config.ex b/lib/igniter/project/config.ex index 14ea387..154bf9d 100644 --- a/lib/igniter/project/config.ex +++ b/lib/igniter/project/config.ex @@ -57,7 +57,7 @@ defmodule Igniter.Project.Config do igniter |> ensure_default_configs_exist(file_path) - |> Igniter.include_or_create_elixir_file(file_path, file_contents) + |> Igniter.include_or_create_file(file_path, file_contents) |> Igniter.update_elixir_file(file_path, fn zipper -> case Zipper.find(zipper, fn {:import, _, [Config]} -> @@ -81,17 +81,17 @@ defmodule Igniter.Project.Config do defp ensure_default_configs_exist(igniter, file) when file in ["config/dev.exs", "config/test.exs", "config/prod.exs"] do igniter - |> Igniter.include_or_create_elixir_file("config/config.exs", """ + |> Igniter.include_or_create_file("config/config.exs", """ import Config """) |> ensure_config_evaluates_env() - |> Igniter.include_or_create_elixir_file("config/dev.exs", """ + |> Igniter.include_or_create_file("config/dev.exs", """ import Config """) - |> Igniter.include_or_create_elixir_file("config/test.exs", """ + |> Igniter.include_or_create_file("config/test.exs", """ import Config """) - |> Igniter.include_or_create_elixir_file("config/prod.exs", """ + |> Igniter.include_or_create_file("config/prod.exs", """ import Config """) end @@ -378,7 +378,7 @@ defmodule Igniter.Project.Config do config_file_path = Path.join("config", config_file_name) igniter = - Igniter.include_existing_elixir_file(igniter, config_file_path, required?: false) + Igniter.include_existing_file(igniter, config_file_path, required?: false) case Rewrite.source(igniter.rewrite, config_file_path) do {:ok, source} -> diff --git a/lib/igniter/project/deps.ex b/lib/igniter/project/deps.ex index e8c0782..5110007 100644 --- a/lib/igniter/project/deps.ex +++ b/lib/igniter/project/deps.ex @@ -69,7 +69,7 @@ defmodule Igniter.Project.Deps do def get_dependency_declaration(igniter, name) do zipper = igniter - |> Igniter.include_existing_elixir_file("mix.exs") + |> Igniter.include_existing_file("mix.exs") |> Map.get(:rewrite) |> Rewrite.source!("mix.exs") |> Rewrite.Source.get(:quoted) diff --git a/lib/igniter/project/formatter.ex b/lib/igniter/project/formatter.ex index 3f5ad41..91b2f89 100644 --- a/lib/igniter/project/formatter.ex +++ b/lib/igniter/project/formatter.ex @@ -16,7 +16,7 @@ defmodule Igniter.Project.Formatter do @spec import_dep(Igniter.t(), dep :: atom) :: Igniter.t() def import_dep(igniter, dep) do igniter - |> Igniter.include_or_create_elixir_file(".formatter.exs", @default_formatter) + |> Igniter.include_or_create_file(".formatter.exs", @default_formatter) |> Igniter.update_elixir_file(".formatter.exs", fn zipper -> zipper |> Zipper.down() @@ -62,7 +62,7 @@ defmodule Igniter.Project.Formatter do @spec add_formatter_plugin(Igniter.t(), plugin :: module()) :: Igniter.t() def add_formatter_plugin(igniter, plugin) do igniter - |> Igniter.include_or_create_elixir_file(".formatter.exs", @default_formatter) + |> Igniter.include_or_create_file(".formatter.exs", @default_formatter) |> Igniter.update_elixir_file(".formatter.exs", fn zipper -> zipper |> Zipper.down() diff --git a/test/igniter/code/module_test.exs b/test/igniter/code/module_test.exs index ade30ea..2bd3de7 100644 --- a/test/igniter/code/module_test.exs +++ b/test/igniter/code/module_test.exs @@ -9,8 +9,8 @@ defmodule Igniter.Code.ModuleTest do |> Igniter.assign(:igniter_exs, module_location: :inside_matching_folder ) - |> Igniter.include_or_create_elixir_file("lib/foo/bar.ex", "defmodule Foo.Bar do\nend") - |> Igniter.include_or_create_elixir_file( + |> Igniter.include_or_create_file("lib/foo/bar.ex", "defmodule Foo.Bar do\nend") + |> Igniter.include_or_create_file( "lib/foo/bar/baz.ex", "defmodule Foo.Bar.Baz do\nend" ) @@ -25,7 +25,7 @@ defmodule Igniter.Code.ModuleTest do test "modules can be found anywhere across the project" do %{rewrite: rewrite} = Igniter.new() - |> Igniter.create_new_elixir_file("lib/foo/bar.ex", """ + |> Igniter.create_new_file("lib/foo/bar.ex", """ defmodule Foo.Bar do defmodule Baz do 10 @@ -59,7 +59,7 @@ defmodule Igniter.Code.ModuleTest do test "modules will be created if they do not exist, in the conventional place" do %{rewrite: rewrite} = Igniter.new() - |> Igniter.create_new_elixir_file("lib/foo/bar.ex", """ + |> Igniter.create_new_file("lib/foo/bar.ex", """ defmodule Foo.Bar do end """) @@ -91,7 +91,7 @@ defmodule Igniter.Code.ModuleTest do |> Igniter.assign(:igniter_exs, module_location: :inside_matching_folder ) - |> Igniter.create_new_elixir_file("lib/foo/bar/something.ex", """ + |> Igniter.create_new_file("lib/foo/bar/something.ex", """ defmodule Foo.Bar.Something do end """) diff --git a/test/igniter/project/config_test.exs b/test/igniter/project/config_test.exs index d342b2a..de7d571 100644 --- a/test/igniter/project/config_test.exs +++ b/test/igniter/project/config_test.exs @@ -21,7 +21,7 @@ defmodule Igniter.Project.ConfigTest do test "it merges with 2 arg version of existing config" do %{rewrite: rewrite} = Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ import Config config :fake, buz: [:blat] @@ -67,7 +67,7 @@ defmodule Igniter.Project.ConfigTest do test "it merges with 2 arg version of existing config with a single path item" do %{rewrite: rewrite} = Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ import Config config :fake, buz: [:blat] @@ -86,7 +86,7 @@ defmodule Igniter.Project.ConfigTest do test "it chooses the 3 arg version when first item in path is not pretty" do %{rewrite: rewrite} = Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ import Config """) |> Igniter.Project.Config.configure("fake.exs", :fake, [Foo.Bar, :bar], "baz") @@ -102,7 +102,7 @@ defmodule Igniter.Project.ConfigTest do test "it chooses the 3 arg version when first item in path is not pretty, and merges that way" do %{rewrite: rewrite} = Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ import Config """) |> Igniter.Project.Config.configure("fake.exs", :fake, [Foo.Bar, :bar], "baz") @@ -119,7 +119,7 @@ defmodule Igniter.Project.ConfigTest do test "it merges with 3 arg version of existing config" do %{rewrite: rewrite} = Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ import Config config :fake, :buz, [:blat] @@ -140,7 +140,7 @@ defmodule Igniter.Project.ConfigTest do test "it merges with 3 arg version of existing config with the config set to []" do %{rewrite: rewrite} = Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ import Config config :foo, SomeModule, [] @@ -165,7 +165,7 @@ defmodule Igniter.Project.ConfigTest do test "it merges with 3 arg version of existing config with the config set to [] and the path is one level deeper than existing" do %{rewrite: rewrite} = Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ import Config config :foo, SomeModule, [level1: []] @@ -189,7 +189,7 @@ defmodule Igniter.Project.ConfigTest do test "it merges with 3 arg version of existing config with a single path item" do %{rewrite: rewrite} = Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ import Config config :fake, :buz, [:blat] @@ -209,7 +209,7 @@ defmodule Igniter.Project.ConfigTest do test "present values can be updated" do %{rewrite: rewrite} = Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ import Config config :fake, :buz, [:blat] @@ -232,7 +232,7 @@ defmodule Igniter.Project.ConfigTest do test "we merge configs even in large config files" do %{rewrite: rewrite} = Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ # this is too import Config @@ -268,7 +268,7 @@ defmodule Igniter.Project.ConfigTest do test "integers can be used as values" do %{rewrite: rewrite} = Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ import Config config :fake, :buz, [:blat] @@ -287,7 +287,7 @@ defmodule Igniter.Project.ConfigTest do test "present values can be updated by updating map keys" do %{rewrite: rewrite} = Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ import Config config :fake, foo: %{"a" => ["a", "b"]} @@ -314,7 +314,7 @@ defmodule Igniter.Project.ConfigTest do test "it presents users with instructions on how to update a malformed config" do %{warnings: [warning]} = Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ config :fake, foo: %{"a" => ["a", "b"]} """) |> Igniter.Project.Config.configure("fake.exs", :fake, [:foo], %{"b" => ["c", "d"]}, @@ -334,7 +334,7 @@ defmodule Igniter.Project.ConfigTest do test "configures_root_key?/3" do igniter = Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ import Config config :foo, key1: "key1" @@ -352,7 +352,7 @@ defmodule Igniter.Project.ConfigTest do %{ igniter: Igniter.new() - |> Igniter.create_new_elixir_file("config/fake.exs", """ + |> Igniter.create_new_file("config/fake.exs", """ import Config config :foo, key1: [key2: "key2"] diff --git a/test/igniter/project/test_test.exs b/test/igniter/project/test_test.exs index 4e124b1..1dac3e8 100644 --- a/test/igniter/project/test_test.exs +++ b/test/igniter/project/test_test.exs @@ -7,7 +7,7 @@ defmodule Igniter.Project.TestTest do test "it adds the path if it doesn't exist" do assert %{rewrite: rewrite} = Igniter.new() - |> Igniter.include_existing_elixir_file("mix.exs") + |> Igniter.include_existing_file("mix.exs") |> Map.update!(:rewrite, fn rewrite -> source = Rewrite.source!(rewrite, "mix.exs") @@ -47,7 +47,7 @@ defmodule Igniter.Project.TestTest do test "it doesnt change anything if the setting is already configured" do assert %{rewrite: rewrite} = Igniter.new() - |> Igniter.include_existing_elixir_file("mix.exs") + |> Igniter.include_existing_file("mix.exs") |> Map.update!(:rewrite, fn rewrite -> source = Rewrite.source!(rewrite, "mix.exs")