sgammon/canteen

View on GitHub

Showing 1,384 of 1,384 total issues

Function execute_query has a Cognitive Complexity of 229 (exceeds 5 allowed). Consider refactoring.
Open

  def execute_query(cls, kind, spec, options, **kwargs):  # pragma: no cover

    """ Execute a :py:class:`model.Query` across one (or multiple) indexed
        properties.

Severity: Minor
Found in canteen/model/adapter/redis.py - About 4 days 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 execute_query has a Cognitive Complexity of 179 (exceeds 5 allowed). Consider refactoring.
Open

  def execute_query(cls, kind, spec, options, **kwargs):  # pragma: no cover

    """ Execute a query across one (or multiple) indexed properties. Collapses
        a symbolic :py:class:`canteen.model.query.Query` object and attempts to
        properly satisfy any ``Filter``/``Sort`` objects attached.
Severity: Minor
Found in canteen/model/adapter/inmemory.py - About 3 days 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

File redis.py has 1141 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""

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

File __init__.py has 1111 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""

  model
Severity: Major
Found in canteen/model/__init__.py - About 2 days to fix

Cyclomatic complexity is too high in method execute_query. (103)
Open

  @classmethod
  def execute_query(cls, kind, spec, options, **kwargs):  # pragma: no cover

    """ Execute a :py:class:`model.Query` across one (or multiple) indexed
        properties.
Severity: Minor
Found in canteen/model/adapter/redis.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

Function to_dict has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
Open

  def to_dict(self, exclude=tuple(), include=tuple(),
              filter=None, map=None, _all=False,
              filter_fn=filter, map_fn=map,
              convert_keys=True, convert_models=True, convert_datetime=True):

Severity: Minor
Found in canteen/model/adapter/core.py - About 1 day 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 collapse has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
Open

    def collapse(cls, spec=None):

      """ Collapse available ``component`` items into a mapping of names to
          objects which can respond to attribute requests for those paths.

Severity: Minor
Found in canteen/core/meta.py - About 1 day 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

File abstract.py has 728 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""

  abstract model adapters
Severity: Major
Found in canteen/model/adapter/abstract.py - About 1 day to fix

Function generate_indexes has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring.
Open

  def generate_indexes(cls, key, entity=None, properties=None):

    """ Generate a set of indexes that should be written to with associated
        values, considering that some ``key`` values may be ``VertexKey`` or
        ``EdgeKey`` instances.
Severity: Minor
Found in canteen/model/adapter/abstract.py - About 1 day 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 clean_indexes has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
Open

  def clean_indexes(cls, writes, **kwargs):

    """ Clean indexes for a key that is due to be deleted.

        :param writes: Index writes that would be committed if the ``key`` was
Severity: Minor
Found in canteen/model/adapter/inmemory.py - About 1 day 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

File query.py has 672 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""

  model queries
Severity: Major
Found in canteen/model/query.py - About 1 day to fix

File template.py has 646 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""

  template logic
Severity: Major
Found in canteen/logic/template.py - About 1 day to fix

Cyclomatic complexity is too high in method execute_query. (60)
Open

  @classmethod
  def execute_query(cls, kind, spec, options, **kwargs):  # pragma: no cover

    """ Execute a query across one (or multiple) indexed properties. Collapses
        a symbolic :py:class:`canteen.model.query.Query` object and attempts to
Severity: Minor
Found in canteen/model/adapter/inmemory.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

Function write_indexes has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

  def write_indexes(cls, w, g, pipeline=None, execute=True):

    """ Write a batch of index updates generated earlier via
        :py:meth:`RedisAdapter.generate_indexes`.

Severity: Minor
Found in canteen/model/adapter/redis.py - About 1 day 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 write_indexes has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
Open

  def write_indexes(cls, writes, _graph, execute=True):

    """ Write a set of generated indexes via `generate_indexes`.

        :param writes: Index writes to commit to the ``_metadata`` ``dict``.
Severity: Minor
Found in canteen/model/adapter/inmemory.py - About 1 day 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 get_multi has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

  def get_multi(cls, keys, pipeline=None, **kwargs):

    """ Retrieve a set of entity by Key from Redis, all in one go.

        :param keys: Target iterable of :py:class:`model.Key` instances to
Severity: Minor
Found in canteen/model/adapter/redis.py - About 1 day 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

File inmemory.py has 544 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""

  in-memory model adapter
Severity: Major
Found in canteen/model/adapter/inmemory.py - About 1 day to fix

Function build_message has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

  def build_message(_model):

    """ Recursively builds a new `Message` class dynamically from a canteen
        :py:class:`model.Model`. Properties are converted to their
        :py:mod:`protorpc` equivalents and factoried into a full
Severity: Minor
Found in canteen/model/adapter/protorpc.py - About 1 day 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 bind_urls has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

  def bind_urls(self):

    """ Bind static asset URLs, if Canteen is instructed to handle requests for
        static assets. Constructs handlers according to URLs and paths from
        application configuration. """
Severity: Minor
Found in canteen/logic/assets.py - About 1 day 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

File __init__.py has 497 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""

  RPC
Severity: Minor
Found in canteen/rpc/__init__.py - About 7 hrs to fix
Severity
Category
Status
Source
Language