Finesse/Wired

View on GitHub
src/Helpers.php

Summary

Maintainability
B
6 hrs
Test Coverage

Function filterModelRelatives has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public static function filterModelRelatives(ModelInterface $model, string $relation, callable $filter)
    {
        if (!$model->doesHaveLoadedRelatives($relation)) {
            return;
        }
Severity: Minor
Found in src/Helpers.php - 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

Method filterModelRelatives has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function filterModelRelatives(ModelInterface $model, string $relation, callable $filter)
    {
        if (!$model->doesHaveLoadedRelatives($relation)) {
            return;
        }
Severity: Minor
Found in src/Helpers.php - About 1 hr to fix

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

        public static function collectModelsRelatives(array $models, string $relation): array
        {
            $modelsSet = new \SplObjectStorage;
            foreach ($models as $model) {
                $modelsSet->attach($model);
    Severity: Minor
    Found in src/Helpers.php - 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 wrapException has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function wrapException(\Throwable $exception): \Throwable
        {
            if ($exception instanceof ExceptionInterface) {
                return $exception;
            }
    Severity: Minor
    Found in src/Helpers.php - 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 collectModelsCyclicRelatives has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function collectModelsCyclicRelatives(array $models, string $relation): array
        {
            // The goal is to track the list of unique models
            // We can't index the relatives list by models identifiers because a model can have no identifier
            // Using SplObjectStorage is the faster than using in_array or spl_object_hash: https://3v4l.org/h6YA6
    Severity: Minor
    Found in src/Helpers.php - 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

    Avoid too many return statements within this method.
    Wontfix

            return $exception;
    Severity: Major
    Found in src/Helpers.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Wontfix

                      return new DatabaseException($exception->getMessage(), $exception->getCode(), $exception);
      Severity: Major
      Found in src/Helpers.php - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status