CastagnaIT/plugin.video.netflix

View on GitHub

Showing 103 of 373 total issues

Function _request has a Cognitive Complexity of 31 (exceeds 10 allowed). Consider refactoring.
Open

    def _request(self, method, endpoint, session_refreshed, **kwargs):
        endpoint_conf = ENDPOINTS[endpoint]
        url = (_api_url(endpoint_conf['address'])
               if endpoint_conf['is_api_call']
               else _document_url(endpoint_conf['address'], kwargs))
Severity: Minor
Found in resources/lib/services/nfsession/session/http_requests.py - About 3 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 auto_scroll has a Cognitive Complexity of 30 (exceeds 10 allowed). Consider refactoring.
Open

def auto_scroll(dir_items):
    """
    Auto scroll the current viewed list to select the last partial watched or next episode to be watched,
    works only with Sync of watched status with netflix
    """
Severity: Minor
Found in resources/lib/navigation/directory_utils.py - About 3 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 onNotification has a Cognitive Complexity of 28 (exceeds 10 allowed). Consider refactoring.
Open

    def onNotification(self, sender, method, data):  # pylint: disable=unused-argument,too-many-branches
        """
        Callback for Kodi notifications that handles and dispatches playback events
        """
        LOG.warn('ActionController: onNotification {} -- {}', method, data)
Severity: Minor
Found in resources/lib/services/playback/action_controller.py - About 3 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

