OptimumCredo.Check.Readability.ModulePathMismatch (OptimumCredo v0.5.0)

View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

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

Explanation

The module namespace should mirror the directory and the file name should mirror the module, as mix phx.gen.* would generate it.

Bad

# lib/my_app_web/controllers/helper.ex
defmodule MyApp.ScreenshotHelper do
end

Good

# lib/my_app/screenshot_helper.ex
defmodule MyApp.ScreenshotHelper do
end

Top-level modules in the same file must live in the namespace of the module that matches the path (additional_modules: :nested). Use ignore_paths or allowed_modules for intentional exceptions.

Check-Specific Parameters

Use the following parameters to configure this check:

:ignore_paths

Path fragments or regexes to skip.

This parameter defaults to [].

:web_layer_dirs

Layer directories that may be omitted below a *_web root.

This parameter defaults to ["controllers", "live", "components", "channels", "plugs"].

:additional_modules

:nested (default), :report, or :ignore for extra modules.

This parameter defaults to :nested.

:allowed_modules

Module names (and children) exempt from the path rule.

This parameter defaults to [].

General Parameters

Like with all checks, general params can be applied.

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