Skip to content

Commit

Permalink
Merge pull request #1165 from rNoz/rnoz/check-format-issue-category
Browse files Browse the repository at this point in the history
Credo.Check format_issue opts allow a custom category
  • Loading branch information
rrrene authored Dec 24, 2024
2 parents 91350ad + 973d042 commit 1f5ae9e
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 @@ -687,14 +687,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 @@ -68,7 +68,8 @@ defmodule Credo.CheckTest do
line_no: 3,
column: 15,
exit_status: 23,
severity: 11
severity: 11,
category: :custom_category
)
]
end
Expand All @@ -91,6 +92,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

Expand Down

0 comments on commit 1f5ae9e

Please sign in to comment.