elixir-templates icon indicating copy to clipboard operation
elixir-templates copied to clipboard

Fix: Credo issue with Multi Alias syntax on creating a new project

Open bterone opened this issue 3 years ago • 0 comments

Issue

Whenever we create a new project with the elixir template, there are more files with the single alias syntax.

Specifically in the conn_case, data_case, and project_name_web files

import Ecto.Changeset 
import Ecto.Query

We cannot manually convert them into multi-alias syntax as in the conn_case and project_name_web files use quote do and scope different aliases over multiple functions. Credo will treat the project as using only single alias and raise false positives when we use mutli alias syntax

We mostly create a workaround for this by ignoring the offending files that aren't fixable and fixing files that can be (like data_case)

Solution

When applying the Credo addon, edit the credo config to ignore the offending files and fix data_case manually

Expected

Can use Multi Alias syntax in a newly created Elixir project with the template without raising credo error.

Steps to reproduce

  1. Create a new Elixir Project using the template
  2. Add one Multi-line alias syntax (e.g. import Ecto.{Changeset, Query}
  3. Run credo or mix codebase and observe error

bterone avatar May 26 '22 03:05 bterone