Sha256: 470280fc05d76ffdd527fc5d493e1ce6a21bce421a61e3f3fe3d33e97aeb9bbc

Contents?: true

Size: 719 Bytes

Versions: 4

Compression:

Stored size: 719 Bytes

Contents

# frozen_string_literal: true

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

        def investigate(processed_source)
          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, location: range, message: message)
          end
        end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-rubycw-0.1.4 lib/rubocop/cop/rubycw/rubycw.rb
rubocop-rubycw-0.1.3 lib/rubocop/cop/rubycw/rubycw.rb
rubocop-rubycw-0.1.2 lib/rubocop/cop/rubycw/rubycw.rb
rubocop-rubycw-0.1.1 lib/rubocop/cop/rubycw/rubycw.rb