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: GitHub - rrrene/credo: A static code analysis tool for the Elixir language with a focus on code consistency and teaching.

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