willforde/script.module.codequick

View on GitHub
script.module.codequick/lib/codequick/listing.py

Summary

Maintainability
F
3 days
Test Coverage

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

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

          def _close(self, listitem, isfolder):  # type: (xbmcgui.ListItem, bool) -> None
              if fanart and "fanart" not in self.raw_dict:  # pragma: no branch
                  self.raw_dict["fanart"] = fanart
              if "thumb" not in self.raw_dict:  # pragma: no branch
                  self.raw_dict["thumb"] = icon
      Severity: Minor
      Found in script.module.codequick/lib/codequick/listing.py - About 25 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

              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

      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

      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

      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

      There are no issues that match your filters.

      Category
      Status