eugene-matvejev/battleship-game-api

View on GitHub
tests/phpunit/GameBundle/Service/CoordinateSystem/PathProcessorTest.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method AdjacentCellsProvider has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function AdjacentCellsProvider() : array
    {

        $battlefield = MockFactory::getBattlefieldMock();
        $battlefield->getCellByCoordinate('A2')->setFlags(CellModel::FLAG_DEAD);

    Method getAdjacentCells has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function getAdjacentCells(string $initCoordinate, array $expectedCoordinates, Battlefield $battlefield, int $levels, int $onlyFlag, int $excludeFlag)
    Severity: Minor
    Found in tests/phpunit/GameBundle/Service/CoordinateSystem/PathProcessorTest.php - About 45 mins to fix

      Avoid using static access to class '\EM\Tests\Environment\Factory\MockFactory' in method 'AdjacentCellsProvider'.
      Open

              $battlefield = MockFactory::getBattlefieldMock();

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class '\EM\Tests\Environment\Factory\MockFactory' in method 'AdjacentCellsProvider'.
      Open

                      MockFactory::getBattlefieldMock(),

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class '\EM\Tests\Environment\Factory\MockFactory' in method 'AdjacentCellsProvider'.
      Open

                      MockFactory::getBattlefieldMock(),

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Method name "PathProcessorTest::AdjacentCellsProvider" is not in camel caps format
      Open

          public function AdjacentCellsProvider() : array

      Line exceeds 120 characters; contains 131 characters
      Open

           * extended paths list contains all paths from @see PathProcessor::$primaryPaths and 4 additional paths: (LEFT|RIGHT)-(UP|DOWN)

      Line exceeds 120 characters; contains 160 characters
      Open

          public function getAdjacentCells(string $initCoordinate, array $expectedCoordinates, Battlefield $battlefield, int $levels, int $onlyFlag, int $excludeFlag)

      The method AdjacentCellsProvider is not named in camelCase.
      Open

          public function AdjacentCellsProvider() : array
          {
      
              $battlefield = MockFactory::getBattlefieldMock();
              $battlefield->getCellByCoordinate('A2')->setFlags(CellModel::FLAG_DEAD);

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      There are no issues that match your filters.

      Category
      Status