class RuboCop::Cop::Rubycw::Rubycw

Execute `ruby -cw` and wrap the warning as RuboCop offense.

Public Instance Methods

on_new_investigation() click to toggle source
# File lib/rubocop/cop/rubycw/rubycw.rb, line 10
def on_new_investigation
  source = processed_source.raw_source

  warnings(source).each do |line|
    lnum = line[/.+:(\d+):/, 1].to_i
    message = line[/.+:\d+: warning: (.+)$/, 1]

    range = source_range(processed_source.buffer, lnum, 0)
    add_offense(range, message: message)
  end
end
warnings(source) click to toggle source
# File lib/rubocop/cop/rubycw/rubycw.rb, line 22
def warnings(source)
  RuboCop::Rubycw::WarningCapturer.capture(source)
end