apparat/object

View on GitHub
src/Object/Tests/RepositoryTest.php

Summary

Maintainability
C
1 day
Test Coverage

File RepositoryTest.php has 268 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * apparat-object
 *
Severity: Minor
Found in src/Object/Tests/RepositoryTest.php - About 2 hrs to fix

    RepositoryTest has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class RepositoryTest extends AbstractDisabledAutoconnectorTest
    {
        /**
         * Temporary glob directory
         *
    Severity: Minor
    Found in src/Object/Tests/RepositoryTest.php - About 2 hrs to fix

      Method setUpBeforeClass has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function setUpBeforeClass()
          {
              parent::setUpBeforeClass();
              self::$globDirs[] =
              self::$globBase = sys_get_temp_dir().DIRECTORY_SEPARATOR.'glob';
      Severity: Minor
      Found in src/Object/Tests/RepositoryTest.php - About 1 hr to fix

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

            public static function setUpBeforeClass()
            {
                parent::setUpBeforeClass();
                self::$globDirs[] =
                self::$globBase = sys_get_temp_dir().DIRECTORY_SEPARATOR.'glob';
        Severity: Minor
        Found in src/Object/Tests/RepositoryTest.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

        Avoid using Apparat\Object\Tests\count() function in while loops.
        Open

                        while (count($days) < 3) {
                            $day = rand(1, date('t', mktime(0, 0, 0, $month, 1, $year)));
                            $days[$day] = $day;
                        }
        Severity: Minor
        Found in src/Object/Tests/RepositoryTest.php by phpmd

        CountInLoopExpression

        Since: 2.7.0

        Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

        Example

        class Foo {
        
          public function bar()
          {
            $array = array();
        
            for ($i = 0; count($array); $i++) {
              // ...
            }
          }
        }

        Source https://phpmd.org/rules/design.html#countinloopexpression

        There are no issues that match your filters.

        Category
        Status