willforde/script.module.codequick

View on GitHub

Showing 65 of 65 total issues

File listing.py has 665 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
from __future__ import absolute_import

# Standard Library Imports
from time import strptime, strftime
Severity: Major
Found in script.module.codequick/lib/codequick/listing.py - About 1 day to fix

    File youtube.py has 488 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    from __future__ import absolute_import
    
    # Standard Library Imports
    import logging
    Severity: Minor
    Found in script.module.codequick/lib/codequick/youtube.py - About 7 hrs to fix

      File urlquick.py has 352 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/env python
      # -*- coding: utf-8 -*-
      #
      # The MIT License (MIT)
      #
      Severity: Minor
      Found in script.module.codequick/lib/urlquick.py - About 4 hrs to fix

        File script.py has 301 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        from __future__ import absolute_import
        
        # Standard Library Imports
        import logging
        Severity: Minor
        Found in script.module.codequick/lib/codequick/script.py - About 3 hrs to fix

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

          def send_to_kodi(handle, session):
              """Handle the processing of the listitems."""
              # Guess the contenty type
              if session["content_type"] == -1:
                  kodi_listitems = []
          Severity: Minor
          Found in script.module.codequick/lib/codequick/route.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 support.py has 280 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          from __future__ import absolute_import
          
          # Standard Library Imports
          import importlib
          Severity: Minor
          Found in script.module.codequick/lib/codequick/support.py - About 2 hrs to fix

            Function request_videos has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

                def request_videos(self, ids):
                    """
                    Return all requested videos from cache.
            
                    If requested video(s) are not cached, the video data will be
            Severity: Minor
            Found in script.module.codequick/lib/codequick/youtube.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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                def playlist_items(self, playlist_id, pagetoken=None, loop=False):
                    """
                    Return all videos ids for giving playlist ID.
            
                    Refer to 'https://developers.google.com/youtube/v3/docs/playlistItems/list'
            Severity: Major
            Found in script.module.codequick/lib/codequick/youtube.py and 1 other location - About 2 hrs to fix
            script.module.codequick/lib/codequick/youtube.py on lines 300..323

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 54.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                def playlists(self, channel_id, pagetoken=None, loop=False):
                    """
                    Return all playlist for a giving channel_id.
            
                    Refer to 'https://developers.google.com/youtube/v3/docs/playlists/list'
            Severity: Major
            Found in script.module.codequick/lib/codequick/youtube.py and 1 other location - About 2 hrs to fix
            script.module.codequick/lib/codequick/youtube.py on lines 256..278

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 54.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    try:
                        value = type_converter(value)
                    except ValueError:
                        msg = "Value of '%s' for stream info '%s', is not of type '%s'"
                        raise TypeError(msg % (value, key, type_converter))
            Severity: Major
            Found in script.module.codequick/lib/codequick/listing.py and 1 other location - About 2 hrs to fix
            script.module.codequick/lib/codequick/listing.py on lines 256..263

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 52.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                        if type_converter:
                            try:
                                value = type_converter(value)
                            except ValueError:
                                msg = "value of '%s' for infolabel '%s', is not of type '%s'"
            Severity: Major
            Found in script.module.codequick/lib/codequick/listing.py and 1 other location - About 2 hrs to fix
            script.module.codequick/lib/codequick/listing.py on lines 373..379

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 52.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function __setitem__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                def __setitem__(self, key, value):
                    if value is None or value == "":
                        logger.debug("Ignoring empty infolable: '%s'", key)
                        return None
            
            
            Severity: Minor
            Found in script.module.codequick/lib/codequick/listing.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 run_delayed has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def run_delayed(self, exception=None):
                    """Execute all delayed callbacks, if any."""
                    if self.registered_delayed:
                        # Time before executing callbacks
                        start_time = time.time()
            Severity: Minor
            Found in script.module.codequick/lib/codequick/support.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 parse_qs has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            def parse_qs(qs, keep_blank_values=False, strict_parsing=False):
                """
                Parse a "urlencoded" query string, and return the data as a dictionary.
            
                Parse a query string given as a string or unicode argument (data of type application/x-www-form- urlencoded).
            Severity: Minor
            Found in script.module.codequick/lib/codequick/utils.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 _process_results has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def _process_results(self, resolved):
                    """
                    Construct playable listitem and send to kodi.
            
                    :param resolved: The resolved url to send back to kodi.
            Severity: Minor
            Found in script.module.codequick/lib/codequick/resolver.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 extract_source has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def extract_source(self, url, quality=None, **params):
                    """
                    Extract video URL using "YouTube.DL".
            
                    YouTube.DL provides access to hundreds of sites.
            Severity: Minor
            Found in script.module.codequick/lib/codequick/resolver.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

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                def __setitem__(self, key, value):
                    if isinstance(value, bytes):
                        self.raw_dict[key] = value.decode("utf8")
                    else:
                        self.raw_dict[key] = value
            Severity: Major
            Found in script.module.codequick/lib/codequick/listing.py and 1 other location - About 1 hr to fix
            script.module.codequick/lib/codequick/listing.py on lines 267..274

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 42.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                        elif isinstance(value, unicode_type):
                            # Only executes on python 2
                            self.raw_dict[key] = value.encode("utf8")
                        elif isinstance(value, bytes):
                            # Only executes on python 3
            Severity: Major
            Found in script.module.codequick/lib/codequick/listing.py and 1 other location - About 1 hr to fix
            script.module.codequick/lib/codequick/listing.py on lines 108..112

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 42.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

            def validate_listitems(raw_listitems):
                """Check if we have a vialid set of listitems."""
            
                # Convert a generator of listitems into a list of listitems
                if inspect.isgenerator(raw_listitems):
            Severity: Minor
            Found in script.module.codequick/lib/codequick/route.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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                if u"nextPageToken" in feed:
                    next_item = Listitem.next_page(contentid=contentid, pagetoken=feed[u"nextPageToken"])
                    results.append(next_item)
            Severity: Major
            Found in script.module.codequick/lib/codequick/youtube.py and 1 other location - About 1 hr to fix
            script.module.codequick/lib/codequick/youtube.py on lines 722..724

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 41.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language