From 97309878467b673ee045ebcd7ba9ec38d5f3aadc Mon Sep 17 00:00:00 2001 From: Willem van den Ende Date: Mon, 26 Oct 2026 20:01:33 +0000 Subject: [PATCH] app: give credo checks one load path (fixes redefining-module warning) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- app/.credo.exs | 5 +++++ app/mix.exs | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/.credo.exs b/app/.credo.exs index 0a5f34a..88f64e3 100644 --- a/app/.credo.exs +++ b/app/.credo.exs @@ -41,6 +41,11 @@ # 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. # + # 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/"], # # If you want to enforce a style guide and need a more traditional linting diff --git a/app/mix.exs b/app/mix.exs index f4eb3a0..c1bdc1a 100644 --- a/app/mix.exs +++ b/app/mix.exs @@ -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.