bilalshaikh42/OASTools

View on GitHub

Showing 62 of 111 total issues

File parser.py has 802 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" parser

:Author: Bilal Shaikh < bilalshaikh42@gmail.com >
:Date: 2019-08-29
:Copyright: 2019, Bilal Shaikh
Severity: Major
Found in oastools/parse/parser.py - About 1 day to fix

Function _example_from_array_spec has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    def _example_from_array_spec(self, prop_spec):
        """Get an example from a property specification of an array.
        Args:
            prop_spec: property specification you want an example of.
        Returns:
Severity: Minor
Found in oastools/parse/parser.py - About 4 hrs to fix

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

OASParser has 30 functions (exceeds 20 allowed). Consider refactoring.
Open

class OASParser(object):
    def __init__(self, oas_spec, use_example=True):

        self._HTTP_VERBS = set(['get', 'put', 'post', 'delete',
                                'options', 'head', 'patch'])
Severity: Minor
Found in oastools/parse/parser.py - About 3 hrs to fix

Function get_send_request_correct_body has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def get_send_request_correct_body(self, path, action):
        """Get an example body which is correct to send to the given path with the given action.
        Args:
            path: path of the request
            action: action of the request (get, post, put, delete)
Severity: Minor
Found in oastools/parse/parser.py - About 3 hrs to fix

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_body_parameters has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def _validate_body_parameters(self, body, action_spec):
        """Check the body parameter for the action specification.
        Args:
            body: body parameter to check.
            action_spec: specification of the action.
Severity: Minor
Found in oastools/parse/parser.py - About 3 hrs to fix

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_query_parameters has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def _validate_query_parameters(self, query, action_spec):
        """Check the query parameter for the action specification.
        Args:
            query: query parameter to check.
            action_spec: specification of the action.
Severity: Minor
Found in oastools/parse/parser.py - About 3 hrs to fix

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_paths_data has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def get_paths_data(self):
        # go through each path (name of path ) and pathspec (the defined path)
        for path, path_spec in self.specification['paths'].items():
            self.paths[path] = {}

Severity: Minor
Found in oastools/parse/parser.py - About 3 hrs to fix

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_paths_data has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def get_paths_data(self):
        """Get data for each paths in the swagger specification.
        Get also the list of operationId.
        """
        for path, path_spec in self.specification['paths'].items():
Severity: Minor
Found in oastools/parse/parser.py - About 3 hrs to fix

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_response_example has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def get_response_example(self, resp_spec):
        """Get a response example from a response spec.
        """

        #if resp_spec['content']['text/plain']:
Severity: Minor
Found in oastools/parse/parser.py - About 2 hrs to fix

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_example_from_prop_spec has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def get_example_from_prop_spec(self, prop_spec, from_allof=False):
        """Return an example value from a property specification.
        Args:
            prop_spec: the specification of the property.
            from_allof: whether these properties are part of an
Severity: Minor
Found in oastools/parse/parser.py - About 2 hrs to fix

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_definition has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_definition(self, definition_name, dict_to_test, definition=None):
        """Validate the given dict according to the given definition.
        Args:
            definition_name: name of the the definition.
            dict_to_test: dict to test.
Severity: Minor
Found in oastools/parse/parser.py - About 2 hrs to fix

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_path_spec has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def get_path_spec(self, path, action=None):
        """Get the specification matching with the given path.
        Args:
            path: path we want the specification.
            action: get the specification for the given action.
Severity: Minor
Found in oastools/parse/parser.py - About 1 hr to fix

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_type has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def _validate_type(self, properties_spec, value):
        """Validate the given value with the given property spec.
        Args:
            properties_dict: specification of the property to check (From definition not route).
            value: value to check.
Severity: Minor
Found in oastools/parse/parser.py - About 1 hr to fix

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 traverse has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def traverse(spec, rootpath, callback=resolve):
    if (isinstance(spec, dict)):
        for key in spec.keys():
            if key == "$ref":
                refSpec = callback(spec[key], rootpath)
Severity: Minor
Found in oastools/resolve/resolver.py - About 1 hr to fix

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 _example_from_complex_def has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def _example_from_complex_def(self, prop_spec):
        """Get an example from a property specification.
        In case there is no "type" key in the root of the dictionary.
        Args:
            prop_spec: property specification you want an example of.
Severity: Minor
Found in oastools/parse/parser.py - About 1 hr to fix

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_example_from_properties has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_example_from_properties(self, spec):
        """Get example from the properties of an object defined inline.
        Args:
            prop_spec: property specification you want an example of.
        Returns:
Severity: Minor
Found in oastools/parse/parser.py - About 1 hr to fix

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_post_body has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def _validate_post_body(actual_request_body, body_specification):
        """ returns a tuple (boolean, msg)
            to indicate whether the validation passed
            if False then msg contains the reason
            if True then msg is empty
Severity: Minor
Found in oastools/parse/parser.py - About 1 hr to fix

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_additional_properties has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_additional_properties(self, valid_response, response):
        """Validates additional properties. In additional properties, we only
           need to compare the values of the dict, not the keys
        Args:
            valid_response: An example response (for example generated in
Severity: Minor
Found in oastools/parse/parser.py - About 1 hr to fix

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 _definition_from_example has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def _definition_from_example(example):
        """Generates a swagger definition json from a given example
           Works only for simple types in the dict
        Args:
            example: The example for which we want a definition
Severity: Minor
Found in oastools/parse/parser.py - About 55 mins to fix

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_request_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get_request_data(self, path, action, body=None):
        """Get the default data and status code of the given path + action request.
        Args:
            path: path of the request.
            action: action of the request(get, post, delete...)
Severity: Minor
Found in oastools/parse/parser.py - About 55 mins to fix

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

Severity
Category
Status
Source
Language