Jump. CredoChecks. TopLevelAliasImportRequire
(Jump.CredoChecks v0.3.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 high and works with any version of Elixir.
Explanation
Ensures that alias, import, and require statements are at the top level of a module.
Placing alias, import, or require statements inside functions, describe blocks, or
test blocks makes code harder to read and understand. Instead, these should be declared
at the module level.
# Bad
defmodule Foo do
def bar(baz) do
import Ecto.Query
# ...
end
end
# Good
defmodule Foo do
import Ecto.Query
def bar(baz) do
# ...
end
endCheck-Specific Parameters
There are no specific parameters for this check.
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.