Showing 39 of 49 total issues
Function refresh_token
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def refresh_token(token, session=None):
"""Refresh Google OAuth token.
:param OAuthToken token:
the token to refresh
- 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_index_bulk_query
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _prepare_index_bulk_query(cls, docs, action):
body = []
errors = []
for doc in docs:
if not isinstance(doc, (dict, Mapping)):
- 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 push_cards
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def push_cards(self, cards):
for i in range(len(cards)):
try:
c = cards[i]
if 'kind' not in 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
Avoid deeply nested control flow statements. Open
if item[operation]['status'] not in [200, 201]:
error_docs.append({
'card': docs[index],
'status': item[operation]['status'],
'id': docs[index]['id']
Function wait_or_raise
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def wait_or_raise(logger, retry_exc, attempt):
wait_time = None
if attempt == retry_exc.max_retries:
raise retry_exc
if retry_exc.countdown is not None:
- 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_env
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def from_env(cls, envvars, default, default_config):
try:
if isinstance(envvars, six.string_types):
envvars = [envvars]
config_file = default
- 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, kwargs=None, countdown=None, exc=None,
Function teb_retry
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def teb_retry(exc=RequestException,
Function truncated_exponential_backoff
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def truncated_exponential_backoff(
Function register
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def register(cls, component=None):
component = component or cls
cls._components.add(component)
registry = cls._registry
for cls in component.__mro__:
- 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 _eval_exp
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _eval_exp(cls, obj, exp, value):
op = operator.eq
tokens = exp.split('__')[::-1]
_op = cls._get_operation(tokens[0])
if _op is not None:
- 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 decorate_instance_methods
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def decorate_instance_methods(obj, decorator, includes=None, excludes=None):
"""Decorator instance methods of an object.
:param obj: Python object whose instance methods have to be decorated
:param decorator:
- 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 unicode(text)
Avoid too many return
statements within this function. Open
return ' '.join([to_unicode(arg) for arg in text.args])
Function mount_rate_limit_adapters
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def mount_rate_limit_adapters(cls, session=None,
rls_config=None, **kwargs):
"""Mount rate-limits adapters on the specified `requests.Session`
object.
- 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_obj_attr
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _get_obj_attr(cls, obj, path, pos):
"""Resolve one kwargsql expression for a given object and returns
its result.
:param obj: the object to evaluate
- 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 __getitem__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __getitem__(self, cls):
"""Activate the component instance for the given class, or
return the existing instance if the component has already been
activated.
- 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 fix_mispelled_day
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def fix_mispelled_day(cls, timestr):
"""fix mispelled day when written in english
:return: `None` if the day was not modified, the new date otherwise
"""
- 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__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __call__(self, units=1, waits=True, context=None):
"""To be called before consuming a resource that is subject to rate-limits.
:param units:
Number of units consumed by the API call that is about to be made.
- 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"