View Source CredoNaming.Check.Consistency.ModuleFilename (CredoNaming v2.1.0)

This check has a base priority of low and works with any version of Elixir.

explanation

Explanation

If a file contains a single module, its filename should match the name of the module.

# preferred

# lib/foo/bar.exs
defmodule Foo.Bar, do: nil

# lib/foo/bar/bar.exs
defmodule Foo.Bar, do: nil

# lib/foo/foo.exs
defmodule Foo, do: nil

# lib/foo.exs
defmodule Foo, do: nil

# lib/foo/exceptions.exs
defmodule Foo.FirstException, do: nil
defmodule Foo.SecondException, do: nil

# NOT preferred

# lib/foo.exs
defmodule Bar, do: nil

# lib/foo/schemas/bar.exs
defmodule Foo.Bar, do: nil

check-specific-parameters

Check-Specific Parameters

Use the following parameters to configure this check:

plugins

:plugins

A list of atoms for applying plugin specific naming (ex: :phoenix)

This parameter defaults to [].

excluded_paths

:excluded_paths

A list of paths to exclude

This parameter defaults to [].

acronyms

:acronyms

A list of tuples that map a module term to its path version, eg. [{"MyAppGraphQL", "myapp_graphql"}]

This parameter defaults to [].

valid_filename_callback

:valid_filename_callback

A function (either &fun/3 or {module, fun}) that will be called on each filename with the name of the module it defines

This parameter defaults to {nil, :valid_filename?}.

apps_path

:apps_path

The path to the apps folder in umbrella projects

This parameter defaults to "apps".

general-parameters

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.

Link to this section Summary

Functions

Returns the root path of a file, with support for umbrella projects

Returns whether the filename matches the module defined in it.

Link to this section Functions

Link to this function

root_path(filename, params)

View Source

Returns the root path of a file, with support for umbrella projects

Link to this function

valid_filename?(filename, module_name, params)

View Source

Returns whether the filename matches the module defined in it.