Skip to content

Commit

Permalink
Merge pull request #1090 from antedeguemon/vm-fixes-unused-function-f…
Browse files Browse the repository at this point in the history
…rom-mix-env-check

Fixes unused function warning in MixEnv check
  • Loading branch information
rrrene authored Nov 17, 2023
2 parents ce7b565 + 2346b43 commit a8f661f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/credo/check/warning/mix_env.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ defmodule Credo.Check.Warning.MixEnv do

for op <- @def_ops do
# catch variables named e.g. `defp`
defp traverse({unquote(op), _, nil} = ast, issues, _issue_meta, _parens?) do
defp traverse({unquote(op), _, nil} = ast, issues, _issue_meta) do
{ast, issues}
end

Expand Down
14 changes: 14 additions & 0 deletions test/credo/check/warning/mix_env_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,18 @@ defmodule Credo.Check.Warning.MixEnvTest do
|> run_check(@described_check)
|> assert_issue()
end

test "it should report violations from variables named like def operations" do
"""
defmodule CredoSampleModule do
def some_function do
def = Mix.env()
defp = &Mix.env/0
end
end
"""
|> to_source_file
|> run_check(@described_check)
|> assert_issues()
end
end

0 comments on commit a8f661f

Please sign in to comment.