Skip to content

Commit

Permalink
Add warnings about malformed issue triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrene committed Jan 9, 2024
1 parent dbc886b commit bf0af1b
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions lib/credo/test/case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,33 @@ defmodule Credo.Test.Case do
|> to_source_file()
|> run_check(MyProject.MyCheck, foo_parameter: "bar")
"""
def run_check(source_file, check, params \\ []) do
CheckRunner.run_check(source_file, check, params)
def run_check(source_files, check, params \\ []) do
issues = CheckRunner.run_check(source_files, check, params)

warn_on_malformed_issues(source_files, issues)

issues
end

defp warn_on_malformed_issues(_source_files, issues) do
Enum.each(issues, fn issue ->
case issue.trigger do
{:__no_trigger__} ->
:ok

trigger when is_nil(trigger) ->
IO.warn(":trigger is nil")

trigger when is_binary(trigger) ->
:ok

trigger when is_atom(trigger) ->
:ok

trigger ->
IO.warn(":trigger is not a binary: #{inspect(trigger, pretty: true)}")
end
end)
end

#
Expand Down

0 comments on commit bf0af1b

Please sign in to comment.