[SOLVED] How to deal with "Move `% s` out of conditional." error from Rubocop.
Problem:
Move `% s` out of the Conditional.
where %s is a Method
As the method call pointed out at %s is redundant, Rubocop throws this as Error. The method that is common under both condition should be moved outside the Conditions as it would be executed in either of case.
Solution:
@bad Code
if condition
do_x
do_z
else
do_y
do_z
end
@good Code
if condition
do_x
else
do_y
end
do_z
This post first appeared on G33K-TRICKS - Your Source To Tips And Tricks, please read the originial post: here