zalando/connexion

View on GitHub

Showing 149 of 149 total issues

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

def get_pets(limit, animal_type=None):
    q = db_session.query(orm.Pet)
    if animal_type:
        q = q.filter(orm.Pet.animal_type == animal_type)
    return [p.dump() for p in q][:limit]
Severity: Major
Found in examples/openapi3/sqlalchemy/app.py and 1 other location - About 3 hrs to fix
examples/swagger2/sqlalchemy/app.py on lines 13..17

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 68.

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

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

def get_pets(limit, animal_type=None):
    q = db_session.query(orm.Pet)
    if animal_type:
        q = q.filter(orm.Pet.animal_type == animal_type)
    return [p.dump() for p in q][:limit]
Severity: Major
Found in examples/swagger2/sqlalchemy/app.py and 1 other location - About 3 hrs to fix
examples/openapi3/sqlalchemy/app.py on lines 13..17

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 68.

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

File openapi.py has 310 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
from copy import copy, deepcopy

from connexion.operations.abstract import AbstractOperation

Severity: Minor
Found in connexion/operations/openapi.py - About 3 hrs to fix

    File security_handler_factory.py has 296 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import abc
    import base64
    import functools
    import logging
    import os
    Severity: Minor
    Found in connexion/security/security_handler_factory.py - About 3 hrs to fix

      Function parameter_to_arg has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      def parameter_to_arg(operation, function, pythonic_params=False,
                           pass_context_arg_name=None):
          """
          Pass query and body parameters as keyword arguments to handler function.
      
      
      Severity: Minor
      Found in connexion/decorators/parameter.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

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

                      elif scheme == 'bearer':
                          bearer_info_func = self._api.security_handler_factory.get_bearerinfo_func(security_scheme)
                          if not bearer_info_func:
                              logger.warning("... x-bearerInfoFunc missing", extra=vars(self))
                              continue
      Severity: Major
      Found in connexion/operations/secure.py and 3 other locations - About 2 hrs to fix
      connexion/operations/secure.py on lines 98..104
      connexion/operations/secure.py on lines 109..115
      connexion/operations/secure.py on lines 127..132

      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 61.

      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 4 locations. Consider refactoring.
      Open

                  elif security_scheme['type'] == 'basic':
                      basic_info_func = self._api.security_handler_factory.get_basicinfo_func(security_scheme)
                      if not basic_info_func:
                          logger.warning("... x-basicInfoFunc missing", extra=vars(self))
                          continue
      Severity: Major
      Found in connexion/operations/secure.py and 3 other locations - About 2 hrs to fix
      connexion/operations/secure.py on lines 109..115
      connexion/operations/secure.py on lines 116..121
      connexion/operations/secure.py on lines 127..132

      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 61.

      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 4 locations. Consider refactoring.
      Open

                      if scheme == 'basic':
                          basic_info_func = self._api.security_handler_factory.get_basicinfo_func(security_scheme)
                          if not basic_info_func:
                              logger.warning("... x-basicInfoFunc missing", extra=vars(self))
                              continue
      Severity: Major
      Found in connexion/operations/secure.py and 3 other locations - About 2 hrs to fix
      connexion/operations/secure.py on lines 98..104
      connexion/operations/secure.py on lines 116..121
      connexion/operations/secure.py on lines 127..132

      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 61.

      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 4 locations. Consider refactoring.
      Open

                      if scheme == 'bearer':
                          bearer_info_func = self._api.security_handler_factory.get_bearerinfo_func(security_scheme)
                          if not bearer_info_func:
                              logger.warning("... x-bearerInfoFunc missing", extra=vars(self))
                              continue
      Severity: Major
      Found in connexion/operations/secure.py and 3 other locations - About 2 hrs to fix
      connexion/operations/secure.py on lines 98..104
      connexion/operations/secure.py on lines 109..115
      connexion/operations/secure.py on lines 116..121

      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 61.

      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

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

      def get_pet(pet_id):
          pet = db_session.query(orm.Pet).filter(orm.Pet.id == pet_id).one_or_none()
          return pet.dump() if pet is not None else ('Not found', 404)
      Severity: Major
      Found in examples/swagger2/sqlalchemy/app.py and 1 other location - About 2 hrs to fix
      examples/openapi3/sqlalchemy/app.py on lines 20..22

      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 61.

      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

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

      def get_pet(pet_id):
          pet = db_session.query(orm.Pet).filter(orm.Pet.id == pet_id).one_or_none()
          return pet.dump() if pet is not None else ('Not found', 404)
      Severity: Major
      Found in examples/openapi3/sqlalchemy/app.py and 1 other location - About 2 hrs to fix
      examples/swagger2/sqlalchemy/app.py on lines 20..22

      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 61.

      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

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

              try:
                  return self.function_resolver(operation_id)
              except ImportError as e:
                  msg = 'Cannot resolve operationId "{}"! Import error was "{}"'.format(operation_id, str(e))
                  raise ResolverError(msg, sys.exc_info())
      Severity: Major
      Found in connexion/resolver.py and 1 other location - About 2 hrs to fix
      connexion/resolver.py on lines 180..198

      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 60.

      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

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

              try:
                  module_name, view_name, meth_name = operation_id.rsplit('.', 2)
                  if operation_id and not view_name.endswith('View'):
                      # If operation_id is not a view then assume it is a standard function
                      return self.function_resolver(operation_id)
      Severity: Major
      Found in connexion/resolver.py and 1 other location - About 2 hrs to fix
      connexion/resolver.py on lines 60..66

      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 60.

      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

      AbstractSecurityHandlerFactory has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class AbstractSecurityHandlerFactory(abc.ABC):
          """
          get_*_func -> _get_function -> get_function_from_name (name=security function defined in spec)
              (if url defined instead of a function -> get_token_info_remote)
      
      
      Severity: Minor
      Found in connexion/security/security_handler_factory.py - About 2 hrs to fix

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

                if query_schema["type"] == "array":
                    return [make_type(part, query_defn["items"]["type"]) for part in value]
                else:
                    return make_type(value, query_defn["type"])
        Severity: Major
        Found in connexion/operations/swagger2.py and 1 other location - About 2 hrs to fix
        connexion/operations/openapi.py on lines 377..380

        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 59.

        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 query_schema["type"] == "array":
                    return [make_type(part, query_schema["items"]["type"]) for part in value]
                else:
                    return make_type(value, query_schema["type"])
        Severity: Major
        Found in connexion/operations/openapi.py and 1 other location - About 2 hrs to fix
        connexion/operations/swagger2.py on lines 307..310

        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 59.

        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

        AbstractAPI has 24 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class AbstractAPI(metaclass=AbstractAPIMeta):
            """
            Defines an abstract interface for a Swagger API
            """
        
        
        Severity: Minor
        Found in connexion/apis/abstract.py - About 2 hrs to fix

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

              def __init__(self, api, method, path, operation, resolver, app_produces, app_consumes,
          Severity: Major
          Found in connexion/operations/swagger2.py - About 2 hrs to fix

            File uri_parsing.py has 268 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # Decorators to split query and path parameters
            import abc
            import functools
            import logging
            import re
            Severity: Minor
            Found in connexion/decorators/uri_parsing.py - About 2 hrs to fix

              Function validate_parameter has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_parameter(parameter_type, value, param, param_name=None):
                      if value is not None:
                          if is_nullable(param) and is_null(value):
                              return
              
              
              Severity: Minor
              Found in connexion/decorators/validation.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

              Severity
              Category
              Status
              Source
              Language