-
Notifications
You must be signed in to change notification settings - Fork 414
/
tag_fixme.ex
50 lines (41 loc) · 1.31 KB
/
tag_fixme.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
defmodule Credo.Check.Design.TagFIXME do
use Credo.Check,
base_priority: :high,
param_defaults: [include_doc: true],
explanations: [
check: """
FIXME comments are used to indicate places where source code needs fixing.
Example:
# FIXME: this does no longer work, research new API url
defp fun do
# ...
end
The premise here is that FIXME should indeed be fixed as soon as possible and
are therefore reported by Credo.
Like all `Software Design` issues, this is just advice and might not be
applicable to your project/situation.
""",
params: [
include_doc: "Set to `true` to also include tags from @doc attributes."
]
]
@tag_name "FIXME"
alias Credo.Check.Design.TagHelper
@doc false
@impl true
def run(%SourceFile{} = source_file, params) do
issue_meta = IssueMeta.for(source_file, params)
include_doc? = Params.get(params, :include_doc, __MODULE__)
source_file
|> TagHelper.tags(@tag_name, include_doc?)
|> Enum.map(&issue_for(issue_meta, &1))
end
defp issue_for(issue_meta, {line_no, _line, trigger}) do
format_issue(
issue_meta,
message: "Found a #{@tag_name} tag in a comment: #{trigger}",
line_no: line_no,
trigger: trigger
)
end
end