darthdeus/bopt

View on GitHub
bopt/cli/web.py

Summary

Maintainability
D
2 days
Test Coverage

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

def run(web_type, args) -> None:
    script_dir = os.path.dirname(os.path.abspath(inspect.stack()[0][1]))

    app = Flask(__name__, template_folder=os.path.join(script_dir, "..", "templates"))
    app.debug = True
Severity: Minor
Found in bopt/cli/web.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 web.py has 290 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import inspect
import os
from collections import defaultdict
import math
import logging
Severity: Minor
Found in bopt/cli/web.py - About 2 hrs to fix

    Function create_slice_2d has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_slice_2d(i: int, j: int, experiment: bopt.Experiment,
                        resolution: int, n_dims: int, x_slice: List[float], model: GPy.models.GPRegression,
                        sample: bopt.Sample, show_marginal: int) -> Slice2D:
    
        p1 = experiment.hyperparameters[i]
    Severity: Minor
    Found in bopt/cli/web.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 create_slice_1d has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_slice_1d(i: int, experiment: bopt.Experiment, resolution: int,
                        n_dims: int, x_slice: List[float], model: GPy.models.GPRegression, sample: bopt.Sample,
                        show_marginal: int) -> Slice1D:
        param = experiment.hyperparameters[i]
    
    
    Severity: Minor
    Found in bopt/cli/web.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,
    Severity: Major
    Found in bopt/cli/web.py - About 1 hr to fix

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

      def create_slice_2d(i: int, j: int, experiment: bopt.Experiment,
      Severity: Major
      Found in bopt/cli/web.py - About 1 hr to fix

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

            def __init__(self, param: bopt.Hyperparameter, x: List[float],
        Severity: Major
        Found in bopt/cli/web.py - About 1 hr to fix

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

          def create_slice_1d(i: int, experiment: bopt.Experiment, resolution: int,
          Severity: Major
          Found in bopt/cli/web.py - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                                    if i == j:
                                        slices_1d.append(create_slice_1d(i, experiment,
                                            resolution, n_dims, x_slice, model, sample, show_marginal))
            
                                    elif i < j:
            Severity: Major
            Found in bopt/cli/web.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      for v, h in zip(value, experiment.hyperparameters):
                                          kernel_param_timeline["{}_{}".format(key, h.name)].append(v)
                                  else:
              Severity: Major
              Found in bopt/cli/web.py - About 45 mins to fix

                TODO found
                Open

                            # TODO: zbytek asi neni potreba mit pod lockem, ale pak nejde
                Severity: Minor
                Found in bopt/cli/web.py by fixme

                There are no issues that match your filters.

                Category
                Status