Class: EagerEye::AutoFixer
- Inherits:
-
Object
- Object
- EagerEye::AutoFixer
- Defined in:
- lib/eager_eye/auto_fixer.rb
Instance Method Summary collapse
-
#initialize(issues, interactive: true) ⇒ AutoFixer
constructor
A new instance of AutoFixer.
- #run ⇒ Object
- #suggest ⇒ Object
Constructor Details
#initialize(issues, interactive: true) ⇒ AutoFixer
Returns a new instance of AutoFixer.
5 6 7 8 9 |
# File 'lib/eager_eye/auto_fixer.rb', line 5 def initialize(issues, interactive: true) @issues = issues @interactive = interactive @files_cache = {} end |
Instance Method Details
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/eager_eye/auto_fixer.rb', line 11 def run fixes = collect_fixes return puts "No auto-fixable issues found." if fixes.empty? if @interactive apply_interactively(fixes) else apply_all(fixes) end end |
#suggest ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/eager_eye/auto_fixer.rb', line 22 def suggest fixes = collect_fixes return puts "No auto-fixable issues found." if fixes.empty? fixes.group_by { |f| f[:file] }.each do |file, file_fixes| puts "\n#{file}:" file_fixes.each do |fix| puts " Line #{fix[:line]}:" puts " - #{fix[:original]}" puts " + #{fix[:fixed]}" end end end |