Function walk_and_save
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def walk_and_save(path: str, dir_list_path: str, file_list_path: str, return_dirs_instead_of_regular_files: bool,
extensions: Optional[List[str]]) -> Generator[bytes, None, None]:
with open(dir_list_path, 'w') as d, open(file_list_path, 'w') as f:
path_bin = path.encode()
extensions_bin = list(map(lambda e: e.encode(), extensions)) if extensions else None
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_dir_last_modification
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def get_dir_last_modification(path: str, limit: int = LIMIT_FILES_ON_LAST_MODIFICATION_CHECK) -> datetime:
def walk_path(path):
counter = 0
if os.path.isfile(path) or len(os.listdir(path)) == 0:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function walk
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def walk(path:bytes, extension: Optional[bytes] = None) -> Generator[bytes, None, None]:
if os.path.isfile(path) and (not extension or path.endswith(extension)):
yield path
else:
for root, dirs, files in os.walk(path):
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if return_dirs_instead_of_regular_files:
yield bin_name
for file in files:
Avoid deeply nested control flow statements. Open
if not extensions or has_one_of_extensions(bin_name, extensions_bin):
if not os.path.islink(os.path.join(root, file)):
f.write(f'{bin_name}\n')
if not return_dirs_instead_of_regular_files:
yield bin_name
Function walk_and_save
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def walk_and_save(path: str, dir_list_path: str, file_list_path: str, return_dirs_instead_of_regular_files: bool,