zalando/connexion

View on GitHub

Showing 149 of 149 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        super(Swagger2Operation, self).__init__(
Severity: Major
Found in connexion/operations/swagger2.py and 1 other location - About 2 hrs to fix
connexion/operations/openapi.py on lines 75..75

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 55.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        super(OpenAPIOperation, self).__init__(
Severity: Major
Found in connexion/operations/openapi.py and 1 other location - About 2 hrs to fix
connexion/operations/swagger2.py on lines 82..82

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 55.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function run has 19 arguments (exceeds 4 allowed). Consider refactoring.
Open

def run(spec_file,
Severity: Major
Found in connexion/cli.py - About 2 hrs to fix

    File swagger2.py has 265 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import logging
    from copy import deepcopy
    
    from connexion.operations.abstract import AbstractOperation
    
    
    Severity: Minor
    Found in connexion/operations/swagger2.py - About 2 hrs to fix

      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
      Severity: Minor
      Found in connexion/apis/abstract.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

      File flask_api.py has 259 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import logging
      import warnings
      
      import flask
      import werkzeug.exceptions
      Severity: Minor
      Found in connexion/apis/flask_api.py - About 2 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        def delete(id_):
            id_ = int(id_)
            if pets.get(id_) is None:
                return NoContent, 404
            del pets[id_]
        Severity: Major
        Found in examples/openapi3/restyresolver/api/pets.py and 1 other location - About 2 hrs to fix
        examples/swagger2/restyresolver/api/pets.py on lines 25..30

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 52.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        def delete(id):
            id = int(id)
            if pets.get(id) is None:
                return NoContent, 404
            del pets[id]
        Severity: Major
        Found in examples/swagger2/restyresolver/api/pets.py and 1 other location - About 2 hrs to fix
        examples/openapi3/restyresolver/api/pets.py on lines 34..39

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 52.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    if path_schema.get('type') == 'string' and path_schema.get('format') == 'path':
                        # path is special case for type 'string'
                        path_type = 'path'
                    else:
                        path_type = path_schema.get('type')
        Severity: Major
        Found in connexion/operations/openapi.py and 1 other location - About 2 hrs to fix
        connexion/operations/swagger2.py on lines 156..160

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 50.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    if path_defn.get('type') == 'string' and path_defn.get('format') == 'path':
                        # path is special case for type 'string'
                        path_type = 'path'
                    else:
                        path_type = path_defn.get('type')
        Severity: Major
        Found in connexion/operations/swagger2.py and 1 other location - About 2 hrs to fix
        connexion/operations/openapi.py on lines 237..241

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 50.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function _get_body_argument has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def _get_body_argument(self, body, arguments, has_kwargs, sanitize):
                kwargs = {}
                body_parameters = [p for p in self.parameters if p['in'] == 'body'] or [{}]
                if body is None:
                    body = deepcopy(body_parameters[0].get('schema', {}).get('default'))
        Severity: Minor
        Found in connexion/operations/swagger2.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 resolve_refs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def resolve_refs(spec, store=None, handlers=None):
            """
            Resolve JSON references like {"$ref": <some URI>} in a spec.
            Optionally takes a store, which is a mapping from reference URLs to a
            dereferenced objects. Prepopulating the store can avoid network calls.
        Severity: Minor
        Found in connexion/json_schema.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 __init__ has 15 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, api, method, path, operation, resolver, path_parameters=None,
        Severity: Major
        Found in connexion/operations/openapi.py - About 1 hr to fix

          Function get_function_from_name has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          def get_function_from_name(function_name):
              """
              Tries to get function by fully qualified name (e.g. "mymodule.myobj.myfunc")
          
              :type function_name: str
          Severity: Minor
          Found in connexion/utils.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 __init__ has 14 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, api, method, path, operation, resolver,
          Severity: Major
          Found in connexion/operations/abstract.py - About 1 hr to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            def get(petId):
                id_ = int(petId)
                if pets.get(id_) is None:
                    return NoContent, 404
                return pets[id_]
            Severity: Major
            Found in examples/openapi3/restyresolver/api/pets.py and 1 other location - About 1 hr to fix
            examples/swagger2/restyresolver/api/pets.py on lines 33..38

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 46.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            def get(id):
                id = int(id)
                if pets.get(id) is None:
                    return NoContent, 404
            
            
            Severity: Major
            Found in examples/swagger2/restyresolver/api/pets.py and 1 other location - About 1 hr to fix
            examples/openapi3/restyresolver/api/pets.py on lines 42..46

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 46.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function __init__ has 13 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self, specification, base_path=None, arguments=None,
            Severity: Major
            Found in connexion/apis/abstract.py - About 1 hr to fix

              Function __init__ has 13 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, import_name, api_cls, port=None, specification_dir='',
              Severity: Major
              Found in connexion/apps/abstract.py - About 1 hr to fix

                Function run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                def run(spec_file,
                        base_module_path,
                        port,
                        host,
                        wsgi_server,
                Severity: Minor
                Found in connexion/cli.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

                Severity
                Category
                Status
                Source
                Language