diff --git a/lib/credo/check/warning/dbg.ex b/lib/credo/check/warning/dbg.ex index ac748aa40..9fb9d8394 100644 --- a/lib/credo/check/warning/dbg.ex +++ b/lib/credo/check/warning/dbg.ex @@ -75,6 +75,15 @@ defmodule Credo.Check.Warning.Dbg do {ast, [issue_for(issue_meta, meta, "dbg") | issues]} end + defp traverse( + {:&, _, [{:/, _, [{:dbg, meta, _}, 1]}]} = ast, + issues, + issue_meta + ) do + dbg(ast) + {ast, [issue_for(issue_meta, meta, "dbg/1") | issues]} + end + defp traverse(ast, issues, _issue_meta) do {ast, issues} end diff --git a/test/credo/check/warning/dbg_test.exs b/test/credo/check/warning/dbg_test.exs index 226f2207f..357047b4c 100644 --- a/test/credo/check/warning/dbg_test.exs +++ b/test/credo/check/warning/dbg_test.exs @@ -219,4 +219,21 @@ defmodule Credo.Check.Warning.DbgTest do assert issue.trigger == "dbg" end) end + + test "it should report a violation /11" do + ~S''' + defmodule CredoSampleModule do + def some_function(params) do + params + |> tap(&dbg/1) + end + end + ''' + |> to_source_file + |> run_check(@described_check) + |> assert_issue(fn issue -> + assert issue.line_no == 4 + assert issue.trigger == "dbg/1" + end) + end end