takuseno/d3rlpy

View on GitHub
d3rlpy/dataset/io.py

Summary

Maintainability
B
5 hrs
Test Coverage

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

def load(episode_cls: Type[_TEpisode], f: BinaryIO) -> Sequence[_TEpisode]:
    r"""Constructs episodes from file-like object.

    Args:
        episode_cls: Episode class.
Severity: Minor
Found in d3rlpy/dataset/io.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 dump has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def dump(episodes: Sequence[EpisodeBase], f: BinaryIO) -> None:
    r"""Writes episode data to file-like object.

    Args:
        episodes: Sequence of episodes.
Severity: Minor
Found in d3rlpy/dataset/io.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

Avoid deeply nested control flow statements.
Open

                    while True:
                        tuple_path = f"{key}_{i}_{j}"
                        if tuple_path in h5:
                            tuple_data.append(h5[tuple_path][()])
                        else:
Severity: Major
Found in d3rlpy/dataset/io.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        for j in range(len(serializedData[key])):
                            elm = serializedData[key][j]
                            h5.create_dataset(f"{key}_{i}_{j}", data=elm)
                    else:
    Severity: Major
    Found in d3rlpy/dataset/io.py - About 45 mins to fix

      There are no issues that match your filters.

      Category
      Status