Files
codeql/python/ql/src/Statements/UnnecessaryElseClause.py
2018-11-19 15:10:42 +00:00

22 lines
481 B
Python

def pointless_else(container):
for item in container:
if of_interest(item):
return item
else:
raise NotFoundException()
def no_else(container):
for item in container:
if of_interest(item):
return item
raise NotFoundException()
def with_break(container):
for item in container:
if of_interest(item):
found = item
break
else:
raise NotFoundException()
return found