module Gtn::ReviewDogEmitter

A custom module to properly format reviewdog json output

Public Class Methods

# File bin/lint.rb, line 24
def self.delete_text(path: '', idx: 0, text: '', message: 'No message', code: 'GTN000', full_line: '', fn: '')
  error(
    path: path,
    idx: idx,
    match_start: 0,
    match_end: text.length,
    replacement: '',
    message: message,
    code: code,
    full_line: full_line,
    fn: fn,
  )
end
# File bin/lint.rb, line 68
def self.error(path: '', idx: 0, match_start: 0, match_end: 1, replacement: nil, message: 'No message',
               code: 'GTN000', full_line: '', fn: '')
  self.message(
    path: path,
    idx: idx,
    match_start: match_start,
    match_end: match_end,
    replacement: replacement,
    message: message,
    level: 'ERROR',
    code: code,
    full_line: full_line,
    fn: fn,
  )
end
# File bin/lint.rb, line 38
def self.file_error(path: '', message: 'None', code: 'GTN:000', fn: '')
  error(
    path: path,
    idx: 0,
    match_start: 0,
    match_end: 1,
    replacement: nil,
    message: message,
    code: code,
    full_line: '',
    fn: fn
  )
end
# File bin/lint.rb, line 84
def self.message(path: '', idx: 0, match_start: 0, match_end: 1, replacement: nil, message: 'No message',level: 'WARNING', code: 'GTN000', full_line: '', fn: '')
  end_area = { 'line' => idx + 1, 'column' => match_end }
  end_area = { 'line' => idx + 2, 'column' => 1 } if match_end == full_line.length

  res = {
    'message' => message,
    'location' => {
      'path' => path,
      'range' => {
        'start' => { 'line' => idx + 1, 'column' => match_start + 1 },
        'end' => end_area
      }
    },
    'severity' => level
  }
  if !code.nil?
    res['code'] = {
      'value' => code
    }
    if !fn.nil?
      res['code']['url'] = "#{@CODE_URL}#method-c-#{fn}"
    end
  end
  if !replacement.nil?
    res['suggestions'] = [{
      'text' => replacement,
      'range' => {
        'start' => { 'line' => idx + 1, 'column' => match_start + 1 },
        'end' => end_area
      }
    }]
  end
  res
end
# File bin/lint.rb, line 52
def self.warning(path: '', idx: 0, match_start: 0, match_end: 1,
                 replacement: nil, message: 'No message', code: 'GTN000', full_line: '', fn: '')
  self.message(
    path: path,
    idx: idx,
    match_start: match_start,
    match_end: match_end,
    replacement: replacement,
    message: message,
    level: 'WARNING',
    code: code,
    full_line: full_line,
    fn: fn,
  )
end