sgammon/canteen

View on GitHub

Showing 1,384 of 1,384 total issues

Function __init__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, module='templates', strict=False):

      """ Initialize this ``ModuleLoader`` with a target top-level ``module``.
          Templates will be loaded under this top level module name, where
          directories are converted to packages and the template file has
Severity: Minor
Found in canteen/logic/template.py - About 1 hr 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 asset_url has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def asset_url(self, type, fragments, arguments):

    """  """

    assert (fragments or arguments)  # must pass at least fragments or arguments
Severity: Minor
Found in canteen/logic/assets.py - About 1 hr 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 flatten has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def flatten(self, join=False):

    """ Flatten this Key into a basic structure suitable for transport or
        storage.

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

    def get(self, key, default=None, _skip=False):

      """ Retrieve an item from the threadcache by key.

          :param key: Key at which an item should exist in the threadcache to
Severity: Minor
Found in canteen/logic/cache.py - About 1 hr 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 url has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def url(name_or_route, route=None, **kwargs):

  """ Decorator for binding a URL (potentially with a name) to some sort of
      handler, which can really be anything from raw types like a ``str`` or a
      ``tuple`` to a full handler/function/class to a foreign WSGI callable.
Severity: Minor
Found in canteen/logic/http/semantics.py - About 1 hr 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 __call__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def __call__(self, arguments, unknown=None):  # pragma: no cover

    """ Begins dispatching execution from a set of parsed arguments, as the
        product of a :py:meth:`parser.parse_args()` call.

Severity: Minor
Found in canteen/util/cli.py - About 1 hr 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 encode_message has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def encode_message(self, message):

        """  """

        message.check_initialized()
Severity: Minor
Found in canteen/rpc/protocol/msgpack.py - About 1 hr 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 has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def _get(self, key, **kwargs):

    """ Low-level method for retrieving an entity by Key. Fetches and
        deserializes the given entity, if it exists, or returns ``None``.

Severity: Minor
Found in canteen/model/adapter/abstract.py - About 1 hr 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 4 locations. Consider refactoring.
Open

        if target not in _write[cls._reverse_prefix]:
          _write[cls._reverse_prefix][target] = set()
Severity: Major
Found in canteen/model/adapter/inmemory.py and 3 other locations - About 1 hr to fix
canteen/model/adapter/inmemory.py on lines 430..431
canteen/model/adapter/inmemory.py on lines 463..464
canteen/model/adapter/inmemory.py on lines 511..512

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

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 4 locations. Consider refactoring.
Open

        if target not in _write[cls._reverse_prefix]:  # pragma: no cover
          _write[cls._reverse_prefix][target] = set()
Severity: Major
Found in canteen/model/adapter/inmemory.py and 3 other locations - About 1 hr to fix
canteen/model/adapter/inmemory.py on lines 430..431
canteen/model/adapter/inmemory.py on lines 463..464
canteen/model/adapter/inmemory.py on lines 488..489

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

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 4 locations. Consider refactoring.
Open

        if target not in _write[cls._reverse_prefix]:
          _write[cls._reverse_prefix][target] = set()
Severity: Major
Found in canteen/model/adapter/inmemory.py and 3 other locations - About 1 hr to fix
canteen/model/adapter/inmemory.py on lines 430..431
canteen/model/adapter/inmemory.py on lines 488..489
canteen/model/adapter/inmemory.py on lines 511..512

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

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

  def __call__(self, *args, **kwargs):

    """ Execute this local ``HookResponder``, which will dispatch the underlying
        hook target, passing along any arguments and keyword arguments.

Severity: Minor
Found in canteen/core/hooks.py - About 1 hr 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 4 locations. Consider refactoring.
Open

          if target not in _write[cls._reverse_prefix]:  # pragma: no cover
            _write[cls._reverse_prefix][target] = set()
Severity: Major
Found in canteen/model/adapter/inmemory.py and 3 other locations - About 1 hr to fix
canteen/model/adapter/inmemory.py on lines 463..464
canteen/model/adapter/inmemory.py on lines 488..489
canteen/model/adapter/inmemory.py on lines 511..512

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

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

  def _execute(self, options=None, adapter=None, **kwargs):

    """ Internal method to execute a query, optionally along with some override
        options.

Severity: Minor
Found in canteen/model/query.py - About 1 hr 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 3 locations. Consider refactoring.
Open

              if isinstance(target, Key) and not (
                  isinstance(target, VertexKey)):  # pragma: no cover
                # @TODO(sgammon): unambiguous graph keys
                target = VertexKey.from_urlsafe(target.urlsafe())
Severity: Major
Found in canteen/model/adapter/abstract.py and 2 other locations - About 1 hr to fix
canteen/model/adapter/abstract.py on lines 992..995
canteen/model/adapter/abstract.py on lines 999..1002

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

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 3 locations. Consider refactoring.
Open

                if isinstance(target, Key) and not (
                    isinstance(target, VertexKey)):  # pragma: no cover
                  # @TODO(sgammon): unambiguous graph keys
                  target = VertexKey.from_urlsafe(target.urlsafe())
Severity: Major
Found in canteen/model/adapter/abstract.py and 2 other locations - About 1 hr to fix
canteen/model/adapter/abstract.py on lines 969..972
canteen/model/adapter/abstract.py on lines 992..995

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

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 3 locations. Consider refactoring.
Open

              if isinstance(source, Key) and not (
                  isinstance(source, VertexKey)):  # pragma: no cover
                # @TODO(sgammon): unambiguous graph keys
                source = VertexKey.from_urlsafe(source.urlsafe())
Severity: Major
Found in canteen/model/adapter/abstract.py and 2 other locations - About 1 hr to fix
canteen/model/adapter/abstract.py on lines 969..972
canteen/model/adapter/abstract.py on lines 999..1002

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

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

    def to_message(self, *args, **kwargs):

      """ Convert a `Model` instance to a ProtoRPC `Message` class.

          :param args: Positional arguments to pass to
Severity: Minor
Found in canteen/model/adapter/protorpc.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 allocate_ids has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def allocate_ids(cls, key_class, kind, count=1, pipeline=None):

    """ Allocate new :py:class:`model.Key` IDs up to ``count``. Allocated IDs
        are guaranteed not to be provisioned or otherwise used by the underlying
        persistence engine, and thus can be used for uniquely identifying
Severity: Minor
Found in canteen/model/adapter/redis.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 __new__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def __new__(mcs, name, chain, _map):

      """ Read mapped properties, store on the object, along with a reverse
          mapping.

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

Severity
Category
Status
Source
Language