krygal/samsung_multiroom

View on GitHub

Showing 22 of 52 total issues

File api.py has 963 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Low level api to communicate with samsung multiroom speaker."""
import inspect
import logging
import urllib.parse

Severity: Major
Found in samsung_multiroom/api/api.py - About 2 days to fix

    SamsungMultiroomApi has 68 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SamsungMultiroomApi:
        """
        Samsung Multiroom Api implementation.
    
        Contains non-inclusive list of API calls you can make to control the speaker.
    Severity: Major
    Found in samsung_multiroom/api/api.py - About 1 day to fix

      Function open has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def open(self, uri):
              """
              Generator consuming events from speaker's main info stream.
      
              Yields ApiResponse instance.
      Severity: Minor
      Found in samsung_multiroom/api/api_stream.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

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

      class SpeakerGroup(SpeakerBase):
          """
          Speaker group.
      
          Use Speaker.group() to initiate grouping.
      Severity: Minor
      Found in samsung_multiroom/group.py - About 2 hrs to fix

        Speaker has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Speaker(SpeakerBase):
            """Entry control for speaker operation."""
        
            def __init__(self, api, event_loop, clock, equalizer, player_operator, service_registry):
                """
        Severity: Minor
        Found in samsung_multiroom/speaker.py - About 2 hrs to fix

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

          class SpeakerBase(metaclass=abc.ABCMeta):
              """Speaker interface to control speaker operation."""
          
              @property
              def ip_address(self):
          Severity: Minor
          Found in samsung_multiroom/base.py - About 2 hrs to fix

            Function _factory_item has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def _factory_item(self, data):
                    kwargs = {'metadata': {}}
            
                    # mandatory
                    if 'dmsid' in data:
            Severity: Minor
            Found in samsung_multiroom/service/dlna/browser.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 _factory_item has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def _factory_item(self, data):
                    kwargs = {'metadata': {}}
            
                    # mandatory
                    if '@id' in data:
            Severity: Minor
            Found in samsung_multiroom/service/app/browser.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 set has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def set(self, time=None, weekdays=None, duration=None, volume=None, station_data=None, playlist=None, enabled=None):
                    """
                    Update speaker's configuration for this slot.
            
                    :param time: hour/minute when to trigger the alarm in HH:MM format
            Severity: Minor
            Found in samsung_multiroom/clock/alarm.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

            Function set has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def set(self, *args):
                    """
                    Set equalizer values by preset name or list of band values
            
                    :param: Name of the preset to set or list of 7 band values to set
            Severity: Minor
            Found in samsung_multiroom/equalizer/equalizer.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

            Function get_current_track has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_current_track(self):
                    """
                    Get current track info.
            
                    :returns: Track instance, or None if unavailable
            Severity: Minor
            Found in samsung_multiroom/service/dlna/player.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

            Function format_param has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def format_param(param):
                """
                Format request parameter.
            
                :param param: Tuple e.g. ('list_count', 30, 'dec')
            Severity: Minor
            Found in samsung_multiroom/api/api.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

            Function set has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def set(self, time=None, weekdays=None, duration=None, volume=None, station_data=None, playlist=None, enabled=None):
            Severity: Major
            Found in samsung_multiroom/clock/alarm.py - About 50 mins to fix

              Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, title, artist, album, duration, position, thumbnail_url, metadata=None):
              Severity: Major
              Found in samsung_multiroom/service/player.py - About 50 mins to fix

                Function set_alarm_info has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def set_alarm_info(self, index, hour, minute, week, duration, volume, station_data):
                Severity: Major
                Found in samsung_multiroom/api/api.py - About 50 mins to fix

                  Function get_current_track has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get_current_track(self):
                          """
                          Get current track info.
                  
                          :returns: Track instance, or None if unavailable
                  Severity: Minor
                  Found in samsung_multiroom/service/app/player.py - About 45 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

                  Function paginator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def paginator(*args):
                      """
                      Generator to paginate over api call.
                  
                      Api method must accept start_index and list_count parameters.
                  Severity: Minor
                  Found in samsung_multiroom/api/api.py - About 45 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

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

                      def __init__(self, api, event_loop, clock, equalizer, player_operator, service_registry):
                  Severity: Minor
                  Found in samsung_multiroom/speaker.py - About 45 mins to fix

                    Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def __init__(self, api, app_id, app_name, path=None, items=None):
                    Severity: Minor
                    Found in samsung_multiroom/service/app/browser.py - About 35 mins to fix

                      Function set_playlist_playback_control has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def set_playlist_playback_control(self, items):
                              """
                              Create a playlist and playback.
                      
                              Use pc_get_music_list_by_id() to fetch item information required for playlist item.
                      Severity: Minor
                      Found in samsung_multiroom/api/api.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