eugene-matvejev/battleship-game-api

View on GitHub

Showing 153 of 153 total issues

Avoid using static access to class '\EM\GameBundle\Model\BattlefieldModel' in method 'getLiveCells'.
Open

        $this->assertCount(49, BattlefieldModel::getLiveCells($battlefield));

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\GameBundle\Model\BattlefieldModel' in method 'processCPUTurn'.
Open

            $cells = BattlefieldModel::getLiveCells($battlefield);

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

The method successfulInitAction_XML uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $this->assertContains((string)$cell->flags, [CellModel::FLAG_NONE, CellModel::FLAG_SHIP, CellModel::FLAG_DEAD_SHIP]);
                }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

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

            [[MockFactory::getCellMock('A1'), MockFactory::getCellMock('A2')]]

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 'setCellsOnConstruct'.
Open

        $this->iterateResponseCells(new GameTurnResponse(MockFactory::getGameMock(), $cells));

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 'attackCell'.
Open

        $cell = $this->invokeMethod(static::$ai, 'attackCell', [MockFactory::getCellMock('A1', $cellFlag)]);

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\GameBundle\Model\BattlefieldModel' in method 'buildGame'.
Open

            $this->assertTrue(BattlefieldModel::hasUnfinishedShips($battlefield));

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

Line exceeds 120 characters; contains 138 characters
Open

        static::$gameProcessor->processTurn(MockFactory::getGameResultMock()->getGame()->getBattlefields()[0]->getCellByCoordinate('A1'));

Line exceeds 120 characters; contains 140 characters
Open

            && $this->validatePlayerName($data->playerName) // will be replaced by Authorization header which will reflect Player.id content

Line exceeds 120 characters; contains 177 characters
Open

    describe('::hasUnfinishedShips - should return true if Battlefield contains cells flagged with CellModel::FLAG_SHIP and not flagged with CellModel::FLAG_DEAD', function () {

Line exceeds 120 characters; contains 128 characters
Open

        $game = $this->get('em.game_bundle.service.game_builder')->buildGame(new GameInitiationRequest($request->getContent()));

Line exceeds 120 characters; contains 139 characters
Open

            foreach ($processor->reset($cell->getCoordinate())->getAdjacentCells($battlefield, 1, 0, CellModel::FLAG_SHIP) as $waterCell) {

Line exceeds 120 characters; contains 166 characters
Open

    public function getAdjacentCells(Battlefield $battlefield, int $levels = 1, int $onlyFlag = CellModel::FLAG_NONE, int $excludeFlag = CellModel::FLAG_NONE) : array

Line exceeds 120 characters; contains 121 characters
Open

            throw new HttpException(Response::HTTP_BAD_REQUEST, 'request validation failed, please check documentation');

Line exceeds 120 characters; contains 126 characters
Open

        $cells = static::$strategyProcessor->process(MockFactory::getBattlefieldMock()->getCellByCoordinate('B2'), $strategy);

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 145 characters
Open

     * @ORM\OneToMany(targetEntity="EM\GameBundle\Entity\Cell", mappedBy="battlefield", cascade={"persist"}, fetch="EAGER", indexBy="coordinate")

Line exceeds 120 characters; contains 130 characters
Open

        return $this->currentCoordinate = $this->calculateNextCoordinateLetterPart() . $this->calculateNextCoordinateNumberPart();

Line exceeds 120 characters; contains 123 characters
Open

        throw new CellException("{$battlefield->getId()} do not contain cell with coordinate: {$this->currentCoordinate}");

Line exceeds 120 characters; contains 166 characters
Open

            /** if path is HORIZONTAL, strategy should be HORIZONTAL otherwise VERTICAL @see AIStrategyService::$strategyMap contains only UP|DOWN|LEFT|RIGHT paths */
Severity
Category
Status
Source
Language