Sha256: 3ca80ac9f08bec5929ddad7dd75a570514874b8ce7650433c6d940530d15b033
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Solidus # Solidus suggests a decorator module instead of `class_eval` when overriding some features. # This cop finds any `class_eval` and asks to use a decorator module instead. # More info: https://guides.solidus.io/customization/customizing-the-core. # # @example # # # bad # SpreeClass.class_eval do # # your code here # end # # # good # module Spree # module SpreeClassDecorator # # your code here # end # # Spree::SpreeClass.prepend self # end # class ClassEvalDecorator < Base MSG = 'Do not use `class_eval` flag. Use a decorator module instead. More info: https://guides.solidus.io/customization/customizing-the-core.' RESTRICT_ON_SEND = %i[class_eval].freeze def_node_matcher :on_class_eval?, <<~PATTERN (send ($...) :class_eval) PATTERN def on_send(node) return unless on_class_eval?(node) add_offense(node) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-solidus-0.2.0 | lib/rubocop/cop/solidus/class_eval_decorator.rb |
rubocop-solidus-0.1.4 | lib/rubocop/cop/solidus/class_eval_decorator.rb |