darthdeus/bopt

View on GitHub
bopt/experiment.py

Summary

Maintainability
D
1 day
Test Coverage

Function collect_results has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

    def collect_results(self) -> None:
        # TODO: collect run time + check collected_at

        for sample in self.samples:
            if sample.collect_flag == CollectFlag.WAITING_FOR_SIMILAR:
Severity: Minor
Found in bopt/experiment.py - About 6 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

File experiment.py has 304 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import math
import yaml
import os
import re
import pathlib
Severity: Minor
Found in bopt/experiment.py - About 3 hrs to fix

    Function manual_run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def manual_run(self, hyperparam_values: HyperparamValues,
                       model_params: ModelParameters) -> Tuple[Sample, bool]:
            assert isinstance(hyperparam_values, HyperparamValues)
    
            output_dir_path = pathlib.Path("output")
    Severity: Minor
    Found in bopt/experiment.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

                            with open(fname, "r") as f:
                                contents = f.read().rstrip("\n")
                                found = False
    
                                for line in contents.split("\n"):
    Severity: Major
    Found in bopt/experiment.py - About 45 mins to fix

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

          def __init__(self, task_name: str, batch_name: Optional[str],
      Severity: Minor
      Found in bopt/experiment.py - About 45 mins to fix

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

            def from_dict(data: dict) -> "Experiment":
                hyperparameters = \
                    [Hyperparameter.from_dict(key, data["hyperparameters"][key])
                     for key in data["hyperparameters"].keys()]
        
        
        Severity: Minor
        Found in bopt/experiment.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

        TODO found
        Open

                            # TODO: gpy pouzito na 2 mistech?
        Severity: Minor
        Found in bopt/experiment.py by fixme

        TODO found
        Open

                # TODO: finished samples only?
        Severity: Minor
        Found in bopt/experiment.py by fixme

        TODO found
        Open

                # TODO: overit, ze by to fungovalo i na ok+running a mean_pred
        Severity: Minor
        Found in bopt/experiment.py by fixme

        TODO found
        Open

        # TODO: set this at a proper global place
        Severity: Minor
        Found in bopt/experiment.py by fixme

        XXX found
        Open

                    data["task_name"] = "XXX"
        Severity: Minor
        Found in bopt/experiment.py by fixme

        XXX found
        Open

                    data["batch_name"] = "XXX"
        Severity: Minor
        Found in bopt/experiment.py by fixme

        TODO found
        Open

                # TODO: remove once the new implementation is tested
        Severity: Minor
        Found in bopt/experiment.py by fixme

        TODO found
        Open

                        # TODO: opravit:
        Severity: Minor
        Found in bopt/experiment.py by fixme

        TODO found
        Open

                # TODO: collect run time + check collected_at
        Severity: Minor
        Found in bopt/experiment.py by fixme

        There are no issues that match your filters.

        Category
        Status