Sha256: e2581750c716a742f07ea256d9d861754b5c6391e39c4a5dafecc5fcd913c4a3

Contents?: true

Size: 580 Bytes

Versions: 4

Compression:

Stored size: 580 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)
        end

        def on_module(node)
          check_name(node)
        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

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.12.0 lib/rubocop/cop/style/class_and_module_camel_case.rb
rubocop-0.11.1 lib/rubocop/cop/style/class_and_module_camel_case.rb
rubocop-0.11.0 lib/rubocop/cop/style/class_and_module_camel_case.rb
rubocop-0.10.0 lib/rubocop/cop/style/class_and_module_camel_case.rb