Sha256: 8d356a5a202481209b41a29706032d872d0c9bff3d0bdec4685d5d46d8a47ae4

Contents?: true

Size: 949 Bytes

Versions: 2

Compression:

Stored size: 949 Bytes

Contents

require_relative '../ruler'

class Tailor
  module Rulers
    class AllowCamelCaseMethodsRuler < Tailor::Ruler
      def ident_update(token, lexed_line, lineno, column)
        ident_index = lexed_line.event_index(column)
        previous_event = lexed_line.event_at(ident_index - 2)
        log "previous event: #{previous_event}"

        return if previous_event.nil?

        if previous_event[1] == :on_kw && previous_event.last == "def"
          measure(token, lineno, column)
        end
      end

      # Checks to see if the method name contains capital letters.
      #
      # @param [Fixnum] token The method name.
      # @param [Fixnum] lineno Line the problem was found on.
      # @param [Fixnum] column Column the problem was found on.
      def measure(token, lineno, column)
        if token.contains_capital_letter?
          @problems << Problem.new(:camel_case_method, lineno, column)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tailor-1.0.0.alpha2 lib/tailor/rulers/allow_camel_case_methods_ruler.rb
tailor-1.0.0.alpha lib/tailor/rulers/allow_camel_case_methods_ruler.rb