Sha256: ad0eb35103451f7191a17725fe11471aa097537fe4ef643b75823603d809929d

Contents?: true

Size: 889 Bytes

Versions: 4

Compression:

Stored size: 889 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:
          pattern = options['pattern'] || DEFAULT_PATTERN
          super([Parsing::ModuleContext], pattern)
        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-1.7.2 lib/simplabs/excellent/checks/module_name_check.rb
excellent-1.7.1 lib/simplabs/excellent/checks/module_name_check.rb
excellent-1.7.0 lib/simplabs/excellent/checks/module_name_check.rb
excellent-1.6.0 lib/simplabs/excellent/checks/module_name_check.rb