<commit_before>" Author: <NAME> <<EMAIL>>
" Description: Support cfn-python-lint for AWS Cloudformation template file

function! ale_linters#cloudformation#cfn_python_lint#Handle(buffer, lines) abort
    " Matches patterns line the following:
    "
    " sample.template.yaml:96:7:96:15:E3012:Property Resources/Sample/Properties/FromPort should be of type Integer
    let l:pattern = '\v^(.*):(\d+):(\d+):(\d+):(\d+):([[:alnum:]]+):(.*)$'
    let l:output = []

    for l:match in ale#util#GetMatches(a:lines, l:pattern)
        let l:code = l:match[6]

        if ale#path#IsBufferPath(a:buffer, l:match[1])
            call add(l:output, {
            \   'lnum': l:match[2],
            \   'col': l:match[3],
            \   'end_lnum': l:match[4],
            \   'end_col': l:match[5],
            \   'code': l:code,
            \   'type': l:code[:0] is# 'E' ? 'E' : 'W',
            \   'text': l:match[7]
            \})
        endif
    endfor

    return l:output
endfunction

call ale#linter#Define('cloudformation', {
\   'name': 'cloudformation',
\   'executable': 'cfn-lint',
\   'command': 'cfn-lint --template %t --format parseable',
\   'callback': 'ale_linters#cloudformation#cfn_python_lint#Handle',
\})<commit_msg>#2547 Add a cfn-lint alias for cloudformation<commit_after>" Author: <NAME> <<EMAIL>>
" Description: Support cfn-python-lint for AWS Cloudformation template file

function! ale_linters#cloudformation#cfn_python_lint#Handle(buffer, lines) abort
    " Matches patterns line the following:
    "
    " sample.template.yaml:96:7:96:15:E3012:Property Resources/Sample/Properties/FromPort should be of type Integer
    let l:pattern = '\v^(.*):(\d+):(\d+):(\d+):(\d+):([[:alnum:]]+):(.*)$'
    let l:output = []

    for l:match in ale#util#GetMatches(a:lines, l:pattern)
        let l:code = l:match[6]

        if ale#path#IsBufferPath(a:buffer, l:match[1])
            call add(l:output, {
            \   'lnum': l:match[2],
            \   'col': l:match[3],
            \   'end_lnum': l:match[4],
            \   'end_col': l:match[5],
            \   'code': l:code,
            \   'type': l:code[:0] is# 'E' ? 'E' : 'W',
            \   'text': l:match[7]
            \})
        endif
    endfor

    return l:output
endfunction

call ale#linter#Define('cloudformation', {
\   'name': 'cloudformation',
\   'aliases': ['cfn-lint'],
\   'executable': 'cfn-lint',
\   'command': 'cfn-lint --template %t --format parseable',
\   'callback': 'ale_linters#cloudformation#cfn_python_lint#Handle',
\})
{'fraction_non_alphanumeric': 0.1844698462751281, 'fraction_numerical': 0.016554986204178165, 'mean_word_length': 2.7488921713441656, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6879805', 'n_tokens_mistral': 920, 'n_tokens_neox': 895, 'n_words': 174}