Sha256: 5935deb7d2d809a5f5042e6f783c97fe9237acc07d276006ce14b874d5c90e2e

Contents?: true

Size: 1019 Bytes

Versions: 1

Compression:

Stored size: 1019 Bytes

Contents

require 'simplabs/excellent/checks/base'

module Simplabs

  module Excellent

    module Checks

      # This check reports methods with bad names. Badly named methods make reading and understanding the code much harder. Method names regarded as bad
      # are for example:
      #
      # * names that are camel cased
      #
      # ==== Applies to
      #
      # * methods
      class MethodNameCheck < NameCheck

        DEFAULT_PATTERN = /^[_a-z<>=\[|+-\/\*\~\%\&`\|\^]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/
        WHITELIST       = %w([] ! !=  !~ % & * ** + +@ - -@ / < << <= <=> == === =~ > >= >> ^ ` | ~)

        def initialize(options = {}) #:nodoc:
          pattern = options['pattern'] || DEFAULT_PATTERN
          super([Parsing::MethodContext, Parsing::SingletonMethodContext], pattern, WHITELIST)
        end

        protected

          def warning_args(context) #:nodoc:
            [context, 'Bad method name {{method}}.', { :method => context.full_name }]
          end

      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
excellent-1.7.2 lib/simplabs/excellent/checks/method_name_check.rb