sgammon/canteen

View on GitHub

Showing 1,384 of 1,384 total issues

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

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 173..174

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 hasattr(obj, property_name):
                    return getattr(obj, property_name)  # pragma: nocover

Severity: Major
Found in canteen/core/meta.py - About 45 mins to fix

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

          left = _graph['neighbors']['directed']['out'][entity['source']]
Severity: Minor
Found in canteen/model/adapter/inmemory.py and 1 other location - About 45 mins to fix
canteen/model/adapter/inmemory.py on lines 249..249

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

  def pack(self, encode=True):

    """ Pack this set of ``QueryOptions`` into a string describing the
        constituent settings it contains.

Severity: Minor
Found in canteen/model/query.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 pack has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def pack(self, encode=True):

    """ Pack this ``Query`` instance into a structure uniquely describing it,
        with the ability to optionally expand that into a ``Query`` object
        representing the same operations.
Severity: Minor
Found in canteen/model/query.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 klass.__binding__ and klass.__binding__.__alias__:
                    parent_ref = '.'.join((
                      klass.__binding__.__alias__, property_name))
                    if parent_ref in pool:
                      return pool[parent_ref]
Severity: Major
Found in canteen/core/meta.py - About 45 mins to fix

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

  def __enter__(self):

    """ Context entrance method, responsible for triggering a load of the top-
        level package and propagating exceptions if ``strict`` mode is active.

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

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

          left_e = _graph['edges']['directed']['out'][entity['source']]
Severity: Minor
Found in canteen/model/adapter/inmemory.py and 1 other location - About 45 mins to fix
canteen/model/adapter/inmemory.py on lines 248..248

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

    sorts = sorts and ([sorts] if not (
      isinstance(sorts, (list, tuple))) else sorts) 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 464..465

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

    def prepare(mcs, target):

      """ Prepare ``target`` (usually ``cls``) for injection, possibly resolving
          a global singleton object to be returned upon matching attribute
          requests.
Severity: Minor
Found in canteen/core/meta.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 hasattr(klass, '__aliases__') and (
                    property_name in klass.__aliases__):
                    return getattr(obj, klass.__aliases__[property_name])
                  if hasattr(obj, property_name):
Severity: Major
Found in canteen/core/meta.py - About 45 mins to fix

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

  def run(output=None,
Severity: Minor
Found in canteen/test.py - About 45 mins to fix

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

  def __init__(self, prop, value,
Severity: Minor
Found in canteen/model/query.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              if not isinstance(bundle, tuple):  # pragma: no cover
                _key = '.'.join((namespace, bundle)) if namespace else bundle
                property_bucket[_key] = (responder, bundle)
                continue

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

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

Consider simplifying this complex logical expression.
Open

    if not (isinstance(value, (model.Key, model.Model)) or (
            isinstance(value, type) and issubclass(value, model.Model)) or (
            value is None)):
      raise ValueError('`KeyFilter` value must be a `Key`, model class,'
                       ' or `None`. Instead, got: "%s".' % repr(value))
Severity: Major
Found in canteen/model/query.py - About 40 mins to fix

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

    for key, value in (map.iteritems() if isinstance(map, dict) else map):
      _cache.set(key, value)
Severity: Minor
Found in canteen/logic/cache.py and 1 other location - About 40 mins to fix
canteen/logic/cache.py on lines 385..386

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

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 parts and formats.get('raw'):
      return cls.from_raw(formats['raw'])
Severity: Minor
Found in canteen/model/__init__.py and 1 other location - About 40 mins to fix
canteen/model/__init__.py on lines 1182..1183

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

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