Skip to content

Commit

Permalink
refactor: flatter structure
Browse files Browse the repository at this point in the history
Use guard clause and any to reduce nesting / indentation.
  • Loading branch information
b-kamphorst committed May 11, 2023
1 parent 0ede84d commit 880fcc9
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions bandit/core/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,24 +401,15 @@ def _is_file_included(
:param enforce_glob: Can set to false to bypass extension check
:return: Boolean indicating whether a file should be included
"""
return_value = False

# if this is matches a glob of files we look at, and it isn't in an
# excluded path
if _matches_glob_list(path, included_globs) or not enforce_glob:
if not _matches_glob_list(path, excluded_path_strings) and not any(
x in path for x in excluded_path_strings
):
return_value = True

return return_value
if enforce_glob and not _matches_glob_list(path, included_globs):
return False
return not _matches_glob_list(path, excluded_path_strings) and not any(
x in path for x in excluded_path_strings
)


def _matches_glob_list(filename, glob_list):
for glob in glob_list:
if fnmatch.fnmatch(filename, glob):
return True
return False
return any(fnmatch.fnmatch(filename, glob) for glob in glob_list)


def _compare_baseline_results(baseline, results):
Expand Down

0 comments on commit 880fcc9

Please sign in to comment.