fuzeman/trakt.py

View on GitHub

Showing 118 of 249 total issues

Function refresh_autodoc_index has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

def refresh_autodoc_index():
    def find_autodoc_modules(module_name, sourcedir):
        """Return a list of modules in the SOURCE directory."""
        result = []

Severity: Minor
Found in docs/conf.py - About 7 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

File scrobble.py has 311 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from trakt.core.helpers import dictfilter
from trakt.interfaces.base import Interface, authenticated, application


class ScrobbleInterface(Interface):
Severity: Minor
Found in trakt/interfaces/scrobble.py - About 3 hrs to fix

    Function _update has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def _update(self, info=None, **kwargs):
            if not info:
                return
    
            super(Progress, self)._update(info, **kwargs)
    Severity: Minor
    Found in trakt/objects/progress.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 send has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def send(self, request):
            # Retrieve http configuration
            retry = self.client.configuration.get('http.retry', DEFAULT_HTTP_RETRY)
            max_retries = self.client.configuration.get('http.max_retries', DEFAULT_HTTP_MAX_RETRIES)
            retry_sleep = self.client.configuration.get('http.retry_sleep', DEFAULT_HTTP_RETRY_SLEEP)
    Severity: Minor
    Found in trakt/core/http.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 map_item has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def map_item(cls, client, store, item, media, key=None, parent=None, append=False, **kwargs):
            if item and media in item:
                i_data = item[media]
            else:
                i_data = item
    Severity: Minor
    Found in trakt/mapper/sync.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_data has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_data(self, response, exceptions=False, parse=True):
            if response is None:
                if exceptions:
                    raise RequestFailedError('No response available')
    
    
    Severity: Minor
    Found in trakt/interfaces/base/__init__.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 iterate_items has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def iterate_items(cls, client, store, items, func, media=None, **kwargs):
            if store is None:
                store = {}
    
            if 'movies' not in store:
    Severity: Minor
    Found in trakt/mapper/sync.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 to_dict has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_dict(self):
            """Dump movie to a dictionary.
    
            :return: Movie dictionary
            :rtype: :class:`~python:dict`
    Severity: Minor
    Found in trakt/objects/movie.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 to_dict has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_dict(self):
            """Dump show to a dictionary.
    
            :return: Show dictionary
            :rtype: :class:`~python:dict`
    Severity: Minor
    Found in trakt/objects/show.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 has 16 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def get(self, source, media, collection=None, start_date=None, days=None, query=None, years=None, genres=None,
    Severity: Major
    Found in trakt/interfaces/calendars.py - About 2 hrs to fix

      Function __getitem__ has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def __getitem__(self, path):
              parts = path.strip('/').split('/')
      
              cur = self.__interfaces
              parameters = []
      Severity: Minor
      Found in trakt/client.py - About 1 hr 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 _format_apis has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def _format_apis(apis):
      
          output = []
      
          def make_path(path_dict, api_path):
      Severity: Minor
      Found in trakt/sphinxext.py - About 1 hr 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 __init__ has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(self, client, keys, index=None):
              super(Show, self).__init__(client, keys, index)
      
              self.title = None
              """
      Severity: Minor
      Found in trakt/objects/show.py - About 1 hr to fix

        Function construct has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def construct(cls, client, media, item, keys=None, **kwargs):
                if keys is None:
                    _, keys = cls.get_ids(media, item)
        
                if media == 'movie':
        Severity: Minor
        Found in trakt/mapper/core/base.py - About 1 hr 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 dictfilter has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def dictfilter(d, **kwargs):
            result = {}
        
            if 'get' in kwargs:
                for key in kwargs['get']:
        Severity: Minor
        Found in trakt/core/helpers.py - About 1 hr 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 _send has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _send(self, request):
                response = self.client.http.send(request)
        
                if response is None:
                    if self.exceptions:
        Severity: Minor
        Found in trakt/core/pagination.py - About 1 hr 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 has 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def get(self, username, media=None, id=None, start_at=None, end_at=None, store=None,
        Severity: Major
        Found in trakt/interfaces/users/history.py - About 1 hr to fix

          Function request has 10 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def request(self, method, path=None, params=None, data=None, query=None, authenticated=False,
          Severity: Major
          Found in trakt/core/http.py - About 1 hr to fix

            Function get_ids has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_ids(media, item, parent=None):
                    if not item:
                        return None, []
            
                    ids = item.get('ids', {})
            Severity: Minor
            Found in trakt/mapper/core/base.py - About 1 hr 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 to_dict has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def to_dict(self):
                    """Dump episode to a dictionary.
            
                    :return: Episode dictionary
                    :rtype: :class:`~python:dict`
            Severity: Minor
            Found in trakt/objects/episode.py - About 1 hr 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