Sha256: b9a1c89cb08d0f2ed2e75650499c9ded7f12cf6d552f97848b82a6f848ffdf7f
Contents?: true
Size: 697 Bytes
Versions: 16
Compression:
Stored size: 697 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop class AmpersandsPipesVsAndOr < Cop ERROR_MESSAGE = 'Use &&/|| for boolean expressions, and/or for control flow.' def inspect(file, source, tokens, sexp) [:if, :unless, :while, :until].each { |keyword| check(keyword, sexp) } end def check(keyword, sexp) each(keyword, sexp) do |sub_sexp| condition = sub_sexp[1] if condition[0] == :binary && [:and, :or].include?(condition[2]) add_offence(:convention, sub_sexp.flatten.grep(Position).first.lineno, ERROR_MESSAGE) end end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems