Showing 11 of 11 total issues
Function decode
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def decode(cls, encoded: bytes, *, byte_keys: Set[str] = None) -> TypeEncodable:
"""Decodes bencoded data introduced as bytes.
Returns decoded structure(s).
- 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
Torrent
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
class Torrent:
"""Represents a torrent file, and exposes utilities to work with it."""
def __init__(self, dict_struct: dict = None):
dict_struct: dict = dict_struct or {'info': {}}
File torrent.py
has 318 lines of code (exceeds 250 allowed). Consider refactoring. Open
from calendar import timegm
from datetime import datetime
from functools import reduce
from hashlib import sha1
from os import walk, sep
Function create_from
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def create_from(cls, src_path: Union[str, Path]) -> 'Torrent':
"""Returns Torrent object created from a file or a directory.
:param src_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 encode
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def encode(cls, value: TypeEncodable) -> bytes:
"""Encodes a value into bencoded bytes.
:param value: Python object to be encoded (str, int, list, dict).
- 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_magnet
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def get_magnet(self, detailed: Union[bool, list, tuple, set] = True) -> str:
"""Returns torrent magnet link, consisting of BTIH (BitTorrent Info Hash) URN
anr optional other information.
:param detailed:
- 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 announce_urls
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def announce_urls(self, val: List[str]):
self._struct['announce'] = ''
self._struct['announce-list'] = []
def set_single(val):
- 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 create
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create(source, dest, tracker, open_trackers, comment, cache):
"""Create torrent file from a single file or a directory."""
source_title = path.basename(source).replace('.', '_').replace(' ', '_')
dest = f'{path.join(dest, source_title)}.torrent'
- 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 not isinstance(item, _ITERABLE_TYPES):
item = [item]
self._struct['announce-list'].append(item)
Function create
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def create(source, dest, tracker, open_trackers, comment, cache):
Function _get_target_files_info
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _get_target_files_info(cls, src_path: Path) -> Tuple[List[Tuple[str, int, List[str]]], int]:
is_dir = src_path.is_dir()
src_path = f'{src_path}' # Force walk() to return unicode names.
target_files = []
- 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"