diff --git a/lib/nimble_template/addons/credo.ex b/lib/nimble_template/addons/credo.ex index 0a0bde19..d9e4be12 100644 --- a/lib/nimble_template/addons/credo.ex +++ b/lib/nimble_template/addons/credo.ex @@ -33,7 +33,6 @@ defmodule NimbleTemplate.Addons.Credo do project |> inject_mix_dependency!() |> edit_mix!() - |> edit_web_entry!() end defp inject_mix_dependency!(project) do @@ -60,48 +59,4 @@ defmodule NimbleTemplate.Addons.Credo do project end - - defp edit_web_entry!( - %Project{web_path: web_path, web_module: web_module, mix_project?: false} = project - ) do - Generator.replace_content( - "#{web_path}.ex", - """ - def verified_routes do - quote do - use Phoenix.VerifiedRoutes, - endpoint: #{web_module}.Endpoint, - router: #{web_module}.Router, - statics: #{web_module}.static_paths() - end - end - """, - "" - ) - - Generator.replace_content( - "#{web_path}.ex", - """ - defp html_helpers do - """, - """ - def verified_routes do - quote do - use Phoenix.VerifiedRoutes, - endpoint: #{web_module}.Endpoint, - router: #{web_module}.Router, - statics: #{web_module}.static_paths() - end - end - - defp html_helpers do - """ - ) - - project - end - - defp edit_web_entry!(project) do - project - end end diff --git a/lib/nimble_template/helpers/credo.ex b/lib/nimble_template/helpers/credo.ex index 74f9bb9b..c22bf384 100644 --- a/lib/nimble_template/helpers/credo.ex +++ b/lib/nimble_template/helpers/credo.ex @@ -23,6 +23,8 @@ defmodule NimbleTemplate.CredoHelper do |> disable_rules(@do_single_expression_rule_name) disable_on_core_components(project) + + edit_web_entry(project) end @spec suppress_credo_warnings_for_phoenix_api_project(Project.t()) :: :ok @@ -89,4 +91,41 @@ defmodule NimbleTemplate.CredoHelper do ) end end + + defp edit_web_entry(%Project{web_path: web_path, web_module: web_module} = project) do + Generator.delete_content!( + "#{web_path}.ex", + """ + def verified_routes do + quote do + use Phoenix.VerifiedRoutes, + endpoint: #{web_module}.Endpoint, + router: #{web_module}.Router, + statics: #{web_module}.static_paths() + end + end + """ + ) + + Generator.replace_content!( + "#{web_path}.ex", + """ + defp html_helpers do + """, + """ + def verified_routes do + quote do + use Phoenix.VerifiedRoutes, + endpoint: #{web_module}.Endpoint, + router: #{web_module}.Router, + statics: #{web_module}.static_paths() + end + end + + defp html_helpers do + """ + ) + + project + end end