Sha256: bc213829a35069d558fb727d2a33685b4c43a2d4db4bf5570f0ac8cf733247ef
Contents?: true
Size: 806 Bytes
Versions: 1
Compression:
Stored size: 806 Bytes
Contents
# frozen_string_literal: true require 'open3' require 'rbconfig' 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 _stdout, stderr, _status = Open3.capture3(ruby, '-cw', '-e', source) stderr.each_line do |line| line.chomp! lnum = line[/-e:(\d+):/, 1].to_i message = line[/-e:\d+: warning: (.+)$/, 1] range = source_range(processed_source.buffer, lnum, 0) add_offense(range, location: range, message: message) end end def ruby RbConfig.ruby end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-rubycw-0.1.0 | lib/rubocop/cop/rubycw/rubycw.rb |