Skip to content

Commit

Permalink
More specific error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
frerich committed Dec 16, 2023
1 parent 46e9ca6 commit 155b9d5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/credo/check/refactor/utc_now_truncate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ defmodule Credo.Check.Refactor.UtcNowTruncate do
issues,
issue_meta
) do
new_issue = issue_for(issue_meta, meta[:line], "utc_now_truncate")
new_issue = issue_for(issue_meta, meta[:line], "DateTime")
{ast, issues ++ List.wrap(new_issue)}
end

Expand All @@ -57,7 +57,7 @@ defmodule Credo.Check.Refactor.UtcNowTruncate do
issues,
issue_meta
) do
new_issue = issue_for(issue_meta, meta[:line], "utc_now_truncate")
new_issue = issue_for(issue_meta, meta[:line], "DateTime")
{ast, issues ++ List.wrap(new_issue)}
end

Expand All @@ -76,7 +76,7 @@ defmodule Credo.Check.Refactor.UtcNowTruncate do
issues,
issue_meta
) do
new_issue = issue_for(issue_meta, meta[:line], "utc_now_truncate")
new_issue = issue_for(issue_meta, meta[:line], "DateTime")
{ast, issues ++ List.wrap(new_issue)}
end

Expand All @@ -95,7 +95,7 @@ defmodule Credo.Check.Refactor.UtcNowTruncate do
issues,
issue_meta
) do
new_issue = issue_for(issue_meta, meta[:line], "utc_now_truncate")
new_issue = issue_for(issue_meta, meta[:line], "DateTime")
{ast, issues ++ List.wrap(new_issue)}
end

Expand All @@ -112,7 +112,7 @@ defmodule Credo.Check.Refactor.UtcNowTruncate do
issues,
issue_meta
) do
new_issue = issue_for(issue_meta, meta[:line], "utc_now_truncate")
new_issue = issue_for(issue_meta, meta[:line], "NaiveDateTime")
{ast, issues ++ List.wrap(new_issue)}
end

Expand All @@ -128,7 +128,7 @@ defmodule Credo.Check.Refactor.UtcNowTruncate do
issues,
issue_meta
) do
new_issue = issue_for(issue_meta, meta[:line], "utc_now_truncate")
new_issue = issue_for(issue_meta, meta[:line], "NaiveDateTime")
{ast, issues ++ List.wrap(new_issue)}
end

Expand All @@ -147,7 +147,7 @@ defmodule Credo.Check.Refactor.UtcNowTruncate do
issues,
issue_meta
) do
new_issue = issue_for(issue_meta, meta[:line], "utc_now_truncate")
new_issue = issue_for(issue_meta, meta[:line], "NaiveDateTime")
{ast, issues ++ List.wrap(new_issue)}
end

Expand All @@ -166,20 +166,20 @@ defmodule Credo.Check.Refactor.UtcNowTruncate do
issues,
issue_meta
) do
new_issue = issue_for(issue_meta, meta[:line], "utc_now_truncate")
new_issue = issue_for(issue_meta, meta[:line], "NaiveDateTime")
{ast, issues ++ List.wrap(new_issue)}
end

defp traverse(ast, issues, _issue_meta) do
{ast, issues}
end

defp issue_for(issue_meta, line_no, trigger) do
defp issue_for(issue_meta, line_no, module) do
format_issue(
issue_meta,
message:
"Pass time unit to `{Naive}DateTime.utc_now` instead of composing with `{Naive}DateTime.truncate/2`.",
trigger: trigger,
"Pass time unit to `#{module}.utc_now` instead of composing with `#{module}.truncate/2`.",
trigger: "#{module}.truncate/2",
line_no: line_no
)
end
Expand Down

0 comments on commit 155b9d5

Please sign in to comment.