Module: RuboCop::Rubycw::WarningCapturer

Defined in:
lib/rubocop/rubycw/warning_capturer.rb

Class Method Summary collapse

Class Method Details

.capture(source) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/rubocop/rubycw/warning_capturer.rb', line 22

def self.capture(source)
  start
  RubyVM::AbstractSyntaxTree.parse(source)
  warnings
ensure
  stop
end

.startObject



30
31
32
33
34
# File 'lib/rubocop/rubycw/warning_capturer.rb', line 30

def self.start
  @verbose = $VERBOSE
  $VERBOSE = true
  @warnings = []
end

.stopObject



36
37
38
39
# File 'lib/rubocop/rubycw/warning_capturer.rb', line 36

def self.stop
  $VERBOSE = @verbose if defined?(@verbose)
  @warnings = nil
end

.warningsObject



41
42
43
# File 'lib/rubocop/rubycw/warning_capturer.rb', line 41

def self.warnings
  @warnings
end