Function to_dict
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def to_dict(self, recurse=True):
"""
Convert the current schema to a `dict`.
"""
# start with existing fields
- 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
Schema
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class Schema(object): # pragma: no cover
"""
Basic schema generator class. Schema objects can be loaded up
with existing schemas and objects before being serialized.
"""
Function add_schema
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_schema(self, schema):
"""
Merges in an existing schema.
arguments:
* `schema` (required - `dict` or `Schema`):
- 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 _add_type
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _add_type(self, val_type):
if isinstance(val_type, (str, dict)):
if val_type not in self._type:
self._type.append(val_type)
elif isinstance(val_type, 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
Avoid deeply nested control flow statements. Open
if isinstance(it, dict):
res["anyOf"].append(it)
else:
res["anyOf"].append({'type': it})
properties[key_prop] = res