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:
@@ -41,6 +41,11 @@
|
|||||||
# If you create your own checks, you must specify the source files for
|
# If you create your own checks, you must specify the source files for
|
||||||
# them here, so they can be loaded by Credo before running the analysis.
|
# them here, so they can be loaded by Credo before running the analysis.
|
||||||
#
|
#
|
||||||
|
# This is the ONLY load path for lib_dev/ checks: the directory is kept out
|
||||||
|
# of elixirc_paths in mix.exs on purpose, so the module is not also loaded
|
||||||
|
# from a compiled .beam (that double load produced
|
||||||
|
# "warning: redefining module Firehose.Checks.NoConnShadowing").
|
||||||
|
#
|
||||||
requires: ["lib_dev/firehose/checks/"],
|
requires: ["lib_dev/firehose/checks/"],
|
||||||
#
|
#
|
||||||
# If you want to enforce a style guide and need a more traditional linting
|
# If you want to enforce a style guide and need a more traditional linting
|
||||||
|
|||||||
+9
-2
@@ -33,8 +33,15 @@ defmodule Firehose.MixProject do
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Specifies which paths to compile per environment.
|
# 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"]
|
defp elixirc_paths(_), do: ["lib"]
|
||||||
|
|
||||||
# Specifies your project dependencies.
|
# Specifies your project dependencies.
|
||||||
|
|||||||
Reference in New Issue
Block a user