sgammon/canteen

View on GitHub

Showing 1,384 of 1,384 total issues

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

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

    for datapoint in self.__slots__:
      setattr(self, datapoint, kwargs[datapoint] if datapoint in (
Severity: Minor
Found in canteen/logic/http/agent.py and 1 other location - About 45 mins to fix
canteen/logic/http/agent.py on lines 286..287

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

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

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

    filters = filters and ([filters] if not (
      isinstance(filters, (list, tuple))) else filters) or None
Severity: Minor
Found in canteen/model/query.py and 1 other location - About 45 mins to fix
canteen/model/query.py on lines 467..468

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

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

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

  option_names = frozenset(('_'.join(opt.split('_')[1:]) for opt in options))
Severity: Minor
Found in canteen/model/query.py and 1 other location - About 45 mins to fix
canteen/model/query.py on lines 420..420

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

Severity
Category
Status
Source
Language