Sha256: ea7ea4d8987ce6e601f42c1d9be728d1422921d54f78ef46176525e2a462b525
Contents?: true
Size: 920 Bytes
Versions: 6791
Compression:
Stored size: 920 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for if and unless statements used as modifiers of other if or # unless statements. # # @example # # # bad # tired? ? 'stop' : 'go faster' if running? # # # bad # if tired? # "please stop" # else # "keep going" # end if running? # # # good # if running? # tired? ? 'stop' : 'go faster' # end class IfUnlessModifierOfIfUnless < Cop include StatementModifier MSG = 'Avoid modifier `%<keyword>s` after another conditional.'.freeze def on_if(node) return unless node.modifier_form? && node.body.if_type? add_offense(node, location: :keyword, message: format(MSG, keyword: node.keyword)) end end end end end
Version data entries
6,791 entries across 6,785 versions & 25 rubygems