Class: Rubomop::RandomMop::DeleteOption

Inherits:
Struct
  • Object
show all
Defined in:
lib/rubomop/random_mop.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#copObject

Returns the value of attribute cop

Returns:

  • (Object)

    the current value of cop



65
66
67
# File 'lib/rubomop/random_mop.rb', line 65

def cop
  @cop
end

#fileObject

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



65
66
67
# File 'lib/rubomop/random_mop.rb', line 65

def file
  @file
end

#run_rubocopObject

Returns the value of attribute run_rubocop

Returns:

  • (Object)

    the current value of run_rubocop



65
66
67
# File 'lib/rubomop/random_mop.rb', line 65

def run_rubocop
  @run_rubocop
end

#verboseObject

Returns the value of attribute verbose

Returns:

  • (Object)

    the current value of verbose



65
66
67
# File 'lib/rubomop/random_mop.rb', line 65

def verbose
  @verbose
end

Instance Method Details

#delete!Object



71
72
73
# File 'lib/rubomop/random_mop.rb', line 71

def delete!
  cop.delete!(file)
end

#parse_io(string) ⇒ Object



90
91
92
93
94
# File 'lib/rubomop/random_mop.rb', line 90

def parse_io(string)
  match_data = string.match(/(\d*) offense(s?) corrected/)
  return 0 if match_data.nil?
  match_data[1].to_i
end


66
67
68
69
# File 'lib/rubomop/random_mop.rb', line 66

def print_message
  return unless verbose
  print "Deleting #{file} from #{cop.name}" if verbose
end

#rubocop_runnerObject



79
80
81
82
83
84
85
86
87
88
# File 'lib/rubomop/random_mop.rb', line 79

def rubocop_runner
  return unless run_rubocop
  print "\nbundle exec rubocop #{file} -aD\n"
  IO.popen("bundle exec rubocop #{file} -aD") do |io|
    result_string = io.read
    puts result_string.split("\n").last
    puts "\n"
    parse_io(result_string)
  end
end

#subtract!(offense_count) ⇒ Object



75
76
77
# File 'lib/rubomop/random_mop.rb', line 75

def subtract!(offense_count)
  cop.subtract!(offense_count)
end