dbudwin/RoboHome-Web

View on GitHub
tests/Unit/Controller/API/DevicesControllerTest.php

Summary

Maintainability
A
2 hrs
Test Coverage

DevicesControllerTest has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class DevicesControllerTest extends DevicesControllerTestCase
{
    private $mockDeviceRepository;
    private $mockUser;
    private $messageId;
Severity: Minor
Found in tests/Unit/Controller/API/DevicesControllerTest.php - About 2 hrs to fix

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

        private function assertDiscoverAppliancesResponse(TestResponse $response, Collection $devices): void
        {
            $appliances = [];
    
            for ($i = 0; $i < $devices->count(); $i++) {

    The method createDevice has a boolean flag argument $isOwnedByUser, which is a certain sign of a Single Responsibility Principle violation.
    Open

        private function createDevice(bool $isOwnedByUser = true): Device

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

    Line exceeds 120 characters; contains 136 characters
    Open

            $this->mockDeviceRepository->shouldReceive('getForPublicId')->with(Mockery::on(function (Uuid $argument) use ($publicDeviceId) {

    Line exceeds 120 characters; contains 128 characters
    Open

            $this->mockDeviceRepository->shouldReceive('getForPublicId')->with(Mockery::on(function (Uuid $argument) use ($device) {

    Line exceeds 120 characters; contains 128 characters
    Open

            $this->mockDeviceRepository->shouldReceive('getForPublicId')->with(Mockery::on(function (Uuid $argument) use ($device) {

    There are no issues that match your filters.

    Category
    Status