Sha256: a78df0d6643fc2131ee12184ff266eec2911782d7e439a4d9818f9e07b6b7f35

Contents?: true

Size: 614 Bytes

Versions: 3

Compression:

Stored size: 614 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # This cops checks for class and module names with
      # an underscore in them.
      class ClassAndModuleCamelCase < Cop
        MSG = 'Use CamelCase for classes and modules.'

        def on_class(node)
          check_name(node)

          super
        end

        def on_module(node)
          check_name(node)

          super
        end

        private

        def check_name(node)
          name = node.loc.name.source

          add_offence(:convention, node.loc.name, MSG) if name =~ /_/
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
rubocop-0.9.1 lib/rubocop/cop/style/class_and_module_camel_case.rb
sabat-rubocop-0.9.0 lib/rubocop/cop/style/class_and_module_camel_case.rb
rubocop-0.9.0 lib/rubocop/cop/style/class_and_module_camel_case.rb