Showing 20 of 29 total issues
File microservice.py
has 331 lines of code (exceeds 250 allowed). Consider refactoring. Open
import logging
import os
import functools
import random
import threading
MicroService
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class MicroService(Container):
#: The name of the service. Is required.
name = None
#: The host where the service will listen
Function post
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def post(self):
if self.request.headers.get("Content-type").split(";")[0] != "application/json":
self.write_single_response(GenericResponse.INVALID_REQUEST)
return
- Read upRead up
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 handle_single_request
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def handle_single_request(self, request_object):
"""
Handles a single request object and returns the correct result as follows:
- A valid response object if it is a regular request (with ID)
- Read upRead up
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 parse_json_structure
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def parse_json_structure(string_item):
"""
Given a raw representation of a json structure, returns the parsed corresponding data
structure (``JsonRpcRequest`` or ``JsonRpcRequestBatch``)
- Read upRead up
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 exposed_method
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def exposed_method(name=None, private=False, is_coroutine=True, requires_handler_reference=False):
"""
Marks a method as exposed via JSON RPC.
:param name: the name of the exposed method. Must contains only letters, digits, dots and underscores.
- Read upRead up
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_service
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_service(self, name):
"""
Locates a remote service by name. The name can be a glob-like pattern
(``"project.worker.*"``). If multiple services match the given name, a
random instance will be chosen. There might be multiple services that
- Read upRead up
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 from_dict
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def from_dict(cls, d):
"""
Validates a dict instance and transforms it in a
:py:class:`gemstone.core.structs.JsonRpcRequest`
instance
- Read upRead up
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 as_completed
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def as_completed(*async_result_wrappers):
"""
Yields results as they become available from asynchronous method calls.
Example usage
- Read upRead up
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 __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, host="127.0.0.1", port=5672, username="", password="", **connection_options):
Function _activate_configurators
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _activate_configurators(self):
for configurator in self.configurators:
configurator.load()
for configurator in self.configurators:
- Read upRead up
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 prepare_method_call
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def prepare_method_call(self, method, args):
"""
Wraps a method so that method() will call ``method(*args)`` or ``method(**args)``,
depending of args type
- Read upRead up
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_batch
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def call_batch(self, *requests):
body = []
ids = {}
for item in requests:
if not isinstance(item, (MethodCall, Notification)):
- Read upRead up
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 expire_entries
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def expire_entries(self):
with self.container_lock:
for _, entries in self.container.items():
i = 0
while i < len(entries):
- Read upRead up
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 too many return
statements within this function. Open
return err
Avoid too many return
statements within this function. Open
return resp
Avoid too many return
statements within this function. Open
return to_return_resp
Avoid too many return
statements within this function. Open
return resp
Function dynamic_load
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def dynamic_load(module_or_member):
"""
Dynamically loads a class or member of a class.
If ``module_or_member`` is something like ``"a.b.c"``, will perform ``from a.b import c``.
- Read upRead up
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 first_completed
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def first_completed(*async_result_wrappers):
"""
Just like :py:func:`as_completed`, but returns only the first item and discards the
rest.
- Read upRead up
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"