You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When checking for class / module context, detect class_eval, module_eval, class_exec, module_exec. The class_* variants are aliases of the module_* variants. It should however be safe to assume class_* would be called on a class and module_* would be called on a module.
I don't think it is worth looking at class_eval or module_eval when given a string argument. Just interested in when any of these are given a block.
Given there are multiple cops that need to check for the first class / module context, I think it would be useful to create a mixin module to help with the search. Something like
moduleRuboCopmoduleCopmoduleThreadSafetymoduleMixinmoduleClassModuleContext# return first class or module context in node's ancestorsdeffind_context(node)# return first node that is a class, module, class_eval, module_eval or similarenddefclass_context?(node)# return true if node is a class contextenddefmodule_context?(node)# return true if node is a module contextendendendendendend
The text was updated successfully, but these errors were encountered:
When checking for class / module context, detect
class_eval
,module_eval
,class_exec
,module_exec
. Theclass_*
variants are aliases of themodule_*
variants. It should however be safe to assumeclass_*
would be called on a class andmodule_*
would be called on a module.I don't think it is worth looking at
class_eval
ormodule_eval
when given a string argument. Just interested in when any of these are given a block.A reduced example that inspired this thought:
Given there are multiple cops that need to check for the first class / module context, I think it would be useful to create a mixin module to help with the search. Something like
The text was updated successfully, but these errors were encountered: