# `Bylaw.Credo.Check.Elixir.NoRemoteCallsInModuleAttributes`
[🔗](https://github.com/ryanzidago/bylaw/blob/v0.4.0/lib/bylaw/credo/check/elixir/no_remote_calls_in_module_attributes.ex#L1)

## Basics

> #### This check is disabled by default. {: .neutral}
>
> [Learn how to enable it](`e:credo:config_file.html#checks`) via `.credo.exs`.

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

## Explanation

Avoid calls into application and dependency modules from module attributes.

Module attributes are evaluated at compile time. Calling another module from
an attribute creates a compile-time dependency and embeds the returned value
in the compiled consumer.

## Examples

Avoid:

    @some_values MyApp.SomeModule.some_function()

Prefer:

    def some_values do
      MyApp.SomeModule.some_function()
    end

Literal values are accepted:

    @some_values [:one, :two]

Calls into Elixir and OTP standard-library modules are accepted by default
because they do not add dependencies between project files:

    @some_values Enum.uniq([:one, :one])

When compile-time evaluation is intentional, keep the call and disable this
check locally:

    # credo:disable-for-next-line Bylaw.Credo.Check.Elixir.NoRemoteCallsInModuleAttributes
    @some_values MyApp.SomeModule.some_function()

## Notes

Typespec attributes are ignored because calls such as `String.t()` describe
types and do not execute the named function.

External function captures stored in attributes are reported because the
compiler tracks them as compile-time dependencies too.

This check uses static AST analysis. It recognizes statically named Elixir
and Erlang modules, including nested calls inside an attribute value.

## Options

- `:allow_standard_library` - When true, accept calls into modules shipped by
  the Elixir, Kernel, and standard-library OTP applications. Defaults to true.

## Usage

Add this check to Credo's `checks:` list in `.credo.exs`:

```elixir
%{
  configs: [
    %{
      name: "default",
      checks: [
        {Bylaw.Credo.Check.Elixir.NoRemoteCallsInModuleAttributes, []}
      ]
    }
  ]
}
```

To report standard-library calls as well:

```elixir
{Bylaw.Credo.Check.Elixir.NoRemoteCallsInModuleAttributes,
 [allow_standard_library: false]}
```

## Check-Specific Parameters

Use the following parameters to configure this check:

### `:allow_standard_library`

  When true, accept calls into Elixir and OTP standard-library modules

*This parameter defaults to* `true`.

## General Parameters

Like with all checks, [general params](`e:credo:check_params.html`) can be applied.

Parameters can be configured via the [`.credo.exs` config file](`e:credo:config_file.html`).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
