Repository: rrrene/credo (elixir)

Issue:
Credo.Check.Readability.VariableNames dont work on function parameter variables
### Environment

* Credo version: 0.8.10
* Erlang/Elixir version: Erlang/OTP 18 [erts-7.3] / Elixir 1.4.2

### What were you trying to do?
suppose we have code like this
```
def some_func(notSnakeCase) do
  notSnakeCase + 1
end
```

### Expected outcome
Code Readability.
Variable names should be written in snake_case.


### Actual outcome
nothing


Pull request description:
Added more code paths which should trigger Credo.Check.Readability.VariableNames
Should fix #483 

Patch:
diff --git a/lib/credo/check/readability/variable_names.ex b/lib/credo/check/readability/variable_names.ex
index 3f92c11c..6f211cf1 100644
--- a/lib/credo/check/readability/variable_names.ex
+++ b/lib/credo/check/readability/variable_names.ex
@@ -32,6 +32,21 @@ defmodule Credo.Check.Readability.VariableNames do
   defp traverse({:=, _meta, [lhs, _rhs]} = ast, issues, issue_meta) do
     {ast, issues_for_lhs(lhs, issues, issue_meta)}
   end
+  defp traverse({:->, _meta, [lhs, _rhs]} = ast, issues, issue_meta) do
+    {ast, issues_for_lhs(lhs, issues, issue_meta)}
+  end
+  defp traverse({:<-, _meta, [{:|, _comp_meta, [_lhs, rhs]}, _comp_rhs]} = ast, issues, issue_meta) do
+    {ast, issues_for_lhs(rhs, issues, issue_meta)}
+  end
+  defp traverse({:<-, _meta, [lhs, _rhs]} = ast, issues, issue_meta) do
+    {ast, issues_for_lhs(lhs, issues, issue_meta)}
+  end
+  defp traverse({:def, _meta, [{_fun, _fun_meta, [lhs, _rhs]}, _fun_rhs]} = ast, issues, issue_meta) do
+    {ast, issues_for_lhs(lhs, issues, issue_meta)}
+  end
+  defp traverse({:defp, _meta, [{_fun, _fun_meta, [lhs, _rhs]}, _fun_rhs]} = ast, issues, issue_meta) do
+    {ast, issues_for_lhs(lhs, issues, issue_meta)}
+  end
 
   defp traverse(ast, issues, _issue_meta) do
     {ast, issues}


Test patch:
diff --git a/test/credo/check/readability/variable_names_test.exs b/test/credo/check/readability/variable_names_test.exs
index 2347db84..a429ae87 100644
--- a/test/credo/check/readability/variable_names_test.exs
+++ b/test/credo/check/readability/variable_names_test.exs
@@ -126,6 +126,125 @@ defmodule Credo.Check.Readability.VariableNamesTest do
     |> assert_issue(@described_check)
   end
 
+  test "it should report a violation /9" do
+"""
+defmodule CredoSampleModule do
+  def some_function(oneParam, twoParam) do
+    :ok
+  end
+end
+""" |> to_source_file
+    |> assert_issue(@described_check)
+  end
+
+  test "it should report a violation /10" do
+"""
+defmodule CredoSampleModule do
+  def some_function(param, p2, p3) do
+    [someValue + v2 + v3 | {someValue} <- param, v2 <- p2, v3 <- p3]
+  end
+end
+""" |> to_source_file
+    |> assert_issue(@described_check)
+  end
+
+  test "it should report a violation /11" do
+"""
+defmodule CredoSampleModule do
+  def some_function(param) do
+    for someValue <- param do
+      someValue + 1
+    end
+  end
+end
+""" |> to_source_file
+    |> assert_issue(@described_check)
+  end
+
+  test "it should report a violation /12" do
+"""
+defmodule CredoSampleModule do
+  def some_function(param) do
+    case param do
+      0 -> :ok
+      1 -> :ok
+      someValue -> :error
+    end
+  end
+end
+""" |> to_source_file
+    |> assert_issue(@described_check)
+  end
+
+  test "it should report a violation /13" do
+"""
+defmodule CredoSampleModule do
+  def some_function(_param) do
+    try do
+      raise "oops"
+    catch
+      someValue -> :error
+    end
+  end
+end
+""" |> to_source_file
+    |> assert_issue(@described_check)
+  end
+
+  test "it should report a violation /14" do
+"""
+defmodule CredoSampleModule do
+  def some_function(param) do
+    receive do
+      {:get, someJam} -> :ok
+      {:put, ^param} -> :ok
+    end
+  end
+end
+""" |> to_source_file
+    |> assert_issue(@described_check)
+  end
+
+  test "it should report a violation /15" do
+"""
+defmodule CredoSampleModule do
+  def some_function(timeOut) do
+    receive do
+      _ -> :ok
+    after
+      timeOut -> :timeout
+    end
+  end
+end
+""" |> to_source_file
+    |> assert_issue(@described_check)
+  end
+
+  test "it should report a violation /16" do
+"""
+defmodule CredoSampleModule do
+  def some_function(param) do
+    fn (otherParam) -> param + otherParam end
+  end
+end
+""" |> to_source_file
+    |> assert_issue(@described_check)
+  end
+
+  test "it should report a violation /17" do
+"""
+defmodule CredoSampleModule do
+  def some_function(param) do
+    with {:ok, v1} <- M.f1(param),
+         {:ok, v2} <- M.f2(v1),
+         {:ok, someValue} <- M.f3(v2),
+         do: M.f0(someValue)
+  end
+end
+""" |> to_source_file
+    |> assert_issue(@described_check)
+  end
+
   test "it should report multiple violations" do
     """
     defmodule CredoSampleModule do