sgammon/canteen

View on GitHub

Showing 200 of 1,384 total issues

Avoid deeply nested control flow statements.
Open

            if svalue in _metadata[index]:
              sorted_entry = _metadata[index][svalue].get(target)
              if sorted_entry:
                _metadata[index][value].remove(sorted_entry)

Severity: Major
Found in canteen/model/adapter/inmemory.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if len(_metadata[index][value]) == 0:  # pragma: no cover
              del _metadata[index][value]

Severity: Major
Found in canteen/model/adapter/inmemory.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if not isinstance(value, Key):

              if not getattr(value, 'key', None):
                raise TypeError('Cannot set non-embedded entity to object without'
                                ' a key. Got: "%s".' % value)
Severity: Major
Found in canteen/model/__init__.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if not choices:  # pragma: no cover
              raise RuntimeError('No template path configured.')

Severity: Major
Found in canteen/logic/template.py - About 45 mins to fix

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

  def fillStructure(self, fill, case_sensitive=False, **kwargs):

    """ If handed a dictionary, will fill self with those entries. Usually
        called from ``__init__``.

Severity: Minor
Found in canteen/util/struct.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

Avoid deeply nested control flow statements.
Open

            if k.startswith('__'): continue

Severity: Major
Found in canteen/util/decorators.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if hasattr(v, '__hooks__') and v.__hooks__:
              v.__register__(target)

        # attach bindings to target class
        target.__aliases__, target.__bindings__ = (
Severity: Major
Found in canteen/util/decorators.py - About 45 mins to fix

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

  def render(self, template,
Severity: Minor
Found in canteen/base/handler.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if subquery.sub_operator is query.AND:
              _and_filters.append(subquery)
            if subquery.sub_operator is query.OR:
Severity: Major
Found in canteen/model/adapter/redis.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if len(tails) == 1 and cls.EngineConfig.mode in (
                  RedisMode.hashkey_blob,
                  RedisMode.hashkind_blob):
              _target_handler = cls.Operations.HASH_GET
            else:
Severity: Major
Found in canteen/model/adapter/redis.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if not _q_init:  # no frame yet, initialize
              _q_init = True
              _data_frame = (
                set((value for _, value in filter(evaluate, index))))
            else:  # otherwise, filter
Severity: Major
Found in canteen/model/adapter/inmemory.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if subquery.sub_operator is query.OR:
              _or_filters.append(subquery)

Severity: Major
Found in canteen/model/adapter/redis.py - About 45 mins to fix

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

  def to(cls, *targets, **options):

    """ Syntactic sugar for creating an on-the-fly :py:class:`Edge` subclass.

        :param target: Target :py:class:`Vertex` subclass to factory
Severity: Minor
Found in canteen/model/__init__.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

Avoid deeply nested control flow statements.
Open

            if isinstance(_path, dict) and 'compiled' in _path:
              try:
                choices.append(ModuleLoader(_path['compiled']))
              except jinja2.TemplateNotFound:  # pragma: no cover
                pass  # no compiled template root at all
Severity: Major
Found in canteen/logic/template.py - About 45 mins to fix

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

  def resolve(cls):

    """  """

    # @TODO(sgammon): figure out how to prioritize/select a runtime
Severity: Minor
Found in canteen/core/runtime.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

Avoid deeply nested control flow statements.
Open

              if _global:
                _key = '.'.join((namespace, alias)) if namespace else alias
                property_bucket[_key] = (responder, prop)
                continue
              property_bucket[_key] = (responder, prop)
Severity: Major
Found in canteen/core/meta.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if (this_value is EMPTY) or override:
              self._set_option(option, value)
    return self
Severity: Major
Found in canteen/model/query.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              if concrete.__binding__:
                property_bucket[concrete.__binding__.__alias__] = (
                  struct.CallbackProxy(do_pluck(*(
                    concrete,
                    responder,
Severity: Major
Found in canteen/core/meta.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if 'Content-Type' not in headers:
              headers['Content-Type'] = context['headers']['Content-Type'] = (
                'text/html; charset=utf-8')

          # call response hooks
Severity: Major
Found in canteen/core/runtime.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              if prop in cls.__bindings__:
                func = (
                  cls.__dict__[prop] if not isinstance(cls.__dict__[prop], (
                    staticmethod, classmethod))
                  else cls.__dict__[prop].__func__)
Severity: Major
Found in canteen/core/meta.py - About 45 mins to fix
Severity
Category
Status
Source
Language