Sha256: 8c2dc51b460e790b344793a8db7e03077b41bba1fe718e1cdd5ae4d0e7e5ed2a
Contents?: true
Size: 676 Bytes
Versions: 16
Compression:
Stored size: 676 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop # This class does condition auto-correction class ConditionCorrector class << self def correct_negative_condition(node) condition = negated_condition(node) lambda do |corrector| corrector.replace(node.loc.keyword, node.inverse_keyword) corrector.replace(condition, condition.children.first.source) end end private def negated_condition(node) condition = node.condition condition = condition.children.first while condition.begin_type? condition end end end end end
Version data entries
16 entries across 16 versions & 3 rubygems