Class: Canon::Diff::FormattingDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/canon/diff/formatting_detector.rb

Overview

Detects if differences between lines are formatting-only (whitespace, line breaks) with no semantic content changes

Class Method Summary collapse

Class Method Details

.formatting_only?(line1, line2) ⇒ Boolean

Detect if two lines differ only in formatting

Parameters:

  • line1 (String, nil)

    First line to compare

  • line2 (String, nil)

    Second line to compare

Returns:

  • (Boolean)

    true if lines differ only in formatting



13
14
15
16
17
18
19
20
21
22
# File 'lib/canon/diff/formatting_detector.rb', line 13

def self.formatting_only?(line1, line2)
  # If both are nil or empty, not a formatting diff (no difference)
  return false if blank?(line1) && blank?(line2)

  # If only one is blank, it's not just formatting
  return false if blank?(line1) || blank?(line2)

  # Compare normalized versions
  normalize_for_comparison(line1) == normalize_for_comparison(line2)
end