module ReviewDogEmitter

A custom module to properly format reviewdog json output

Public Class Methods

delete_text(path: '', idx: 0, text: '', message: 'No message', code: 'GTN000', full_line: '') click to toggle source
# File bin/lint.rb, line 17
def self.delete_text(path: '', idx: 0, text: '', message: 'No message', code: 'GTN000', full_line: '')
  error(
    path: path,
    idx: idx,
    match_start: 0,
    match_end: text.length,
    replacement: '',
    message: message,
    code: code,
    full_line: full_line
  )
end
error(path: '', idx: 0, match_start: 0, match_end: 1, replacement: nil, message: 'No message', code: 'GTN000', full_line: '') click to toggle source
# File bin/lint.rb, line 58
def self.error(path: '', idx: 0, match_start: 0, match_end: 1, replacement: nil, message: 'No message',
               code: 'GTN000', full_line: '')
  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
  )
end
file_error(path: '', message: 'None', code: 'GTN:000') click to toggle source
# File bin/lint.rb, line 30
def self.file_error(path: '', message: 'None', code: 'GTN:000')
  error(
    path: path,
    idx: 0,
    match_start: 0,
    match_end: 1,
    replacement: nil,
    message: message,
    code: code,
    full_line: ''
  )
end
message(path: '', idx: 0, match_start: 0, match_end: 1, replacement: nil, message: 'No message', level: 'WARNING', code: 'GTN000', full_line: '') click to toggle source
# File bin/lint.rb, line 73
def self.message(path: '', idx: 0, match_start: 0, match_end: 1, replacement: nil, message: 'No message',
                 level: 'WARNING', code: 'GTN000', full_line: '')
  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,
      'url' => "#{@CODE_URL}##{code.gsub(/:/, '').downcase}",
    }
  end
  if !replacement.nil?
    res['suggestions'] = [{
      'text' => replacement,
      'range' => {
        'start' => { 'line' => idx + 1, 'column' => match_start + 1 },
        'end' => end_area
      }
    }]
  end
  res
end
warning(path: '', idx: 0, match_start: 0, match_end: 1, replacement: nil, message: 'No message', code: 'GTN000', full_line: '') click to toggle source
# File bin/lint.rb, line 43
def self.warning(path: '', idx: 0, match_start: 0, match_end: 1,
                 replacement: nil, message: 'No message', code: 'GTN000', full_line: '')
  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
  )
end