idlesign/torrentool

View on GitHub

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).

Severity: Minor
Found in torrentool/bencode.py - About 5 hrs to fix

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': {}}
Severity: Minor
Found in torrentool/torrent.py - About 4 hrs to fix

    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
    Severity: Minor
    Found in torrentool/torrent.py - About 3 hrs to fix

      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:
      
      
      Severity: Minor
      Found in torrentool/torrent.py - About 2 hrs to fix

      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).
      
      
      Severity: Minor
      Found in torrentool/bencode.py - About 2 hrs to fix

      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:
      Severity: Minor
      Found in torrentool/torrent.py - About 2 hrs to fix

      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):
      Severity: Minor
      Found in torrentool/torrent.py - About 2 hrs to fix

      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'
      Severity: Minor
      Found in torrentool/cli.py - About 55 mins to fix

      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)
      Severity: Major
      Found in torrentool/torrent.py - About 45 mins to fix

        Function create has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def create(source, dest, tracker, open_trackers, comment, cache):
        Severity: Minor
        Found in torrentool/cli.py - About 45 mins to fix

          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 = []
          Severity: Minor
          Found in torrentool/torrent.py - About 35 mins to fix

          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

          Severity
          Category
          Status
          Source
          Language