CredoNaming v0.6.0 CredoNaming.Check.Consistency.ModuleFilename View Source
This check has a base priority of low
and works with any version of Elixir.
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
Configuration parameters
Use the following parameters to configure this check:
excluded_paths
: A list of paths to excludeDefaults to
[]
acronymes
: A list of tuples that map a module term to its path version, eg. [{"MyAppGraphQL", "myapp_graphql"}]Defaults to
nil
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 definesDefaults to
{nil, :valid_filename?}
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
root_path(filename) View Source
Returns the root path of a file, with support for umbrella projects
valid_filename?(filename, module_name, params) View Source
Returns whether the filename matches the module defined in it.