{{- /*
Creates tag information for an item (linter/formatter).

@param {string} (positional parameter 0) Description
@returns {map[tag: string, tagType: string]}

@example {{ partial "golangci/items/tag" (dict "gcilVersion" "v1.2.3" "item" .) }}
*/ -}}

{{- $gcilVersion := .gcilVersion -}}
{{- $item := .item -}}

{{- $tag := newScratch -}}

{{- if $item.deprecation -}}
    {{- $replacement := "" -}}
    {{- if $item.deprecation.replacement -}}
        {{- $replacement = print " Use `" $item.deprecation.replacement "` instead." -}}
    {{- end -}}

    {{- $tag.SetInMap "options" "subtitle" (print (strings.FirstUpper $item.deprecation.message) $replacement) -}}
    {{- $tag.SetInMap "options" "tag" (print "Deprecated since " $item.deprecation.since) -}}
    {{- $tag.SetInMap "options" "tagType" "error" -}}
{{- else if (partial "golangci/items/compare-versions" (dict "a" $gcilVersion "b" $item.since)) -}}
    {{- $tag.SetInMap "options" "tag" "New" -}}
    {{- $tag.SetInMap "options" "tagType" "warning" -}}
{{- else if $item.canAutoFix -}}
    {{- $tag.SetInMap "options" "tag" "Autofix" -}}
    {{- $tag.SetInMap "options" "tagType" "info" -}}
{{- end -}}

{{- return ($tag.Get "options") -}}
