kalefranz/auxlib

View on GitHub
auxlib/entity.py

Summary

Maintainability
F
4 days
Test Coverage

File entity.py has 733 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
"""
This module provides serializable, validatable, type-enforcing domain objects and data
transfer objects. It has many of the same motivations as the python
`Marshmallow <http://marshmallow.readthedocs.org/en/latest/why.html>`_ package. It is most
Severity: Major
Found in auxlib/entity.py - About 1 day to fix

    Cyclomatic complexity is too high in method __init__. (13)
    Open

        def __init__(self, **kwargs):
            for key, field in iteritems(self.__fields__):
                try:
                    setattr(self, key, kwargs[key])
                except KeyError:
    Severity: Minor
    Found in auxlib/entity.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method box. (10)
    Open

        def box(self, instance, instance_type, val):
            if val is None:
                return None
            if isinstance(val, self._type):
                return val
    Severity: Minor
    Found in auxlib/entity.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method box. (9)
    Open

        def box(self, instance, instance_type, val):
            if val is None:
                return None
            elif isinstance(val, string_types):
                raise ValidationError("Attempted to assign a string to ListField {0}"
    Severity: Minor
    Found in auxlib/entity.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method __new__. (9)
    Open

        def __new__(mcs, name, bases, dct):
            # if we're about to mask a field that's already been created with something that's
            #  not a field, then assign it to an alternate variable name
            non_field_keys = (key for key, value in iteritems(dct)
                              if not isinstance(value, Field) and not key.startswith('__'))
    Severity: Minor
    Found in auxlib/entity.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method validate. (8)
    Open

        def validate(self, instance, val):
            """
    
            Returns:
                True: if val is valid
    Severity: Minor
    Found in auxlib/entity.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method __get__. (7)
    Open

        def __get__(self, instance, instance_type):
            try:
                if instance is None:  # if calling from the class object
                    val = getattr(instance_type, KEY_OVERRIDES_MAP)[self.name]
                else:
    Severity: Minor
    Found in auxlib/entity.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

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

        def box(self, instance, instance_type, val):
            if val is None:
                return None
            if isinstance(val, self._type):
                return val
    Severity: Minor
    Found in auxlib/entity.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 a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, **kwargs):
            for key, field in iteritems(self.__fields__):
                try:
                    setattr(self, key, kwargs[key])
                except KeyError:
    Severity: Minor
    Found in auxlib/entity.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

    Cyclomatic complexity is too high in method update. (6)
    Open

        def update(self, E=None, **F):
            # D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.
            # If E present and has a .keys() method, does:     for k in E: D[k] = E[k]
            # If E present and lacks .keys() method, does:     for (k, v) in E: D[k] = v
            # In either case, this is followed by: for k in F: D[k] = F[k]
    Severity: Minor
    Found in auxlib/entity.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in class EntityEncoder. (6)
    Open

    class EntityEncoder(JSONEncoder):
        # json.dumps(obj, cls=SetEncoder)
        def default(self, obj):
            if hasattr(obj, 'dump'):
                return obj.dump()
    Severity: Minor
    Found in auxlib/entity.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method default. (6)
    Open

        def default(self, obj):
            if hasattr(obj, 'dump'):
                return obj.dump()
            elif hasattr(obj, '__json__'):
                return obj.__json__()
    Severity: Minor
    Found in auxlib/entity.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method dump. (6)
    Open

        def dump(self):
            return odict((field.name, field.dump(self, self.__class__, value))
                         for field, value in ((field, getattr(self, field.name, NULL))
                                              for field in self.__dump_fields())
                         if value is not NULL and not (value is field.default
    Severity: Minor
    Found in auxlib/entity.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method validate. (6)
    Open

        def validate(self):
            # TODO: here, validate should only have to determine if the required keys are set
            try:
                reduce(lambda _, name: getattr(self, name),
                       (name for name, field in iteritems(self.__fields__) if field.required)
    Severity: Minor
    Found in auxlib/entity.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

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

        def box(self, instance, instance_type, val):
            if val is None:
                return None
            elif isinstance(val, string_types):
                raise ValidationError("Attempted to assign a string to ListField {0}"
    Severity: Minor
    Found in auxlib/entity.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 update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def update(self, E=None, **F):
            # D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.
            # If E present and has a .keys() method, does:     for k in E: D[k] = E[k]
            # If E present and lacks .keys() method, does:     for (k, v) in E: D[k] = v
            # In either case, this is followed by: for k in F: D[k] = F[k]
    Severity: Minor
    Found in auxlib/entity.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 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, field_class, default=NULL, required=True, validation=None,
    Severity: Major
    Found in auxlib/entity.py - About 1 hr to fix

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

          def __init__(self, enum_class, default=NULL, required=True, validation=None,
      Severity: Major
      Found in auxlib/entity.py - About 1 hr to fix

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

            def __init__(self, element_type, default=NULL, required=True, validation=None,
        Severity: Major
        Found in auxlib/entity.py - About 1 hr to fix

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

              def __init__(self, default=NULL, required=True, validation=None,
          Severity: Major
          Found in auxlib/entity.py - About 1 hr to fix

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

                def __init__(self, default=NULL, required=True, validation=None,
            Severity: Major
            Found in auxlib/entity.py - About 1 hr to fix

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

                  def __get__(self, instance, instance_type):
                      try:
                          if instance is None:  # if calling from the class object
                              val = getattr(instance_type, KEY_OVERRIDES_MAP)[self.name]
                          else:
              Severity: Minor
              Found in auxlib/entity.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 __repr__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __repr__(self):
                      def _valid(key):
                          # TODO: re-enable once aliases are implemented
                          # if key.startswith('_'):
                          #     return False
              Severity: Minor
              Found in auxlib/entity.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

              Avoid too many return statements within this function.
              Open

                              return self._type(*val)
              Severity: Major
              Found in auxlib/entity.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return obj.value
                Severity: Major
                Found in auxlib/entity.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return self._type(val)
                  Severity: Major
                  Found in auxlib/entity.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return JSONEncoder.default(self, obj)
                    Severity: Major
                    Found in auxlib/entity.py - About 30 mins to fix

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

                          def validate(self, instance, val):
                              """
                      
                              Returns:
                                  True: if val is valid
                      Severity: Minor
                      Found in auxlib/entity.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

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

                          def __init__(self, element_type, default=NULL, required=True, validation=None,
                                       in_dump=True, default_in_dump=True, nullable=False, immutable=False, aliases=()):
                              self._element_type = element_type
                              super(ListField, self).__init__(default, required, validation,
                                                              in_dump, default_in_dump, nullable, immutable, aliases)
                      Severity: Major
                      Found in auxlib/entity.py and 1 other location - About 2 hrs to fix
                      auxlib/entity.py on lines 648..653

                      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 __init__(self, field_class, default=NULL, required=True, validation=None,
                                       in_dump=True, default_in_dump=True, nullable=False, immutable=False, aliases=()):
                              self._type = field_class
                              super(ComposableField, self).__init__(default, required, validation,
                                                                    in_dump, default_in_dump, nullable, immutable,
                      Severity: Major
                      Found in auxlib/entity.py and 1 other location - About 2 hrs to fix
                      auxlib/entity.py on lines 579..583

                      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

                      Do not assign a lambda expression, use a def
                      Open

                              _field_sort_key = lambda x: x[1]._order_helper
                      Severity: Minor
                      Found in auxlib/entity.py by pep8

                      Compound statements (on the same line) are generally discouraged.

                      While sometimes it's okay to put an if/for/while with a small body
                      on the same line, never do this for multi-clause statements.
                      Also avoid folding such long lines!
                      
                      Always use a def statement instead of an assignment statement that
                      binds a lambda expression directly to a name.
                      
                      Okay: if foo == 'blah':\n    do_blah_thing()
                      Okay: do_one()
                      Okay: do_two()
                      Okay: do_three()
                      
                      E701: if foo == 'blah': do_blah_thing()
                      E701: for x in lst: total += x
                      E701: while t < 10: t = delay()
                      E701: if foo == 'blah': do_blah_thing()
                      E701: else: do_non_blah_thing()
                      E701: try: something()
                      E701: finally: cleanup()
                      E701: if foo == 'blah': one(); two(); three()
                      E702: do_one(); do_two(); do_three()
                      E703: do_four();  # useless semicolon
                      E704: def f(x): return 2*x
                      E731: f = lambda x: 2*x

                      There are no issues that match your filters.

                      Category
                      Status