Sha256: b44ae4b340dd946473e0c4ed5bc09da51c675e290731e654938050c099aa1b97

Contents?: true

Size: 879 Bytes

Versions: 4

Compression:

Stored size: 879 Bytes

Contents

require 'simplabs/excellent/checks/base'

module Simplabs

  module Excellent

    module Checks

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

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

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

        protected

          def warning_args(context) #:nodoc:
            [context, 'Bad module name {{module}}.', { :module => 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/module_name_check.rb
excellent-2.1.0 lib/simplabs/excellent/checks/module_name_check.rb
excellent-2.0.1 lib/simplabs/excellent/checks/module_name_check.rb
excellent-2.0.0 lib/simplabs/excellent/checks/module_name_check.rb