Showing 18 of 18 total issues
File deduplicator.py
has 493 lines of code (exceeds 250 allowed). Consider refactoring. Open
import datetime
import filecmp
import logging
import os
import shutil
Function _sort_by_quality_descending
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def _sort_by_quality_descending(duplicate_candidates) -> []:
"""
Sorts images according to the desired priorities.
The first item in the list will be the most preferred one of all found duplicates.
- 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
File config.py
has 271 lines of code (exceeds 250 allowed). Consider refactoring. Open
import os
from datetime import timedelta
from container_app_conf import ConfigBase
from container_app_conf.entry.bool import BoolConfigEntry
Function __walk_directory_files
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def __walk_directory_files(self, root_directory: Path, command, threads: int):
"""
Walks through the files of the given directory
:param root_directory: the directory to start with
:param command: the method to execute for every file found
- 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 _move_files
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def _move_files(self, files_to_move: List[Path], target_dir: Path, dry_run: bool):
"""
Moves files on disk
:param files_to_move: list of absolute file paths
:param target_dir: directory to move files to
- 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 _find_empty_folders
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def _find_empty_folders(self, root_path: Path, recursive: bool, dry_run: bool) -> [str]:
"""
Finds empty folders within the given root_path
:param root_path: folder to search in
"""
- 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 __init__
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self,
host: str,
port: int,
el_index: str,
el_version: int = 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_files_count
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_files_count(directory: Path, recursive: bool, file_extensions: List[str] or None, exclusions: List) -> int:
"""
:param directory: the directory to analyze
:param recursive: whether to search the directory recursively
:param file_extensions: file extensions to include
- 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 _normalize_meta_data_for_db
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _normalize_meta_data_for_db(self, dictionary: dict) -> dict:
"""
:param dictionary:
:return:
"""
- 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 find_duplicates_of_file
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def find_duplicates_of_file(self, root_directories: List[Path], root_directory: Path, reference_file_path: Path):
"""
Finds duplicates and marks all but the best copy as "to-be-deleted".
:param root_directories: valid root directories
:param root_directory: root directory of reference_file_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
Function cleanup_database
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def cleanup_database(self, directories: List[Path]):
"""
Removes database entries of files that don't exist on disk.
Note that this cleanup will only consider files within one
of the root directories specified in constructor, as other file paths
- 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 __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self,
Function _select_images_to_delete
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _select_images_to_delete(self, duplicate_candidates: [{}]) -> tuple:
"""
Selects which image to keep and wich to remove
:return: tuple (image to keep, list of images to remove)
"""
- 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 _delete_files
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _delete_files(self, files_to_delete: [str], dry_run: bool):
"""
Deletes files on disk
:param files_to_delete: list of absolute file paths
:param dry_run: set to true to simulate this action
- 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 print_to_console
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def print_to_console(self):
title = "" * 7 + "Summary"
echo(title, color='cyan')
echo('=' * 21, color='cyan')
echo(f"Files with duplicates: {self.get_duplicate_count()}")
- 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 inc
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def inc(self, n: int = 1):
if self._task is None:
raise AssertionError(
"Cant increase before start. "
"Please start a new task progress using start() before incrementing it.")
- 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 add
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add(self, image_file_path: str):
"""
Analyze an image file and add it to the store
:param image_file_path: path to the image file
- 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 _setup_database
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _setup_database(self):
"""
Creates the expected index, if it does not exist
"""
response = requests.get('http://{}:{}/{}'.format(self.host, self.port, self._el_index))
- 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"