app: give credo checks one load path (fixes redefining-module warning)
lib_dev/ was both compiled (elixirc_paths for :dev and :test) and source-loaded
by credo through `requires:` in .credo.exs. Two load paths for one module means
that whenever _build/dev already holds the beam, `mix credo` warned:
warning: redefining module Firehose.Checks.NoConnShadowing
(current version loaded from _build/dev/.../Elixir.Firehose.Checks.NoConnShadowing.beam)
Keep the explicit contract and drop the accidental one: `requires:` is the
documented way for credo to load project checks, so lib_dev/ now leaves
elixirc_paths in every environment. Nothing under test/ referenced the check, so
the :test entry was dead as well, and credo compiles the file on every run
anyway, so the check still gets compiled — just once.
One-time migration for checkouts that already built it:
`mix clean` (or delete _build/dev) to drop the stale beam; until then the old
warning persists. Fresh clones are unaffected.
This commit is contained in:
+9
-2
@@ -33,8 +33,15 @@ defmodule Firehose.MixProject do
|
||||
end
|
||||
|
||||
# Specifies which paths to compile per environment.
|
||||
defp elixirc_paths(:test), do: ["lib", "lib_dev", "test/support"]
|
||||
defp elixirc_paths(:dev), do: ["lib", "lib_dev"]
|
||||
#
|
||||
# `lib_dev/` is deliberately NOT compiled in any environment: it holds
|
||||
# credo-only checks (Firehose.Checks.NoConnShadowing), and credo loads them
|
||||
# itself from source via `requires:` in .credo.exs. Compiling that path as
|
||||
# well gave every run two load paths for the same module, which surfaces as
|
||||
# "warning: redefining module Firehose.Checks.NoConnShadowing" on a warm
|
||||
# `_build/dev`. Keep the single source load: if you add code under lib_dev/
|
||||
# that is NOT a credo check, give it its own compiled path instead.
|
||||
defp elixirc_paths(:test), do: ["lib", "test/support"]
|
||||
defp elixirc_paths(_), do: ["lib"]
|
||||
|
||||
# Specifies your project dependencies.
|
||||
|
||||
Reference in New Issue
Block a user