Sha256: 440db8fcf43f32588e7dae3770b4a6a9faee1313f78f40829f3a4c0652bcbdab

Contents?: true

Size: 888 Bytes

Versions: 12

Compression:

Stored size: 888 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:
          pattern = options[:pattern] || DEFAULT_PATTERN
          super([:class], pattern)
        end
      
        protected

          def warning_args(context) #:nodoc:
            [context, 'Bad class name {{class}}.', { :class => 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/class_name_check.rb
simplabs-excellent-1.2.2 lib/simplabs/excellent/checks/class_name_check.rb
simplabs-excellent-1.3.0 lib/simplabs/excellent/checks/class_name_check.rb
simplabs-excellent-1.3.1 lib/simplabs/excellent/checks/class_name_check.rb
simplabs-excellent-1.4.0 lib/simplabs/excellent/checks/class_name_check.rb
simplabs-excellent-1.4.1 lib/simplabs/excellent/checks/class_name_check.rb
simplabs-excellent-1.4.2 lib/simplabs/excellent/checks/class_name_check.rb
simplabs-excellent-1.5.0 lib/simplabs/excellent/checks/class_name_check.rb
simplabs-excellent-1.5.1 lib/simplabs/excellent/checks/class_name_check.rb
simplabs-excellent-1.5.2 lib/simplabs/excellent/checks/class_name_check.rb
simplabs-excellent-1.5.3 lib/simplabs/excellent/checks/class_name_check.rb
excellent-1.5.4 lib/simplabs/excellent/checks/class_name_check.rb