Sha256: 9b7949a29e74a2a9923bf16d46d508cc84f5d6c1bd9e1039510fd39c87e71ac8

Contents?: true

Size: 882 Bytes

Versions: 4

Compression:

Stored size: 882 Bytes

Contents

require 'simplabs/excellent/checks/name_check'

module Simplabs

  module Excellent

    module Checks

      # This check reports classes with bad names. Badly named classes make reading and understanding the code much harder. Class names regarded as bad
      # are for example:
      #
      # * names that are not Pascal cased (camel cased, starting with an upper case letter)
      #
      # ==== Applies to
      #
      # * classes
      class ClassNameCheck < NameCheck

        DEFAULT_PATTERN = '^[A-Z]{1}[a-zA-Z0-9]*$'

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

        protected

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

      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
excellent-2.1.1 lib/simplabs/excellent/checks/class_name_check.rb
excellent-2.1.0 lib/simplabs/excellent/checks/class_name_check.rb
excellent-2.0.1 lib/simplabs/excellent/checks/class_name_check.rb
excellent-2.0.0 lib/simplabs/excellent/checks/class_name_check.rb