VideoId has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class VideoId:
    """Universal representation of a video id. Video IDs can be of multiple types:
    - supplemental: a single identifier only for supplementalid, all other values must be None
    - movie: a single identifier only for movieid, all other values must be None
    - show: a single identifier only for tvshowid, all other values must be None
Severity: Minor
Found in resources/lib/common/videoid.py - About 3 hrs to fix

    File db_shared.py has 431 lines of code (exceeds 400 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    """
        Copyright (C) 2017 Sebastian Golasch (plugin.video.netflix)
        Copyright (C) 2019 Stefano Gottardo - @CastagnaIT (original implementation module)
        Sharable database access and functions
    Severity: Minor
    Found in resources/lib/database/db_shared.py - About 2 hrs to fix

      Function get_shareddb_class has a Cognitive Complexity of 24 (exceeds 10 allowed). Consider refactoring.
      Open

      def get_shareddb_class(use_mysql=False):
          # Dynamically sets the inherit class
          base_class = db_base_mysql.MySQLDatabase if use_mysql else db_base_sqlite.SQLiteDatabase
      
          class NFSharedDatabase(base_class):
      Severity: Minor
      Found in resources/lib/database/db_shared.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

      CacheManagement has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class CacheManagement:
          """Cache management"""
      
          def __init__(self):
              self._identifier_prefix = None
      Severity: Minor
      Found in resources/lib/services/cache_management.py - About 2 hrs to fix

        Function _init has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring.
        Open

            def _init(self, player_state):  # pylint: disable=too-many-branches
                is_enabled = G.ADDON.getSettingBool('StreamContinuityManager_enabled')  # remember audio/subtitle preferences
                if is_enabled:
                    # Get user saved preferences
                    self.sc_settings = G.SHARED_DB.get_stream_continuity(G.LOCAL_DB.get_active_profile_guid(),
        Severity: Minor
        Found in resources/lib/services/playback/am_stream_continuity.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

        ActionManager has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ActionManager:
            """
            Base class for managers that handle executing of specific actions during playback
            """
        
        
        Severity: Minor
        Found in resources/lib/services/playback/action_manager.py - About 2 hrs to fix

          Function _prepare_authentication_key_data has a Cognitive Complexity of 21 (exceeds 10 allowed). Consider refactoring.
          Open

          def _prepare_authentication_key_data(data):
              """Check type of app used and prepare data for the service"""
              from resources.lib.utils.cookies import convert_chrome_cookie
              if (data['app_name'] == 'NFAuthenticationKey' and
                      data['app_system'] == 'Windows' and
          Severity: Minor
          Found in resources/lib/common/credentials.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 _update_library has a Cognitive Complexity of 21 (exceeds 10 allowed). Consider refactoring.
          Open

              def _update_library(self, videoids_tasks, exp_tvshows_videoids_values, show_prg_dialog, show_nfo_dialog,
                                  clear_on_cancel):
                  # If set ask to user if want to export NFO files (override user custom NFO settings for videoids)
                  nfo_settings_override = None
                  if show_nfo_dialog:
          Severity: Minor
          Found in resources/lib/kodi/library.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

          File am_stream_continuity.py has 401 lines of code (exceeds 400 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          """
              Copyright (C) 2017 Sebastian Golasch (plugin.video.netflix)
              Copyright (C) 2018 Caphm (original implementation module)
              Remember and restore audio stream / subtitle settings between individual episodes of a tv show or movie
          Severity: Minor
          Found in resources/lib/services/playback/am_stream_continuity.py - About 2 hrs to fix

            Function _find_stream_index has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
            Open

                def _find_stream_index(self, streams, stored_stream):
                    """
                    Find the right stream index
                    in the case of episodes, it is possible that between different episodes some languages are
                    not present, so the indexes are changed, then you have to rely on the streams properties
            Severity: Minor
            Found in resources/lib/services/playback/am_stream_continuity.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_id_default_audio_tracks has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
            Open

            def _get_id_default_audio_tracks(manifest):
                """Get the track id of the audio track to be set as default"""
                channels_stereo = ['1.0', '2.0']
                channels_multi = ['5.1', '7.1']
                is_prefer_stereo = G.ADDON.getSettingBool('prefer_audio_stereo')
            Severity: Minor
            Found in resources/lib/services/nfsession/msl/converter.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 _on_change has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
            Open

                def _on_change(self):
                    # Reinitialize the log settings
                    LOG.initialize(G.ADDON_ID, G.PLUGIN_HANDLE,
                                   G.ADDON.getSettingBool('enable_debug'),
                                   G.ADDON.getSettingBool('enable_timing'))
            Severity: Minor
            Found in resources/lib/services/settings_monitor.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 _generate_library_ctx_items has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
            Open

            def _generate_library_ctx_items(videoid):
                library_actions = []
                allow_lib_operations = True
                lib_is_sync_with_mylist = (G.ADDON.getSettingBool('lib_sync_mylist') and
                                           G.ADDON.getSettingInt('lib_auto_upd_mode') in [0, 2])
            Severity: Minor
            Found in resources/lib/kodi/context_menu.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 _find_no_duplicates has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
            Open

                def _find_no_duplicates(self, name, domain=None, path=None):
                    """Both ``__get_item__`` and ``get`` call this function: it's never
                    used elsewhere in Requests.
            
                    :param name: a string containing name of cookie
            Severity: Minor
            Found in resources/lib/utils/cookies.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_player_state has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
            Open

                def _get_player_state(self, player_id=None, time_override=None):
                    # !! WARNING KODI BUG ON: Player.GetProperties and KODI CORE / GUI, FOR STREAMS WITH ADS CHAPTERS !!
                    # todo: TO TAKE IN ACCOUNT FOR FUTURE ADS IMPROVEMENTS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    # When you are playing a stream with more chapters due to ADS,
                    # every time a chapter is ended and start the next one (chapter change) InputStream Adaptive add-on send the
            Severity: Minor
            Found in resources/lib/services/playback/action_controller.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 compile_jobs_data has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
            Open

                def compile_jobs_data(self, videoid, task_type, nfo_settings=None):
                    """Compile a list of jobs data based on the videoid"""
                    LOG.debug('Compiling list of jobs data for task handler "{}" and videoid "{}"',
                              task_type.__name__, videoid)
                    jobs_data = None
            Severity: Minor
            Found in resources/lib/kodi/library_tasks.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 _add_supplemental_plot_info has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
            Open

            def _add_supplemental_plot_info(infos, item, common_data):
                """Add supplemental info to plot description"""
                suppl_info = []
                suppl_msg = None
                suppl_dp = item.get('dpSupplementalMessage', {})
            Severity: Minor
            Found in resources/lib/kodi/infolabels.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