Class: RuboCop::Gradual::Process::Diff
- Inherits:
-
Object
- Object
- RuboCop::Gradual::Process::Diff
- Defined in:
- lib/rubocop/gradual/process/diff.rb
Overview
Diff class represents the difference between two RuboCop Gradual results.
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #add_files(files, key) ⇒ Object
- #add_issues(path, fixed: [], moved: [], new: [], unchanged: []) ⇒ Object
-
#initialize ⇒ Diff
constructor
A new instance of Diff.
- #state ⇒ Object
- #statistics ⇒ Object
Constructor Details
#initialize ⇒ Diff
Returns a new instance of Diff.
10 11 12 |
# File 'lib/rubocop/gradual/process/diff.rb', line 10 def initialize @files = {} end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
8 9 10 |
# File 'lib/rubocop/gradual/process/diff.rb', line 8 def files @files end |
Instance Method Details
#add_files(files, key) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rubocop/gradual/process/diff.rb', line 36 def add_files(files, key) files.each do |file| add_issues(file.path, **{ key => file.issues }) end self end |
#add_issues(path, fixed: [], moved: [], new: [], unchanged: []) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rubocop/gradual/process/diff.rb', line 43 def add_issues(path, fixed: [], moved: [], new: [], unchanged: []) @files[path] = { fixed: fixed, moved: moved, new: new, unchanged: unchanged } log_file_issues(path) if Configuration.debug? self end |
#state ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/rubocop/gradual/process/diff.rb', line 14 def state return :new if new? return :complete if statistics[:left].zero? return :worse if statistics[:new].positive? return :better if statistics[:fixed].positive? return :updated if statistics[:moved].positive? :no_changes end |
#statistics ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rubocop/gradual/process/diff.rb', line 24 def statistics @statistics ||= begin fixed = count_issues(:fixed) moved = count_issues(:moved) new = count_issues(:new) unchanged = count_issues(:unchanged) left = moved + new + unchanged { fixed: fixed, moved: moved, new: new, unchanged: unchanged, left: left } end end |