Sha256: 06d71992327b3b3ad7481b04119995b970ca1db2a507637a638826b6344b76d1
Contents?: true
Size: 828 Bytes
Versions: 8
Compression:
Stored size: 828 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop module Discourse module Plugins # Methods must be defined inside the plugin namespace (module or class). # # @example # # bad # def my_method # end # # # good # module MyPlugin # def my_method # end # end # class NamespaceMethods < Base MSG = "Don’t define methods outside a class or a module." def on_def(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