Sha256: f34a92fbadd888ec6fbb9d7d95914969bed8f55a44fef428ecc1b47985a094eb

Contents?: true

Size: 440 Bytes

Versions: 3

Compression:

Stored size: 440 Bytes

Contents

# -*- frozen-string-literal: true -*-

module DidYouMean
  module Experimental
    module InitializerNameCorrection
      def method_added(name)
        super

        distance = Levenshtein.distance(name.to_s, 'initialize')
        if distance != 0 && distance <= 2
          warn "warning: #{name} might be misspelled, perhaps you meant initialize?"
        end
      end
    end

    ::Class.prepend(InitializerNameCorrection)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
did_you_mean-1.0.4 lib/did_you_mean/experimental/initializer_name_correction.rb
did_you_mean-1.0.3 lib/did_you_mean/experimental/initializer_name_correction.rb
did_you_mean-1.0.2 lib/did_you_mean/experimental/initializer_name_correction.rb