zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

tag_todo.ex (1290B)


      1 defmodule Credo.Check.Design.TagTODO do
      2   use Credo.Check,
      3     param_defaults: [include_doc: true],
      4     explanations: [
      5       check: """
      6       TODO comments are used to remind yourself of source code related things.
      7 
      8       Example:
      9 
     10           # TODO: move this to a Helper module
     11           defp fun do
     12             # ...
     13           end
     14 
     15       The premise here is that TODO should be dealt with in the near future and
     16       are therefore reported by Credo.
     17 
     18       Like all `Software Design` issues, this is just advice and might not be
     19       applicable to your project/situation.
     20       """,
     21       params: [
     22         include_doc: "Set to `true` to also include tags from @doc attributes."
     23       ]
     24     ]
     25 
     26   alias Credo.Check.Design.TagHelper
     27 
     28   @tag_name "TODO"
     29 
     30   @doc false
     31   @impl true
     32   def run(%SourceFile{} = source_file, params) do
     33     issue_meta = IssueMeta.for(source_file, params)
     34     include_doc? = Params.get(params, :include_doc, __MODULE__)
     35 
     36     source_file
     37     |> TagHelper.tags(@tag_name, include_doc?)
     38     |> Enum.map(&issue_for(issue_meta, &1))
     39   end
     40 
     41   defp issue_for(issue_meta, {line_no, _line, trigger}) do
     42     format_issue(
     43       issue_meta,
     44       message: "Found a #{@tag_name} tag in a comment: #{trigger}",
     45       line_no: line_no,
     46       trigger: trigger
     47     )
     48   end
     49 end