Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Credo.Check format_issue opts allow a custom category #1165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading