Skip to content

Commit 1f5ae9e

Browse files
authored
Merge pull request #1165 from rNoz/rnoz/check-format-issue-category
Credo.Check format_issue opts allow a custom category
2 parents 91350ad + 973d042 commit 1f5ae9e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/credo/check.ex

+3-4
Original file line numberDiff line numberDiff line change
@@ -687,14 +687,13 @@ defmodule Credo.Check do
687687
- `:column` Sets the issue's column.
688688
- `:exit_status` Sets the issue's exit_status.
689689
- `:severity` Sets the issue's severity.
690+
- `:category` Sets the issue's category.
690691
"""
691692
def format_issue(issue_meta, opts, check) do
692693
source_file = IssueMeta.source_file(issue_meta)
693694
params = IssueMeta.params(issue_meta)
694-
issue_category = Params.category(params, check)
695-
issue_base_priority = Params.priority(params, check)
696-
697-
priority = Priority.to_integer(issue_base_priority)
695+
issue_category = opts[:category] || Params.category(params, check)
696+
priority = params |> Params.priority(check) |> Priority.to_integer()
698697

699698
exit_status_or_category =
700699
opts[:exit_status] || Params.exit_status(params, check) || issue_category

test/credo/check_test.exs

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ defmodule Credo.CheckTest do
6868
line_no: 3,
6969
column: 15,
7070
exit_status: 23,
71-
severity: 11
71+
severity: 11,
72+
category: :custom_category
7273
)
7374
]
7475
end
@@ -91,6 +92,7 @@ defmodule Credo.CheckTest do
9192
assert issue.column == 15
9293
assert issue.exit_status == 23
9394
assert issue.severity == 11
95+
assert issue.category == :custom_category
9496
end)
9597
end
9698

0 commit comments

Comments
 (0)