View Source mix styler.inline_attrs (Styler v1.10.1)

WARNING: EXPERIMENTAL | Inlines module attributes that are only referenced once in their module.

This is known to create invalid code. It's far from perfect. It can still be a helpful first step in refactoring though.

Formats files with a currently hard-coded length of 122.

Usage:

mix styler.inline_attrs <file_path> [... additional file paths]

mix styler.inline_attrs path/to/my/file.ex path/to/another_file.ex

Example:

# This ...
defmodule A do
  @non_literal_attr Application.compile_env(...)
  @literal_value_with_only_one_reference :my_key

  def foo(), do: Application.get_env(:my_app, @literal_value_with_only_one_reference)
end

# Becomes this
defmodule A do
  @non_literal_attr Application.compile_env(...)

  def foo(), do: Application.get_env(:my_app, :my_key)
end