Sha256: 1f350ec992c8b0c03bf25a92e42c9abcff3fed056a40a30db2ed104ffcdab26a

Contents?: true

Size: 864 Bytes

Versions: 12

Compression:

Stored size: 864 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_<>=~@\[\]]*[=!\?]?$/

        def initialize(options = {}) #:nodoc:
          pattern = options['pattern'] || DEFAULT_PATTERN
          super([:defn, :defs], pattern)
        end

        protected

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

      end

    end

  end

end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
simplabs-excellent-1.2.1 lib/simplabs/excellent/checks/method_name_check.rb
simplabs-excellent-1.2.2 lib/simplabs/excellent/checks/method_name_check.rb
simplabs-excellent-1.3.0 lib/simplabs/excellent/checks/method_name_check.rb
simplabs-excellent-1.3.1 lib/simplabs/excellent/checks/method_name_check.rb
simplabs-excellent-1.4.0 lib/simplabs/excellent/checks/method_name_check.rb
simplabs-excellent-1.4.1 lib/simplabs/excellent/checks/method_name_check.rb
simplabs-excellent-1.4.2 lib/simplabs/excellent/checks/method_name_check.rb
simplabs-excellent-1.5.0 lib/simplabs/excellent/checks/method_name_check.rb
simplabs-excellent-1.5.1 lib/simplabs/excellent/checks/method_name_check.rb
simplabs-excellent-1.5.2 lib/simplabs/excellent/checks/method_name_check.rb
simplabs-excellent-1.5.3 lib/simplabs/excellent/checks/method_name_check.rb
excellent-1.5.4 lib/simplabs/excellent/checks/method_name_check.rb