Credo for umbrella apps

Background

Following my question on Umbrella projects:

I know have it clear that the mix.exs file of my umbrella should be for general tooling and tasks my projects directly don’t depend on.

One such tool is credo: https://github.com/rrrene/credo

Problem

My projects don’t depend or need credo, but I sure like having it around. My objective would therefore be to have mix credo --strict evaluate all my umbrella applications, without me having to specifically install it in every single app.

I understand this is possible, however when I do mix credo --strict it always shows I have 0 problems, even though I have the code with TODO tags and other issue that I know trigger it.

Obviously my configuration is not set up correctly.

Configuration

This is my folder structure:

.
β”œβ”€β”€ README.md
β”œβ”€β”€ apps
β”‚   β”œβ”€β”€ auction_house
β”‚   β”‚   β”œβ”€β”€ README.md
β”‚   β”‚   β”œβ”€β”€ config
β”‚   β”‚   β”œβ”€β”€ cover
β”‚   β”‚   β”œβ”€β”€ lib
β”‚   β”‚   β”œβ”€β”€ mix.exs
β”‚   β”‚   └── test
β”‚   β”œβ”€β”€ store
β”‚   β”‚   β”œβ”€β”€ README.md
β”‚   β”‚   β”œβ”€β”€ lib
β”‚   β”‚   β”œβ”€β”€ mix.exs
β”‚   β”‚   └── test
β”œβ”€β”€ config
β”‚   β”œβ”€β”€ config.exs
β”‚   β”œβ”€β”€ dev.exs
β”‚   β”œβ”€β”€ prod.exs
β”‚   └── test.exs
β”œβ”€β”€ mix.exs
└── mix.lock

So as you can see, each app has its own mix.exs file which only has the very specific dependencies the projects depends on.

Then on a higher level (apps folder) I have a mix.exs file for the umbrella project. This is what that file looks like:

defmodule MarketManager.MixProject do
  use Mix.Project

  ##########
  # Public #
  ##########

  def project do
    [
      apps_path: "apps",
      version: "1.0.0",
      elixir: "~> 1.10",
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      ]
  end

  def application do
    [
      extra_applications: [:logger],
      mod: {MarketManager.Application, [env: Mix.env()]} # No idea what to put here, really
    ]
  end

  ###########
  # Private #
  ###########

  defp deps do
    [
      # Testing and Dev
      {:credo, "~> 1.4", only: [:test, :dev], runtime: false}
    ]
  end

end

Question

What am I doing wrong?

Turns out several things were wrong. To start, my umbrella mix.exs file has stuff it doesn’t need:

defmodule MarketManager.MixProject do
  use Mix.Project

  def project do
    [
      apps_path: "apps",
      version: "1.0.0",
      elixir: "~> 1.10",
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      ]
  end

  defp deps do
    [
      # Testing and Dev
      {:credo, "~> 1.4", only: [:test, :dev], runtime: false}
    ]
  end

end

Done. This is all that it should have.

With that fixed, turns out my auction_house app should not have a config folder. Instead, it should use the config folder of the umbrella project itself.

With these two issues fixed, credo now works as expected !

4 Likes