Class: RuboCop::Cop::HashTransformMethod::Captures
- Inherits:
-
Struct
- Object
- Struct
- RuboCop::Cop::HashTransformMethod::Captures
- Defined in:
- lib/rubocop/cop/mixin/hash_transform_method.rb
Overview
Internal helper class to hold match data
Instance Attribute Summary collapse
-
#transformed_argname ⇒ Object
Returns the value of attribute transformed_argname.
-
#transforming_body_expr ⇒ Object
Returns the value of attribute transforming_body_expr.
-
#unchanged_body_expr ⇒ Object
Returns the value of attribute unchanged_body_expr.
Instance Method Summary collapse
- #noop_transformation? ⇒ Boolean
- #transformation_uses_both_args? ⇒ Boolean
- #use_transformed_argname? ⇒ Boolean
Instance Attribute Details
permalink #transformed_argname ⇒ Object
Returns the value of attribute transformed_argname
13 14 15 |
# File 'lib/rubocop/cop/mixin/hash_transform_method.rb', line 13 def transformed_argname @transformed_argname end |
permalink #transforming_body_expr ⇒ Object
Returns the value of attribute transforming_body_expr
13 14 15 |
# File 'lib/rubocop/cop/mixin/hash_transform_method.rb', line 13 def transforming_body_expr @transforming_body_expr end |
permalink #unchanged_body_expr ⇒ Object
Returns the value of attribute unchanged_body_expr
13 14 15 |
# File 'lib/rubocop/cop/mixin/hash_transform_method.rb', line 13 def unchanged_body_expr @unchanged_body_expr end |
Instance Method Details
permalink #noop_transformation? ⇒ Boolean
14 15 16 17 |
# File 'lib/rubocop/cop/mixin/hash_transform_method.rb', line 14 def noop_transformation? transforming_body_expr.lvar_type? && transforming_body_expr.children == [transformed_argname] end |
permalink #transformation_uses_both_args? ⇒ Boolean
19 20 21 |
# File 'lib/rubocop/cop/mixin/hash_transform_method.rb', line 19 def transformation_uses_both_args? transforming_body_expr.descendants.include?(unchanged_body_expr) end |
permalink #use_transformed_argname? ⇒ Boolean
23 24 25 26 27 |
# File 'lib/rubocop/cop/mixin/hash_transform_method.rb', line 23 def use_transformed_argname? transforming_body_expr.each_descendant(:lvar).any? do |node| node.source == transformed_argname.to_s end end |