willforde/script.module.codequick

View on GitHub

Showing 65 of 65 total issues

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

    def channels(self, channel_id):
        """
        Return all available information for giving channel

        Note:
Severity: Minor
Found in script.module.codequick/lib/codequick/youtube.py and 1 other location - About 45 mins to fix
script.module.codequick/lib/codequick/youtube.py on lines 280..298

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

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

@wraps(requests.patch, assigned=WRAPPER_ASSIGNMENTS)
def patch(url, data=None, **kwargs):  # type: (...) -> Response
    return request('patch', url, data=data, **kwargs)
Severity: Minor
Found in script.module.codequick/lib/urlquick.py and 1 other location - About 45 mins to fix
script.module.codequick/lib/urlquick.py on lines 512..514

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

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 _process_item has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def _process_item(self, count, url):
        """
        Process the playlist item and add to kodi playlist.

        :param int count: The part number of the item
Severity: Minor
Found in script.module.codequick/lib/codequick/resolver.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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, name, ttl=None):
        super(PersistentList, self).__init__(name)
        data = self._load()
        self._data = []

Severity: Minor
Found in script.module.codequick/lib/codequick/storage.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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def execute(self, sqlquery, args, repeat=False):  # type: (str, tuple, bool) -> None
        self.cur.execute("BEGIN")
        try:
            self.cur.execute(sqlquery, args)

Severity: Minor
Found in script.module.codequick/lib/codequick/storage.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 _close has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def _close(self, listitem):  # type: (xbmcgui.ListItem) -> None
        video = {}
        subtitle = {}
        audio = {"channels": 2}

Severity: Minor
Found in script.module.codequick/lib/codequick/listing.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 get_info has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def get_info(key, addon_id=None):
        """
        Returns the value of an add-on property as a unicode string.

        Properties.
Severity: Minor
Found in script.module.codequick/lib/codequick/script.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 playlist has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def playlist(plugin, contentid, pagetoken=None, enable_playlists=True, loop=False):
Severity: Minor
Found in script.module.codequick/lib/codequick/youtube.py - About 35 mins to fix

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

    def saved_searches(plugin, remove_entry=None, search=False, first_load=False, **extras):
    Severity: Minor
    Found in script.module.codequick/lib/codequick/search.py - About 35 mins to fix

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

      def playlists(plugin, channel_id, show_all=True, pagetoken=None, loop=False):
      Severity: Minor
      Found in script.module.codequick/lib/codequick/youtube.py - About 35 mins to fix

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

        def playlist(plugin, contentid, pagetoken=None, enable_playlists=True, loop=False):
            """
            List all videos within youtube playlist
        
            :param Route plugin: Tools related to Route callbacks.
        Severity: Minor
        Found in script.module.codequick/lib/codequick/youtube.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

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

            def run_callback(self, process_errors=True, redirect=None):
                """
                The starting point of the add-on.
        
                This function will handle the execution of the "callback" functions.
        Severity: Minor
        Found in script.module.codequick/lib/codequick/support.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

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

            def localize(string_id):
                """
                Returns a translated UI string from addon localization files.
        
                .. note::
        Severity: Minor
        Found in script.module.codequick/lib/codequick/script.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

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

        def playlists(plugin, channel_id, show_all=True, pagetoken=None, loop=False):
            """
            List all playlist for giving channel
        
            :param Route plugin: Tools related to Route callbacks.
        Severity: Minor
        Found in script.module.codequick/lib/codequick/youtube.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

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

            def get_route(self, path=None):  # type: (str) -> Route
                """
                Return the given route callback.
        
                :param str path: The route path, if not given defaults to current callback
        Severity: Minor
        Found in script.module.codequick/lib/codequick/support.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

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

            def send(self, request, **kwargs):  # type: (PreparedRequest, ...) -> Response
                max_age = int(request.headers.pop("x-cache-max-age"))
                urlhash = hash_url(request) if max_age >= 0 else None
                cache = None
        
        
        Severity: Minor
        Found in script.module.codequick/lib/urlquick.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

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

            def _duration(duration):
                """Converts duration from a string of 'hh:mm:ss' into seconds."""
                if isinstance(duration, (str, unicode_type)):
                    duration = duration.replace(";", ":").strip(":")
                    if ":" in duration:
        Severity: Minor
        Found in script.module.codequick/lib/codequick/listing.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

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

            def get_cache(self, urlhash, max_age):  # type: (str, int) -> CacheRecord
                """Return a cached response if one exists."""
                result = self.execute("""SELECT key, response,
                strftime('%s', 'now') - strftime('%s', cached_date, 'unixepoch') < ? AS fresh
                FROM urlcache WHERE key = ?""", (max_age, urlhash))
        Severity: Minor
        Found in script.module.codequick/lib/urlquick.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

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

            elif callback:
                msg = "passing in callback path is deprecated, use callback reference 'Route.ref' instead"
                logger.warning("DeprecationWarning: " + msg)
                route = dispatcher.get_route(callback)
        Severity: Minor
        Found in script.module.codequick/lib/codequick/support.py and 1 other location - About 30 mins to fix
        script.module.codequick/lib/codequick/listing.py on lines 654..658

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

        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 "://" not in callback:
                        msg = "passing callback path to 'set_callback' is deprecated, " \
                              "use callback reference 'Route.ref' instead"
                        logger.warning("DeprecationWarning: " + msg)
                        callback = dispatcher.get_route(callback)
        Severity: Minor
        Found in script.module.codequick/lib/codequick/listing.py and 1 other location - About 30 mins to fix
        script.module.codequick/lib/codequick/support.py on lines 376..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 32.

        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