From 162495977b6c1157d934ef3800699d19ce3fa85b Mon Sep 17 00:00:00 2001 From: Manabu Niseki Date: Sun, 5 Apr 2020 19:43:24 +0900 Subject: [PATCH] fix: fix codefactor warnings Fix unnecessary "elif" after "return" warnings --- iocingestor/artifacts.py | 29 +++++++++++++++-------------- iocingestor/extras/webapp.py | 7 +++---- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/iocingestor/artifacts.py b/iocingestor/artifacts.py index 1abf87d..49c3168 100644 --- a/iocingestor/artifacts.py +++ b/iocingestor/artifacts.py @@ -73,12 +73,13 @@ def _match_expression(self, pattern: str): for condition in conditions: if condition.lstrip(NOT) not in URL.__dict__: raise ValueError("not a condition expression") - else: - result = URL.__dict__[condition.lstrip(NOT)](self) - if condition.startswith(NOT) and result: - return False - elif not condition.startswith(NOT) and not result: - return False + + result = URL.__dict__[condition.lstrip(NOT)](self) + if condition.startswith(NOT) and result: + return False + if not condition.startswith(NOT) and not result: + return False + return True def match(self, pattern: str): @@ -246,10 +247,10 @@ def ipaddress(self): version = self.version if version == 4: return ipaddress.IPv4Address(self._stringify()) - elif version == 6: + if version == 6: return ipaddress.IPv6Address(self._stringify()) - else: - raise ValueError("Invalid IP address '{ip}'".format(ip=self.artifact)) + + raise ValueError("Invalid IP address '{ip}'".format(ip=self.artifact)) class Domain(Artifact): @@ -295,14 +296,14 @@ def hash_type(self): """Return the hash type as a string, or None.""" if len(self.artifact) == 32: return self.MD5 - elif len(self.artifact) == 40: + if len(self.artifact) == 40: return self.SHA1 - elif len(self.artifact) == 64: + if len(self.artifact) == 64: return self.SHA256 - elif len(self.artifact) == 128: + if len(self.artifact) == 128: return self.SHA512 - else: - return None + + return None class Task(Artifact): diff --git a/iocingestor/extras/webapp.py b/iocingestor/extras/webapp.py index fe0c52f..01d82c4 100644 --- a/iocingestor/extras/webapp.py +++ b/iocingestor/extras/webapp.py @@ -85,7 +85,7 @@ def list_view(table): if table == "index": return tables - elif table and table in tables: + if table and table in tables: cursor.execute(f"SELECT * FROM {table}") data = [] @@ -95,11 +95,10 @@ def list_view(table): return data - elif table: + if table: return f"No table {table}" - else: - return tables + return tables @hug.get("/{table}", output=hug.output_format.html)