Class: Gergich::Capture::RubocopCapture
- Inherits:
-
BaseCapture
- Object
- BaseCapture
- Gergich::Capture::RubocopCapture
- Defined in:
- lib/gergich/capture/rubocop_capture.rb
Constant Summary collapse
- SEVERITY_MAP =
{ "R" => "info", # refactor "C" => "info", # convention "W" => "warn", # warning "E" => "error", # error "F" => "error" # fatal }.freeze
Instance Method Summary collapse
Methods inherited from BaseCapture
inherited, normalize_captor_class_name
Instance Method Details
#run(output) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/gergich/capture/rubocop_capture.rb', line 14 def run(output) # Example: # bin/gergich:47:8: C: Prefer double-quoted strings # if ENV['DEBUG'] # ^^^^^^^ first_line_pattern = /^([^:\n]+):(\d+):\d+:\s(\w):\s/ parts = output.split(first_line_pattern) parts.shift = [] until parts.empty? file = parts.shift line = parts.shift severity = parts.shift = parts.shift # if there is code context at the end, separate it and indent it # so that gerrit preserves formatting if /(?<context>[^\n]+\n *\^+\n)/m =~ .sub!(context, "\n" + context.gsub(/^/, " ")) end << { path: file, position: line.to_i, message: "[rubocop] #{}", severity: SEVERITY_MAP[severity] } end end |