class ComplexCases::SmartDeleteCheck

Constants

WHITE_LIST

Public Class Methods

call(who, what, args) click to toggle source
# File lib/ducalis/cops/complex_cases/smart_delete_check.rb, line 7
def self.call(who, what, args)
  !new(who, what, args).false_positive?
end
new(who, _what, args) click to toggle source
# File lib/ducalis/cops/complex_cases/smart_delete_check.rb, line 11
def initialize(who, _what, args)
  @who = who
  @args = args
end

Public Instance Methods

false_positive?() click to toggle source
# File lib/ducalis/cops/complex_cases/smart_delete_check.rb, line 16
def false_positive?
  [
    called_with_stringlike?,
    many_args?,
    whitelisted?
  ].any?
end

Private Instance Methods

called_with_stringlike?() click to toggle source
# File lib/ducalis/cops/complex_cases/smart_delete_check.rb, line 26
def called_with_stringlike?
  %i[sym str].include?(@args.first && @args.first.type)
end
many_args?() click to toggle source
# File lib/ducalis/cops/complex_cases/smart_delete_check.rb, line 30
def many_args?
  @args.count > 1
end
whitelisted?() click to toggle source
# File lib/ducalis/cops/complex_cases/smart_delete_check.rb, line 34
def whitelisted?
  WHITE_LIST.any? { |regex| @who.to_s.include?(regex) }
end