zf

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

tag_fixme.ex (1343B)


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