class Pronto::ClangTidy::Diagnostic

a class that represents a single diagnostic emitted by clang-tidy

Attributes

col_no[R]
filename[R]
hints[R]
level[R]
line_no[R]
message[R]

Private Class Methods

new(filename, line_no, col_no, level, message) click to toggle source
# File lib/pronto/clang_tidy/diagnostic.rb, line 8
def initialize(filename, line_no, col_no, level, message)
  @filename = abs(filename)
  @line_no = line_no.to_i
  @col_no = col_no.to_i
  @level = level.to_sym
  @message = message
  @hints = ''
end

Private Instance Methods

abs(pathname) click to toggle source

converts the given String or Pathname to an absolute Pathname

# File lib/pronto/clang_tidy/diagnostic.rb, line 34
def abs(pathname)
  Pathname.new File.absolute_path Pathname.new pathname
end
format_diagnostic() click to toggle source
# File lib/pronto/clang_tidy/diagnostic.rb, line 26
def format_diagnostic
  "#{formatted_filename}:#{line_no}:#{col_no}: #{level}: #{message}\n" \
  "```\n#{hints}```\n"
end
formatted_filename() click to toggle source
# File lib/pronto/clang_tidy/diagnostic.rb, line 17
def formatted_filename
  # output a relative path when filename is inside working directory
  if filename.to_s.start_with?(abs(Pathname.pwd).to_s)
    filename.relative_path_from(Pathname.pwd)
  else
    filename.to_s # absolute otherwise
  end
end