Fixes multiple lgtm issues (#45629)

Most of the issues were just inclusions of code that were not used.
This cleans those up. Other alerts were semi-false-positives for now
This commit is contained in:
Tim Rupp 2018-09-13 15:26:17 -04:00 committed by GitHub
commit e619052424
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 255 additions and 239 deletions

View file

@ -385,41 +385,33 @@ class Difference(object):
@property
def untagged_interfaces(self):
result = []
if self.want.untagged_interfaces is None:
return None
elif self.want.untagged_interfaces == '' and self.have.untagged_interfaces is None:
return None
elif self.want.untagged_interfaces == '' and len(self.have.untagged_interfaces) > 0:
pass
elif not self.have.untagged_interfaces:
result = dict(
interfaces=[dict(name=x, untagged=True) for x in self.want.untagged_interfaces]
)
elif set(self.want.untagged_interfaces) != set(self.have.untagged_interfaces):
result = dict(
interfaces=[dict(name=x, untagged=True) for x in self.want.untagged_interfaces]
)
else:
return None
result = self.cmp_interfaces(self.want.untagged_interfaces, self.have.untagged_interfaces, False)
return result
@property
def tagged_interfaces(self):
result = self.cmp_interfaces(self.want.tagged_interfaces, self.have.tagged_interfaces, True)
return result
def cmp_interfaces(self, want, have, tagged):
result = []
if self.want.tagged_interfaces is None:
if tagged:
tag_key = 'tagged'
else:
tag_key = 'untagged'
if want is None:
return None
elif self.want.tagged_interfaces == '' and self.have.tagged_interfaces is None:
elif want == '' and have is None:
return None
elif self.want.tagged_interfaces == '' and len(self.have.tagged_interfaces) > 0:
elif want == '' and len(have) > 0:
pass
elif not self.have.tagged_interfaces:
elif not have:
result = dict(
interfaces=[dict(name=x, tagged=True) for x in self.want.tagged_interfaces]
interfaces=[{'name': x, tag_key: True} for x in want]
)
elif set(self.want.tagged_interfaces) != set(self.have.tagged_interfaces):
elif set(want) != set(have):
result = dict(
interfaces=[dict(name=x, tagged=True) for x in self.want.tagged_interfaces]
interfaces=[{'name': x, tag_key: True} for x in want]
)
else:
return None