Class: Querly::CLI::Formatter::Text

Inherits:
Base
  • Object
show all
Defined in:
lib/querly/cli/formatter.rb

Instance Method Summary collapse

Methods inherited from Base

#config_load, #fatal_error, #finish, #script_load, #start

Instance Method Details

#config_error(path, error) ⇒ Object



37
38
39
40
41
# File 'lib/querly/cli/formatter.rb', line 37

def config_error(path, error)
  STDERR.puts Rainbow("Failed to load configuration: #{path}").red
  STDERR.puts error
  STDERR.puts error.backtrace.inspect
end

#issue_found(script, rule, pair) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/querly/cli/formatter.rb', line 48

def issue_found(script, rule, pair)
  path = script.path.to_s
  src = Rainbow(pair.node.loc.expression.source.split(/\n/).first).red
  line = pair.node.loc.first_line
  col = pair.node.loc.column
  message = rule.messages.first.split(/\n/).first

  STDOUT.puts "#{path}:#{line}:#{col}\t#{src}\t#{message}"
end

#script_error(path, error) ⇒ Object



43
44
45
46
# File 'lib/querly/cli/formatter.rb', line 43

def script_error(path, error)
  STDERR.puts Rainbow("Failed to load script: #{path}").red
  STDERR.puts error.inspect
end