From 9c88fef8b3db7cf8f7fc86194071e6a84751c296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Sun, 13 Mar 2016 19:25:41 +0100 Subject: [PATCH] Favor raise to fail. Policy seems to have changed recently https://github.com/bbatsov/rubocop/issues/2732#issuecomment-176416811 --- lib/melt/dsl.rb | 8 ++++---- lib/melt/formatters/base.rb | 4 ++-- lib/melt/formatters/pf.rb | 2 +- lib/melt/resolver.rb | 2 +- lib/melt/rule.rb | 2 +- lib/melt/rule_factory.rb | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/melt/dsl.rb b/lib/melt/dsl.rb index 180795a..4e04e50 100644 --- a/lib/melt/dsl.rb +++ b/lib/melt/dsl.rb @@ -73,7 +73,7 @@ def ruleset_for(hostname) # @param hostname [String] # @return [Symbol] def policy_for(hostname) - fail "Policy for #{hostname} unknown" unless @saved_policies[hostname] + raise "Policy for #{hostname} unknown" unless @saved_policies[hostname] @saved_policies[hostname] end @@ -153,7 +153,7 @@ def service(name, &block) if block_given? @services[name] = block else - fail "Undefined service \"#{name}\"" unless @services[name] + raise "Undefined service \"#{name}\"" unless @services[name] @services[name].call end end @@ -184,10 +184,10 @@ def bloc_for(hostname) def block_matching(hostname) found = nil @hosts.select { |host, _block| host.is_a?(Regexp) }.each do |_host, block| - fail "Multiple host definition match \"#{hostname}\"" if found + raise "Multiple host definition match \"#{hostname}\"" if found found = block end - fail "No host definition match \"#{hostname}\"" unless found + raise "No host definition match \"#{hostname}\"" unless found found end diff --git a/lib/melt/formatters/base.rb b/lib/melt/formatters/base.rb index 1dd3290..2215b18 100644 --- a/lib/melt/formatters/base.rb +++ b/lib/melt/formatters/base.rb @@ -19,7 +19,7 @@ def emit_ruleset(rules, _policy = nil) # # @return [Array] def filename_fragment - fail 'Formatters#filename_fragment MUST be overriden' + raise 'Formatters#filename_fragment MUST be overriden' end protected @@ -33,7 +33,7 @@ def loopback_address(address_family) when :inet then loopback_ipv4 when :inet6 then loopback_ipv6 when nil then nil - else fail "Unsupported address family #{address_family.inspect}" + else raise "Unsupported address family #{address_family.inspect}" end end diff --git a/lib/melt/formatters/pf.rb b/lib/melt/formatters/pf.rb index b39c0a3..2721fe4 100644 --- a/lib/melt/formatters/pf.rb +++ b/lib/melt/formatters/pf.rb @@ -109,7 +109,7 @@ def emit_rdr_to(rule) if rule.rdr? keyword = @loopback_addresses.include?(rule.rdr_to_host) ? 'divert-to' : 'rdr-to' destination = rule.rdr_to_host || loopback_address(rule.af) - fail 'Unspecified address family' if destination.nil? + raise 'Unspecified address family' if destination.nil? emit_endpoint_specification(keyword, destination, rule.rdr_to_port) end end diff --git a/lib/melt/resolver.rb b/lib/melt/resolver.rb index 7ed5b20..10139c9 100644 --- a/lib/melt/resolver.rb +++ b/lib/melt/resolver.rb @@ -45,7 +45,7 @@ def resolv_hostname(hostname, address_family) result = [] result += resolv_hostname_ipv6(hostname) if address_family.nil? || address_family == :inet6 result += resolv_hostname_ipv4(hostname) if address_family.nil? || address_family == :inet - fail "\"#{hostname}\" does not resolve to any valid IP#{@af_str[address_family]} address." if result.empty? + raise "\"#{hostname}\" does not resolve to any valid IP#{@af_str[address_family]} address." if result.empty? result end diff --git a/lib/melt/rule.rb b/lib/melt/rule.rb index b44fcc0..a84fd9d 100644 --- a/lib/melt/rule.rb +++ b/lib/melt/rule.rb @@ -59,7 +59,7 @@ def initialize(options = {}) send("#{k}=", v) end - fail 'if src_port or dst_port is specified, the protocol must also be given' if (src_port || dst_port) && proto.nil? + raise 'if src_port or dst_port is specified, the protocol must also be given' if (src_port || dst_port) && proto.nil? end # Instanciate a forward Melt::Rule. diff --git a/lib/melt/rule_factory.rb b/lib/melt/rule_factory.rb index 4ff4672..7ad84c0 100644 --- a/lib/melt/rule_factory.rb +++ b/lib/melt/rule_factory.rb @@ -9,7 +9,7 @@ def initialize # Limit the scope of a set of rules to IPv4 only. def ipv4 - fail 'Address familly already scopped' if @af + raise 'Address familly already scopped' if @af @af = :inet yield @af = nil @@ -17,7 +17,7 @@ def ipv4 # Limit the scope of a set of rules to IPv6 only. def ipv6 - fail 'Address familly already scopped' if @af + raise 'Address familly already scopped' if @af @af = :inet6 yield @af = nil @@ -112,7 +112,7 @@ def port_loockup(port) if port.is_a?(Fixnum) || port =~ /^\d+:\d+$/ port else - fail "unknown service \"#{port}\"" unless @services[port] + raise "unknown service \"#{port}\"" unless @services[port] @services[port] end end