Skip to content

Commit 880fcc9

Browse files
committed
refactor: flatter structure
Use guard clause and any to reduce nesting / indentation.
1 parent 0ede84d commit 880fcc9

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

bandit/core/manager.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -401,24 +401,15 @@ def _is_file_included(
401401
:param enforce_glob: Can set to false to bypass extension check
402402
:return: Boolean indicating whether a file should be included
403403
"""
404-
return_value = False
405-
406-
# if this is matches a glob of files we look at, and it isn't in an
407-
# excluded path
408-
if _matches_glob_list(path, included_globs) or not enforce_glob:
409-
if not _matches_glob_list(path, excluded_path_strings) and not any(
410-
x in path for x in excluded_path_strings
411-
):
412-
return_value = True
413-
414-
return return_value
404+
if enforce_glob and not _matches_glob_list(path, included_globs):
405+
return False
406+
return not _matches_glob_list(path, excluded_path_strings) and not any(
407+
x in path for x in excluded_path_strings
408+
)
415409

416410

417411
def _matches_glob_list(filename, glob_list):
418-
for glob in glob_list:
419-
if fnmatch.fnmatch(filename, glob):
420-
return True
421-
return False
412+
return any(fnmatch.fnmatch(filename, glob) for glob in glob_list)
422413

423414

424415
def _compare_baseline_results(baseline, results):

0 commit comments

Comments
 (0)