Closed dkuku closed 6 months ago
@dkuku This does not look like an error caused by Credo.
Since the name of the check module (CredoChecks.NoAmbiguousAliases
) starts with CredoChecks
, I would guess that the failure comes from a plugin?
Judging from the error message, we can conclude that in that plugin there is a file named lib/credo_checks/no_ambiguous_aliases.ex
and that there is a case
statement on line 44, which does not seem to account for an occurence of nil
.
And the reason why this is happening is probably that the AST representation for an alias
call is
{:alias, meta, [_|_] = args}
where args
represents the parameters given to alias
(like the module name and options).
And the representation for the parameter in your code snippet is
{:alias, meta, nil}
The function in which this happens is named find_alias/2
, so I guess the plugin authors are simply not accounting for variables, parameters and likely module attributes named alias
...
Oh, sorry. You're right. It's a plugin.
On Mon, 26 Feb 2024, 16:21 René Föhring, @.***> wrote:
And the reason why this is happening is probably that the AST representation for an alias call is
{:alias, meta, [|] = args}
where args represents the parameters given to alias (like the module name and options).
And the representation for the parameter in your code snippet is
{:alias, meta, nil}
The function in which this happens is named find_alias/2, so I guess the plugin authors are simply not accounting for variables, parameters and likely module attributes named alias ...
— Reply to this email directly, view it on GitHub https://github.com/rrrene/credo/issues/1116#issuecomment-1964564144, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG4X455FFNRZCVLVKGQKGLYVSZCJAVCNFSM6AAAAABD2JVNTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRUGU3DIMJUGQ . You are receiving this because you were mentioned.Message ID: @.***>
Precheck
Environment
What were you trying to do?
The code works but credo crashes when checking it. It makes sense because I use an elixir keyword but elixir allows this:
renaming the param from
alias
toindex
fixes the problemExpected outcome
It should not fail. Maybe only raise a warning.
Actual outcome