tests/Unit/Model/DeviceTest.php
The method testHtmlDataAttributesForSpecificDeviceProperties_GivenDeviceAddedToDatabase_AttributesMatchNameAndValueOfAddedDevice() has 25 lines of code. Current threshold is set to 25. Avoid really long methods. Open
Open
public function testHtmlDataAttributesForSpecificDeviceProperties_GivenDeviceAddedToDatabase_AttributesMatchNameAndValueOfAddedDevice(): void
{
foreach ($this->deviceTypeConstants() as $specificDeviceType) {
$addedDevice = $this->addDeviceToDatabase($specificDeviceType);
$specificDevice = $this->addSpecificDevice($addedDevice->id, $specificDeviceType);
- Exclude checks
Missing class import via use statement (line '86', column '33'). Open
Open
$deviceTypesClass = new \ReflectionClass(DeviceTypes::class);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using Tests\Unit\Model\sizeof() function in for loops. Open
Open
for ($i = 0; $i < sizeof($attributeNames); $i++) {
$this->assertEquals($specificDeviceProperties[$i], $attributeNames[$i]);
$this->assertEquals($specificDevice->{$attributeNames[$i]}, $attributeValues[$i]);
}
- Read upRead up
- Exclude checks
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
Line exceeds 120 characters; contains 148 characters Open
Open
$this->assertHtmlAttributesMatchSpecificDeviceProperties($specificDevice, $attributeNames, $attributeValues, $specificDeviceProperties);
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
Open
$attributeName = substr($htmlAttributePieces[0], strlen($htmlAttributeDataPrefix), $htmlAttributeRawNameLength);
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
Open
$this->assertEquals($expectedSpecificDevice->attributesToArray(), $actualSpecificDevice->attributesToArray());
- Exclude checks
Line exceeds 120 characters; contains 179 characters Open
Open
private function assertHtmlAttributesMatchSpecificDeviceProperties(Model $specificDevice, array $attributeNames, array $attributeValues, array $specificDeviceProperties): void
- Exclude checks
Line exceeds 120 characters; contains 145 characters Open
Open
public function testHtmlDataAttributesForSpecificDeviceProperties_GivenDeviceAddedToDatabase_AttributesMatchNameAndValueOfAddedDevice(): void
- Exclude checks