File json_validation.py
has 380 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- encoding: utf-8 -*-
"""Tools for performing validations based on json schemas"""
import os
Function _map_refs
has a Cognitive Complexity of 34 (exceeds 10 allowed). Consider refactoring. Open
def _map_refs(node: dict, on_refs: Callable[[str], dict]) -> dict:
"""
Apply `on_refs` to all nodes with `$ref`, returning node with refs replaced
with results of the function call.
- 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_values_for_path_pattern
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
def _get_values_for_path_pattern(self, path: str, doc: dict) -> set:
"""
Search `doc` for every value matching `path`, and return those values as a set.
Path can contain wildcards (e.g., `/my/path/*/with/wildcard/*/hooray`) but partial
- 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 validate_instance
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def validate_instance(instance: str, schema: dict, is_required=False) -> Optional[str]:
"""
Validate a data instance against a JSON schema.
Returns None if `instance` is valid, otherwise returns reason for invalidity.
- 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"