File abstract.py
has 381 lines of code (exceeds 250 allowed). Consider refactoring. Open
import abc
import logging
import pathlib
import sys
import warnings
AbstractAPI
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class AbstractAPI(metaclass=AbstractAPIMeta):
"""
Defines an abstract interface for a Swagger API
"""
Function add_paths
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def add_paths(self, paths=None):
"""
Adds the paths defined in the specification as endpoints
:type paths: list
- 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 13 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, specification, base_path=None, arguments=None,
Function _response_from_handler
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def _response_from_handler(cls, response, mimetype, extra_context=None):
"""
Create a framework response from the operation handler data.
An operation handler can return:
- a framework response
- 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_body_and_status_code
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _prepare_body_and_status_code(cls, data, mimetype, status_code=None, extra_context=None):
if data is NoContent:
data = None
if status_code is 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 _build_response
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _build_response(cls, data, mimetype, content_type=None, status_code=None, headers=None, extra_context=None):
Function _serialize_data
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _serialize_data(cls, data, mimetype):
# TODO: Harmonize with flask_api. Currently this is the backwards compatible with aiohttp_api._cast_body.
if not isinstance(data, bytes):
if isinstance(mimetype, str) and is_json_mimetype(mimetype):
body = cls.jsonifier.dumps(data)
- 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 cls._build_response(mimetype=mimetype, data=response, extra_context=extra_context)
Avoid too many return
statements within this function. Open
return cls._build_response(mimetype=mimetype, data=data, status_code=status_code, headers=headers, extra_context=extra_context)