Sha256: 933f61ad683182b9671a5ce475b99c5d0eb93c4bc8c4e212da930e0e263de24b

Contents?: true

Size: 694 Bytes

Versions: 2

Compression:

Stored size: 694 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Rubycw
      # Execute `ruby -cw` and wrap the warning as RuboCop offense.
      class Rubycw < Base
        include RangeHelp

        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

        def warnings(source)
          RuboCop::Rubycw::WarningCapturer.capture(source)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-rubycw-0.1.6 lib/rubocop/cop/rubycw/rubycw.rb
rubocop-rubycw-0.1.5 lib/rubocop/cop/rubycw/rubycw.rb