CredoFilenameConsistency is a check to ensure filename consistency across an Elixir project.

Installation

Add the :credo_filename_consistency package to your mix.exs dependencies:

def deps do
  [
    {:credo_filename_consistency, "~> 0.1.0", only: [:dev, :test], runtime: false}
  ]
end

Usage

You just need to add the check in your .credo.exs configuration file:

{CredoFilenameConsistency.Check.Consistency.FilenameConsistency}

And now suppose you have a lib/foo.ex that defines a Bar module:

$ mix credo

 Consistency

 [C]  The module defined in `lib/foo.ex` is not named consistently with the
       filename. The file should be named either:

       ["lib/bar/bar.ex", "lib/bar.ex"]

       lib/foo.ex:1:11 #(Bar)

Options

Exclusions

You can exclude files or paths with the excluded_paths option:

{CredoFilenameConsistency.Check.Consistency.FilenameConsistency, excluded_paths: ["test/support", "priv", "rel", "mix.exs"]}

Acronyms

The check converts module names to paths using PascalCase convention, which means that the file lib/myapp_graphql is expected to define the module:

defmodule MyappGraphql do
end

If you want to define your own acronyms, you can do so using the acronyms option:

{CredoFilenameConsistency.Check.Consistency.FilenameConsistency, acronyms: [{"MyAppGraphQL", "myapp_graphql"}]}

Using this, the lib/myapp_graphql will expect to define the module:

defmodule MyAppGraphQL do
end

License

CredoFilenameConsistency is © 2019 Mirego and may be freely distributed under the New BSD license. See the LICENSE.md file.

The books logo is based on this lovely icon by Mr Balind, from The Noun Project. Used under a Creative Commons BY 3.0 license.

About Mirego

Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We’re a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.

We also love open-source software and we try to give back to the community as much as we can.