Module: Crystalball::SourceDiff::FormattingChecker

Defined in:
lib/crystalball/source_diff/formatting_checker.rb

Overview

Determinates if file_diff’s patch contains changes for whitespaces or comments only

Class Method Summary collapse

Class Method Details

.pure_formatting?(file_diff) ⇒ Boolean

Returns ‘true` if file_diff’s patch contains changes for whitespaces or comments only

Parameters:

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/crystalball/source_diff/formatting_checker.rb', line 12

def pure_formatting?(file_diff)
  return false unless stripable_file?(file_diff.path) && file_diff.modified?

  patch = file_diff.patch.to_s.lines

  return true if patch.empty?

  added = collect_patch(patch, '+')
  removed = collect_patch(patch, '-')

  trim_patch(added) == trim_patch(removed)
end