Aerendir/then-when

View on GitHub

Showing 5 of 7 total issues

Function try has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function try(callable $callback)
    {
        try {
            return \call_user_func($callback);
        } catch (\Throwable $throwable) {
Severity: Minor
Found in src/TryAgain.php - 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

Method try has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function try(callable $callback)
    {
        try {
            return \call_user_func($callback);
        } catch (\Throwable $throwable) {
Severity: Minor
Found in src/TryAgain.php - About 1 hr to fix

    Function __construct has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __construct(int $maxAttempts, \DateTimeInterface $endOfTimeWindow, ?string $timeUnit = null)
        {
            $incrementBy = 1;
            // $endOfTime can be only an integer or a \DateTime
            if (false === \is_int($endOfTimeWindow) && false === $endOfTimeWindow instanceof \DateTime) {
    Severity: Minor
    Found in src/Strategy/TimeFixedStrategy.php - About 45 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

    Avoid too many return statements within this method.
    Open

                    return $increment;
    Severity: Major
    Found in src/Strategy/AbstractStrategy.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return $increment * 60;
      Severity: Major
      Found in src/Strategy/AbstractStrategy.php - About 30 mins to fix
        Severity
        Category
        Status
        Source
        Language