mike0sv/pyjackson

View on GitHub

Showing 163 of 163 total issues

Function _construct_from_list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def _construct_from_list(obj, as_class):
    args = []
    if type_field_position_is(as_class, Position.INSIDE):
        obj = obj[1:]
    for i, f in enumerate(get_class_fields(as_class)):
Severity: Minor
Found in src/pyjackson/deserialization.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 _serialize_to_dict has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def _serialize_to_dict(cls, obj):
    result = {}
    fields = get_class_fields(cls)
    for f in fields:
        name = f.name
Severity: Minor
Found in src/pyjackson/serialization.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_type_name_repr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_type_name_repr(cls):
    if is_generic(cls):
        typename = getattr(cls, '_name', str(cls.__origin__))
        if typename.startswith('typing.'):
            typename = typename[len('typing.'):]
Severity: Minor
Found in src/pyjackson/_typing_utils.py - About 45 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 _argspec_to_fields has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def _argspec_to_fields(f, arguments, defaults, hints, types_required=True) -> typing.List[Field]:
Severity: Minor
Found in src/pyjackson/utils.py - About 35 mins to fix

    Function _get_defining_class has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _get_defining_class(cls, method, method_name=None, mro=None, stop_class=None):
    Severity: Minor
    Found in src/pyjackson/generics.py - About 35 mins to fix

      Function _construct_object has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def _construct_object(obj, as_class: Type):
          if isinstance(as_class, Hashable) and as_class in SERIALIZER_MAPPING:
              as_class = SERIALIZER_MAPPING[as_class]
      
          if issubclass(as_class, StaticSerializer):
      Severity: Minor
      Found in src/pyjackson/deserialization.py - About 35 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 _argspec_to_fields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def _argspec_to_fields(f, arguments, defaults, hints, types_required=True) -> typing.List[Field]:
          defaults_num = len(defaults) if defaults is not None else 0
          non_defaults_num = len(arguments) - defaults_num
          fields = []
          for i, arg in enumerate(arguments):
      Severity: Minor
      Found in src/pyjackson/utils.py - About 35 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

      Avoid too many return statements within this function.
      Open

          return _serialize_as_type(obj, as_class)
      Severity: Major
      Found in src/pyjackson/serialization.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return seq_type([deserialize(o, seq_int_type) for o in obj])
        Severity: Major
        Found in src/pyjackson/deserialization.py - About 30 mins to fix

          Function __new__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def __new__(cls, **kwargs):
                  has_init = issubclass(_get_defining_class(cls, cls.__init__), Serializer)
                  if getattr(cls, '_dynamic', False):
                      if has_init:
                          cls.__init__(cls, **kwargs)
          Severity: Minor
          Found in src/pyjackson/generics.py - About 25 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

          Line too long (93 > 79 characters)
          Open

          new_other_container = deserialize(other_payload, OtherContainer)  # OtherContainer([2, 2, 2])
          Severity: Minor
          Found in examples/custom_serialization.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (83 > 79 characters)
          Open

              """:class:`~pyjackson.generics.StaticSerializer` for :class:`uuid.UUID` type"""
          Severity: Minor
          Found in src/pyjackson/builtin_types.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (84 > 79 characters)
          Open

                      args = ','.join('{}={}'.format(key, getattr(self, key)) for key in flds)
          Severity: Minor
          Found in src/pyjackson/decorators.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (95 > 79 characters)
          Open

          from pyjackson.generics import SERIALIZER_MAPPING, Serializer, SerializerType, StaticSerializer
          Severity: Minor
          Found in src/pyjackson/deserialization.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (98 > 79 characters)
          Open

                              f'mapping key type must be one of {SERIALIZABLE_DICT_TYPES}, not {key_type}. '
          Severity: Minor
          Found in src/pyjackson/deserialization.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (110 > 79 characters)
          Open

              return is_generic37(as_class) and any(issubclass(as_class.__origin__, t) for t in _collection_types) and \
          Severity: Minor
          Found in src/pyjackson/_typing_utils37.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (87 > 79 characters)
          Open

              new_types = tuple(_substitute_nested_type(t, polymorphism) for t in type_.__args__)
          Severity: Minor
          Found in src/pyjackson/pydantic_ext.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (97 > 79 characters)
          Open

              return cls == typing.Union or (hasattr(cls, '__origin__') and cls.__origin__ == typing.Union)
          Severity: Minor
          Found in src/pyjackson/_typing_utils37.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (92 > 79 characters)
          Open

                  subtype_models: Dict[str, Type[BaseModel]] = namespace.pop('__subtype_models__', {})
          Severity: Minor
          Found in src/pyjackson/pydantic_ext.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (109 > 79 characters)
          Open

                     'type_field_position_is', 'resolve_subtype', 'Comparable', 'get_tuple_internal_types', 'is_tuple',
          Severity: Minor
          Found in src/pyjackson/utils.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.
          Severity
          Category
          Status
          Source
          Language