Sha256: 59ad7f35642d3d814f2d26b7e8c1eb921e73b059b589313179f091f9fa9122a9

Contents?: true

Size: 432 Bytes

Versions: 4

Compression:

Stored size: 432 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

4 entries across 4 versions & 2 rubygems

Version Path
did_you_mean-1.1.3 lib/did_you_mean/experimental/initializer_name_correction.rb
did_you_mean-1.1.2 lib/did_you_mean/experimental/initializer_name_correction.rb
ruby-compiler-0.1.1 vendor/ruby/gems/did_you_mean-1.1.0/lib/did_you_mean/experimental/initializer_name_correction.rb
did_you_mean-1.1.0 lib/did_you_mean/experimental/initializer_name_correction.rb