Sha256: 06e473d27f1080420feaae2c89eef1982d902e6216251d5ff0cdbd3a0f5970c4
Contents?: true
Size: 1.03 KB
Versions: 9
Compression:
Stored size: 1.03 KB
Contents
# encoding: utf-8 module RuboCop module Cop module Style # Checks for uses of the `then` keyword in multi-line if statements. # # @example This is considered bad practice: # # if cond then # end # # @example If statements can contain `then` on the same line: # # if cond then a # elsif cond then b # end class MultilineIfThen < Cop include IfNode include OnNormalIfUnless def on_normal_if_unless(node) return unless node.loc.begin return unless node.loc.begin.source_line =~ /then\s*(#.*)?$/ add_offense(node, :begin) end def message(node) "Do not use `then` for multi-line `#{node.loc.keyword.source}`." end def autocorrect(node) lambda do |corrector| corrector.remove(range_with_surrounding_space(node.loc.begin, :left)) end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems