Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes unused function warning in MixEnv check #1090

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading