dbudwin/RoboHome-Web

View on GitHub
tests/Unit/Model/DeviceTest.php

Summary

Maintainability
A
0 mins
Test Coverage

The method testHtmlDataAttributesForSpecificDeviceProperties_GivenDeviceAddedToDatabase_AttributesMatchNameAndValueOfAddedDevice() has 25 lines of code. Current threshold is set to 25. Avoid really long methods.
Open

    public function testHtmlDataAttributesForSpecificDeviceProperties_GivenDeviceAddedToDatabase_AttributesMatchNameAndValueOfAddedDevice(): void
    {
        foreach ($this->deviceTypeConstants() as $specificDeviceType) {
            $addedDevice = $this->addDeviceToDatabase($specificDeviceType);
            $specificDevice = $this->addSpecificDevice($addedDevice->id, $specificDeviceType);
Severity: Minor
Found in tests/Unit/Model/DeviceTest.php by phpmd

Missing class import via use statement (line '86', column '33').
Open

        $deviceTypesClass = new \ReflectionClass(DeviceTypes::class);
Severity: Minor
Found in tests/Unit/Model/DeviceTest.php by phpmd

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

        for ($i = 0; $i < sizeof($attributeNames); $i++) {
            $this->assertEquals($specificDeviceProperties[$i], $attributeNames[$i]);
            $this->assertEquals($specificDevice->{$attributeNames[$i]}, $attributeValues[$i]);
        }
Severity: Minor
Found in tests/Unit/Model/DeviceTest.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

Line exceeds 120 characters; contains 148 characters
Open

            $this->assertHtmlAttributesMatchSpecificDeviceProperties($specificDevice, $attributeNames, $attributeValues, $specificDeviceProperties);

Line exceeds 120 characters; contains 128 characters
Open

                $attributeName = substr($htmlAttributePieces[0], strlen($htmlAttributeDataPrefix), $htmlAttributeRawNameLength);

Line exceeds 120 characters; contains 122 characters
Open

            $this->assertEquals($expectedSpecificDevice->attributesToArray(), $actualSpecificDevice->attributesToArray());

Line exceeds 120 characters; contains 179 characters
Open

    private function assertHtmlAttributesMatchSpecificDeviceProperties(Model $specificDevice, array $attributeNames, array $attributeValues, array $specificDeviceProperties): void

Line exceeds 120 characters; contains 145 characters
Open

    public function testHtmlDataAttributesForSpecificDeviceProperties_GivenDeviceAddedToDatabase_AttributesMatchNameAndValueOfAddedDevice(): void

There are no issues that match your filters.

Category
Status