Sha256: 365e1d70283011fd71c0f8be62091cfd620da7d92a863fc9d9bf7ab484d1631d
Contents?: true
Size: 816 Bytes
Versions: 8
Compression:
Stored size: 816 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop module Discourse module Plugins # Constants must be defined inside the plugin namespace (module or class). # # @example # # bad # MY_CONSTANT = :value # # # good # module MyPlugin # MY_CONSTANT = :value # end # class NamespaceConstants < Base MSG = "Don’t define constants outside a class or a module." def on_casgn(node) return if inside_namespace?(node) add_offense(node, message: MSG) end private def inside_namespace?(node) node.each_ancestor.detect { _1.class_type? || _1.module_type? } end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems