artur-deluca/psopt

View on GitHub

Showing 5 of 5 total issues

File optimizer.py has 299 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import functools
import inspect
import random
import time
import typing
Severity: Minor
Found in psopt/commons/optimizer.py - About 3 hrs to fix

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

        def _optimize(self):
    
            start = time.time()
            if not self._n_jobs or self._n_jobs > 1:
                pool = multiprocess.Pool(self._n_jobs)
    Severity: Minor
    Found in psopt/commons/optimizer.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 _set_params has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _set_params(self, selection_size, f_min, verbose, **kwargs):
    
            # Set optimizer logger
            self._logger = make_logger(__name__, verbose=verbose)
    
    
    Severity: Minor
    Found in psopt/commons/optimizer.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 _unpack_metrics has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def _unpack_metrics(selected_metrics: M) -> typing.Dict[typing.Text, typing.Callable]:
    
        metrics_dict = dict()
    
        if isinstance(selected_metrics, str):
    Severity: Minor
    Found in psopt/utils/metrics.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

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

        def _update_best(self):
    
            # For early stopping use
            last_best_position = list(self._global_best[-2]["position"])
    
    
    Severity: Minor
    Found in psopt/commons/optimizer.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

    Severity
    Category
    Status
    Source
    Language