Class: Rubomop::RandomMop
- Inherits:
-
Literal::Object
- Object
- Literal::Object
- Rubomop::RandomMop
- Defined in:
- lib/rubomop/random_mop.rb
Defined Under Namespace
Classes: DeleteOption
Instance Method Summary collapse
- #accept?(delete_option) ⇒ Boolean
- #cops ⇒ Object
- #delete_options ⇒ Object
- #delete_options_for(cop) ⇒ Object
- #log(message) ⇒ Object
- #mop! ⇒ Object
- #mop_once!(delete_option) ⇒ Object
Instance Method Details
#accept?(delete_option) ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rubomop/random_mop.rb', line 16 def accept?(delete_option) return false if autocorrect_only && !delete_option.cop.any_autocorrect? unless except.empty? return except.none? { delete_option.cop.name.include?(_1) } end unless blocklist.empty? return blocklist.none? { delete_option.file.include?(_1) } end unless only.empty? return only.any? { delete_option.cop.name.include?(_1) } end true # return true unless autocorrect_only # cop.autocorrect end |
#cops ⇒ Object
12 13 14 |
# File 'lib/rubomop/random_mop.rb', line 12 def cops todo_file.cops end |
#delete_options ⇒ Object
32 33 34 35 |
# File 'lib/rubomop/random_mop.rb', line 32 def cops.flat_map { (_1) } .select { accept?(_1) } end |
#delete_options_for(cop) ⇒ Object
37 38 39 |
# File 'lib/rubomop/random_mop.rb', line 37 def (cop) cop.files.map { DeleteOption.new(cop, _1, verbose, run_rubocop) } end |
#log(message) ⇒ Object
41 42 43 44 |
# File 'lib/rubomop/random_mop.rb', line 41 def log() return unless verbose print end |
#mop! ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/rubomop/random_mop.rb', line 46 def mop! number.times do |i| = next if .empty? log("#{i + 1}:") mop_once!(.sample) log("\n") end end |
#mop_once!(delete_option) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/rubomop/random_mop.rb', line 56 def mop_once!(delete_option) delete_option. if verbose delete_option.delete! return unless run_rubocop todo_file.save! offense_count = delete_option.rubocop_runner || 0 delete_option.subtract!(offense_count) end |