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));
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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]);
}
- Read upRead up
- Exclude checks
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')]]
- Read upRead up
- Exclude checks
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));
- Read upRead up
- Exclude checks
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)]);
- Read upRead up
- Exclude checks
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));
- Read upRead up
- Exclude checks
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'));
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
&& $this->validatePlayerName($data->playerName) // will be replaced by Authorization header which will reflect Player.id content
- Exclude checks
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 () {
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
$game = $this->get('em.game_bundle.service.game_builder')->buildGame(new GameInitiationRequest($request->getContent()));
- Exclude checks
Line exceeds 120 characters; contains 139 characters Open
foreach ($processor->reset($cell->getCoordinate())->getAdjacentCells($battlefield, 1, 0, CellModel::FLAG_SHIP) as $waterCell) {
- Exclude checks
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
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
throw new HttpException(Response::HTTP_BAD_REQUEST, 'request validation failed, please check documentation');
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
$cells = static::$strategyProcessor->process(MockFactory::getBattlefieldMock()->getCellByCoordinate('B2'), $strategy);
- Exclude checks
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)
- Exclude checks
Line exceeds 120 characters; contains 145 characters Open
* @ORM\OneToMany(targetEntity="EM\GameBundle\Entity\Cell", mappedBy="battlefield", cascade={"persist"}, fetch="EAGER", indexBy="coordinate")
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
return $this->currentCoordinate = $this->calculateNextCoordinateLetterPart() . $this->calculateNextCoordinateNumberPart();
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
throw new CellException("{$battlefield->getId()} do not contain cell with coordinate: {$this->currentCoordinate}");
- Exclude checks
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 */
- Exclude checks