diff --git a/lib/credo/check.ex b/lib/credo/check.ex index 846a84f92..d53312943 100644 --- a/lib/credo/check.ex +++ b/lib/credo/check.ex @@ -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 diff --git a/test/credo/check_test.exs b/test/credo/check_test.exs index 6d82ca688..e711ccc05 100644 --- a/test/credo/check_test.exs +++ b/test/credo/check_test.exs @@ -66,7 +66,8 @@ defmodule Credo.CheckTest do line_no: 3, column: 15, exit_status: 23, - severity: 11 + severity: 11, + category: :custom_category ) ] end @@ -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