Giter Site home page Giter Site logo

Multi alias use is not detected about credo HOT 5 CLOSED

rrrene avatar rrrene commented on May 8, 2024
Multi alias use is not detected

from credo.

Comments (5)

rrrene avatar rrrene commented on May 8, 2024 1

v0.3.8 contains a fix for this. Would you mind test-driving it? 😁

from credo.

rrrene avatar rrrene commented on May 8, 2024

Hi Aaron,

maybe you mistyped your example, but that is not how you use aliasing. An alias is used to reference a given module by another (shorter) name, which is by default the last part of the module atom. Your Sample module should therefore read:

defmodule Sample do
  @moduledoc false

  alias Sample.{One, Two}

  def foo do
    {One.one, Two.two}      # <----
  end
end

Was this a typo in your example or did I misinterpret the report? In any case, thanks for reporting! 👍

from credo.

aweiker avatar aweiker commented on May 8, 2024

Yes, you are correct. I messed up the sample.

I corrected the sample that way it's obvious.

Also, what I just discovered while updating it is that this works Sample.One and Sample.Two but when it is Sample.App.One and Sample.App.Two it does not.

from credo.

aweiker avatar aweiker commented on May 8, 2024

Doing some more digging into it and it appears that this may be the preferred syntax and it currently does get through the current checks.

defmodule Sample.App do
  @moduledoc false

  alias Sample.{App.One, App.Two}  # <----

  def foo do
    {One.one, Two.two}
  end
end

from credo.

aweiker avatar aweiker commented on May 8, 2024

Looks good.

from credo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.