Sha256: 7f2182f981bbf7bf144db5a93fdd333e58b2a0d3aaadd2d1b2d1b094dd251e26

Contents?: true

Size: 526 Bytes

Versions: 3

Compression:

Stored size: 526 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # This cop checks for *when;* uses in *case* expressions.
      class WhenThen < Cop
        MSG = 'Never use "when x;". Use "when x then" instead.'

        def on_when(node)
          convention(node, :begin) if node.loc.begin && node.loc.begin.is?(';')
        end

        def autocorrect(node)
          @corrections << lambda do |corrector|
            corrector.replace(node.loc.begin, ' then')
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-0.15.0 lib/rubocop/cop/style/when_then.rb
rubocop-0.14.1 lib/rubocop/cop/style/when_then.rb
rubocop-0.14.0 lib/rubocop/cop/style/when_then.rb