lib/rubocop/cop/style/case_indentation.rb in rubocop-0.26.1 vs lib/rubocop/cop/style/case_indentation.rb in rubocop-0.27.0

- old
+ new

@@ -25,26 +25,34 @@ private def check_when(when_node, case_node, base, indent, base_column) pos = when_node.loc.keyword expected_column = base_column + - (indent ? IndentationWidth::CORRECT_INDENTATION : 0) + (indent ? configured_indentation_width : 0) if pos.column == expected_column correct_style_detected else - msg = 'Indent `when` ' + if indent - "one step more than `#{base}`." - else - "as deep as `#{base}`." - end - add_offense(when_node, pos, msg) do - if pos.column == base_column(case_node, alternative_style) - opposite_style_detected - else - unrecognized_style_detected - end + incorrect_style(when_node, case_node, base, pos, indent) + end + end + + def incorrect_style(when_node, case_node, base, pos, indent) + msg = 'Indent `when` ' + if indent + "one step more than `#{base}`." + else + "as deep as `#{base}`." + end + add_offense(when_node, pos, msg) do + if pos.column == base_column(case_node, alternative_style) + opposite_style_detected + else + unrecognized_style_detected end end + end + + def configured_indentation_width + config.for_cop('IndentationWidth')['Width'] end def parameter_name 'IndentWhenRelativeTo' end