Class: RuboCop::Cop::Custom::IpRanges

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/custom/ip_ranges.rb

Overview

:nodoc:

Constant Summary collapse

MSG =
'Outdated list of IP ranges compared to %<url>s'
REGEXP =
/^\s*#\s*@fetch:(?<param>[a-z0-9_]+)\s+(?<arg>.*)?/

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rubocop/cop/custom/ip_ranges.rb', line 23

def on_send(node)
  on_ip_ranges(node) do |value|
    params = fetch_params(node)
    return unless mandatory_params?(params)

    existing_ips = normalise_list(read_node_ips(value))
    new_ips = normalise_list(fetch_ips(**params))
    return unless new_ips
    return if existing_ips == new_ips

    register_offense(value, new_ips, **params)
  end
end