eager-dev/eagerx

View on GitHub
eagerx/core/space.py

Summary

Maintainability
C
7 hrs
Test Coverage
A
90%

Consider simplifying this complex logical expression.
Open

        if shape is not None:
            shape = tuple(shape)
            assert low is None or np.isscalar(low) or low.shape == shape, "low.shape doesn't match provided shape"
            assert high is None or np.isscalar(high) or high.shape == shape, "high.shape doesn't match provided shape"
        elif low is not None and not np.isscalar(low):
Severity: Critical
Found in eagerx/core/space.py - About 2 hrs to fix

    Function __init__ has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(
            self,
            low: t.Optional[t.Union[t.List, np.ndarray, int, float, bool, t.Tuple]] = None,
            high: t.Optional[t.Union[t.List, np.ndarray, int, float, bool, t.Tuple]] = None,
            shape: t.Optional[t.Tuple] = None,
    Severity: Minor
    Found in eagerx/core/space.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

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

        def to_dict(self) -> t.Dict:
            """Convert the space to a dict representation
    
            :return: Dict representation of the space.
            """
    Severity: Minor
    Found in eagerx/core/space.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

    Consider simplifying this complex logical expression.
    Open

            if self._space is None:
                return (
                    isinstance(other, Space)
                    and other._space is None
                    and (self.shape == other.shape)
    Severity: Major
    Found in eagerx/core/space.py - About 1 hr to fix

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

          def __eq__(self, other):
              if self._space is None:
                  return (
                      isinstance(other, Space)
                      and other._space is None
      Severity: Minor
      Found in eagerx/core/space.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

      There are no issues that match your filters.

      Category
      Status