Skip to content

Commit

Permalink
feat+refact+test(check): format_issue opts allow a custom category
Browse files Browse the repository at this point in the history
  • Loading branch information
rNoz committed Nov 28, 2024
1 parent 2143bd9 commit 973d042
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lib/credo/check.ex
Original file line number Diff line number Diff line change
Expand Up @@ -691,14 +691,13 @@ defmodule Credo.Check do
- `:column` Sets the issue's column.
- `:exit_status` Sets the issue's exit_status.
- `:severity` Sets the issue's severity.
- `:category` Sets the issue's category.
"""
def format_issue(issue_meta, opts, check) do
source_file = IssueMeta.source_file(issue_meta)
params = IssueMeta.params(issue_meta)
issue_category = Params.category(params, check)
issue_base_priority = Params.priority(params, check)

priority = Priority.to_integer(issue_base_priority)
issue_category = opts[:category] || Params.category(params, check)
priority = params |> Params.priority(check) |> Priority.to_integer()

exit_status_or_category =
opts[:exit_status] || Params.exit_status(params, check) || issue_category
Expand Down
4 changes: 3 additions & 1 deletion test/credo/check_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ defmodule Credo.CheckTest do
line_no: 3,
column: 15,
exit_status: 23,
severity: 11
severity: 11,
category: :custom_category
)
]
end
Expand All @@ -89,6 +90,7 @@ defmodule Credo.CheckTest do
assert issue.column == 15
assert issue.exit_status == 23
assert issue.severity == 11
assert issue.category == :custom_category
end)
end
end

0 comments on commit 973d042

Please sign in to comment.