willforde/script.module.codequick

View on GitHub

Showing 65 of 65 total issues

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

    def container(self, callback, label, *args, **kwargs):
        """
        Convenient method to add a context menu item that links to a "container".

        :param Callback callback: The function that will be called when menu item is activated.
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 490..501

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

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 script(self, callback, label, *args, **kwargs):
        """
        Convenient method to add a context menu item that links to a "script".

        :param Callback callback: The function that will be called when menu item is activated.
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 476..488

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

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 from_dict has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def from_dict(
Severity: Major
Found in script.module.codequick/lib/codequick/listing.py - About 1 hr to fix

    Function build_path has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def build_path(callback=None, args=None, query=None, **extra_query):
        """
        Build addon url that can be passed to kodi for kodi to use when calling listitems.
    
        :param callback: [opt] The route selector path referencing the callback object. (default => current route selector)
    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 build_sortmethods has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def build_sortmethods(manualsort, autosort):  # type: (list, set) -> list
        """Merge manual & auto sortmethod together."""
        if autosort:
            # Add unsorted sort method if not sorted by date and no manually set sortmethods are given
            if not (manualsort or xbmcplugin.SORT_METHOD_DATE in autosort):
    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

    Function valid_playlistid has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def valid_playlistid(self, contentid):
            """
            Return a valid playlist uuid.
    
            Contentid can be a channel uuid, playlist uuid or channel uploads uuid.
    Severity: Minor
    Found in script.module.codequick/lib/codequick/youtube.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 __getitem__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def __getitem__(self, key):
            if key in self.buffer:
                return self.buffer[key]
            else:
                item = self.cur.execute("SELECT value, timestamp FROM itemcache WHERE key = ?", (key,)).fetchone()
    Severity: Minor
    Found in script.module.codequick/lib/codequick/storage.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

    @wraps(requests.head, assigned=WRAPPER_ASSIGNMENTS)
    def head(url, **kwargs):  # type: (...) -> Response
        kwargs.setdefault('allow_redirects', False)
        return request('head', url, **kwargs)
    Severity: Major
    Found in script.module.codequick/lib/urlquick.py and 1 other location - About 1 hr to fix
    script.module.codequick/lib/urlquick.py on lines 495..498

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

    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

                        (str(e).find("file is encrypted") > -1 or str(e).find("not a database") > -1):
    Severity: Major
    Found in script.module.codequick/lib/codequick/storage.py and 1 other location - About 1 hr to fix
    script.module.codequick/lib/urlquick.py on lines 282..282

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

    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

                if repeat is False and (str(e).find("file is encrypted") > -1 or str(e).find("not a database") > -1):
    Severity: Major
    Found in script.module.codequick/lib/urlquick.py and 1 other location - About 1 hr to fix
    script.module.codequick/lib/codequick/storage.py on lines 279..279

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

    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.options, assigned=WRAPPER_ASSIGNMENTS)
    def options(url, **kwargs):  # type: (...) -> Response
        kwargs.setdefault('allow_redirects', True)
        return request('options', url, **kwargs)
    Severity: Major
    Found in script.module.codequick/lib/urlquick.py and 1 other location - About 1 hr to fix
    script.module.codequick/lib/urlquick.py on lines 501..504

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

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

        def _connect_v3(self, api_type, query, loop=False):
            """
            Send API request and return response as a json object.
    
            :param str api_type: The type of api request to make.
    Severity: Minor
    Found in script.module.codequick/lib/codequick/youtube.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 from_dict has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_dict(
                cls,
                callback,
                label,
                art=None,
    Severity: Minor
    Found in script.module.codequick/lib/codequick/listing.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 saved_searches has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def saved_searches(plugin, remove_entry=None, search=False, first_load=False, **extras):
        """
        Callback used to list all saved searches for the addon that called it.
    
        Useful to add search support to addon and will also keep track of previous searches.
    Severity: Minor
    Found in script.module.codequick/lib/codequick/search.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 build has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def build(self):
            listitem = self.listitem
            isfolder = self._is_folder
            listitem.setProperty("folder", str(isfolder).lower())
            listitem.setProperty("isplayable", str(self._is_playable).lower())
    Severity: Minor
    Found in script.module.codequick/lib/codequick/listing.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 __call__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self, route, args, kwargs):
            cache_ttl = getattr(self, "cache_ttl", -1)
            cache = Cache("listitem_cache.sqlite", cache_ttl * 60) if cache_ttl >= 0 else None
            session_id = get_session_id()
    
    
    Severity: Minor
    Found in script.module.codequick/lib/codequick/route.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

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

        def videos(self, video_id):
            """
            Return all available information for giving video/vidoes.
    
            Refer to 'https://developers.google.com/youtube/v3/docs/videos/list'
    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 212..234

    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.put, assigned=WRAPPER_ASSIGNMENTS)
    def put(url, data=None, **kwargs):  # type: (...) -> Response
        return request('put', 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 517..519

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

        def __init__(self, name, ttl=None):
            super(PersistentDict, 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

    Severity
    Category
    Status
    Source
    Language