lib/rubocop/cop/lint/useless_assignment.rb in rubocop-1.12.1 vs lib/rubocop/cop/lint/useless_assignment.rb in rubocop-1.13.0

- old
+ new

@@ -36,13 +36,11 @@ def self.joining_forces VariableForce end def after_leaving_scope(scope, _variable_table) - scope.variables.each_value do |variable| - check_for_unused_assignments(variable) - end + scope.variables.each_value { |variable| check_for_unused_assignments(variable) } end def check_for_unused_assignments(variable) return if variable.should_be_unused? @@ -62,12 +60,11 @@ end def message_for_useless_assignment(assignment) variable = assignment.variable - format(MSG, variable: variable.name) + - message_specification(assignment, variable).to_s + format(MSG, variable: variable.name) + message_specification(assignment, variable).to_s end def message_specification(assignment, variable) if assignment.multiple_assignment? multiple_assignment_message(variable.name) @@ -83,20 +80,18 @@ "that it won't be used." end def operator_assignment_message(scope, assignment) return_value_node = return_value_node_of_scope(scope) - return unless assignment.meta_assignment_node - .equal?(return_value_node) + return unless assignment.meta_assignment_node.equal?(return_value_node) " Use `#{assignment.operator.sub(/=$/, '')}` " \ "instead of `#{assignment.operator}`." end def similar_name_message(variable) variable_like_names = collect_variable_like_names(variable.scope) - similar_name = NameSimilarity.find_similar_name(variable.name, - variable_like_names) + similar_name = NameSimilarity.find_similar_name(variable.name, variable_like_names) " Did you mean `#{similar_name}`?" if similar_name end # TODO: More precise handling (rescue, ensure, nested begin, etc.) def return_value_node_of_scope(scope)