Showing 62 of 111 total issues
Function check_type
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def check_type(value, type_def):
"""Check if the value is in the type given in type_def.
Args:
value: the var to test.
type_def: string representing the type in swagger.
- Read upRead up
- Create a ticketCreate a ticket
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_one_definition_example
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def build_one_definition_example(self, def_name):
"""Build the example for the given definition.
Args:
def_name: Name of the definition.
Returns:
- Read upRead up
- Create a ticketCreate a ticket
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 'type' in spec['schema'].keys() and spec['schema']['type'] == 'array':
# It is an array
# Get value from definition
if '$ref' in spec['schema']['items']:
definition_name = self.get_definition_name_from_ref(spec['schema']
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if len(body) > 0 and not self.validate_definition(definition_name, body[0]):
msg = "The body did not validate against its definition"
return False, msg
elif ('type' in param_spec['schema'].keys() and not
- Create a ticketCreate a ticket
Function validate_request
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_request(self, path, action, body=None, query=None):
"""Check if the given request is valid.
Validates the body and the query
# Rules to validate the BODY:
# Let's limit this to mime types that either contain 'text' or 'json'
- Read upRead up
- Create a ticketCreate a ticket
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 not self.validate_definition(definition_name, body):
msg = "The body did not validate against its definition"
return False, msg
# Check required
if not all(param in processed_params for param, spec in action_spec['parameters'].items()
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
for i in param_value: # Check type of all elements in array
if not self.check_type(i, action_spec['parameters'][param_name]['items']['type']):
return False
- Create a ticketCreate a ticket
Function get_dict_definition
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_dict_definition(self, dict, get_list=False):
"""Get the definition name of the given dict.
Args:
dict: dict to test.
get_list: if set to true, return a list of definition that match the body.
- Read upRead up
- Create a ticketCreate a ticket
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 self._example_from_array_spec(prop_spec)
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return True
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return False
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return True
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return self.get_example_from_prop_spec(prop_spec['schema'])
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return False
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return True, ""
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return self._get_example_from_basic_type(prop_spec['type'][0])[0]
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return False, msg
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return True, ""
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return self._get_example_from_basic_type(prop_spec['type'])[0]
- Create a ticketCreate a ticket