Fix W504 and remove exclusion

This is a topic where there are two points of view. While neither
is fundamentally better than the other in reality, what's best is
to not have any arguments about it. The tox.ini comments about 503
and 504 that were in place make the argument that:

  - 503 is intended to be disabled and 504 enabled by default
  - Donald Knuth believes 504 is the right way

Since Donald Knuth is smarter than all of us, align with 504, match
the comments in the file and turn on enforcement to keep it that way.

Change-Id: I92d4d1e82935e30ae42a0e14e641cbe36fd6e811
This commit is contained in:
Monty Taylor
2020-02-27 09:21:21 -06:00
parent 72ba76f156
commit 92d7d7caeb
13 changed files with 96 additions and 54 deletions

View File

@@ -223,9 +223,13 @@ def _ports_match(protocol, module_min, module_max, rule_min, rule_max):
module_min = None
module_max = None
if ((module_min is None and module_max is None) and
(rule_min and int(rule_min) == 1 and
rule_max and int(rule_max) == 65535)):
if (
(module_min is None and module_max is None)
and (
rule_min and int(rule_min) == 1
and rule_max and int(rule_max) == 65535
)
):
# (None, None) == (1, 65535)
return True
@@ -254,16 +258,19 @@ def _find_matching_rule(module, secgroup, remotegroup):
remote_group_id = remotegroup['id']
for rule in secgroup['security_group_rules']:
if (protocol == rule['protocol'] and
remote_ip_prefix == rule['remote_ip_prefix'] and
ethertype == rule['ethertype'] and
direction == rule['direction'] and
remote_group_id == rule['remote_group_id'] and
_ports_match(protocol,
module.params['port_range_min'],
module.params['port_range_max'],
rule['port_range_min'],
rule['port_range_max'])):
if (
protocol == rule['protocol']
and remote_ip_prefix == rule['remote_ip_prefix']
and ethertype == rule['ethertype']
and direction == rule['direction']
and remote_group_id == rule['remote_group_id']
and _ports_match(
protocol,
module.params['port_range_min'],
module.params['port_range_max'],
rule['port_range_min'],
rule['port_range_max'])
):
return rule
return None