dbudwin/RoboHome-Web

View on GitHub

Showing 76 of 76 total issues

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

    public function testDevices_GivenUserLoggedIn_EditsDevice_DevicesUpdatedOnPage(): void
    {
        $this->browse(function (Browser $browser) {
            $deviceName = self::$faker->word();
            $deviceDescription = self::$faker->sentence();
Severity: Minor
Found in tests/Browser/DevicesTest.php by phpmd

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

    public function testDevices_GivenUserLoggedIn_ViewContainsUsersDevices(): void
    {
        $user = $this->makeUser();
        $deviceName = self::$faker->word();
        $deviceDescription = self::$faker->sentence();

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 testDevices_GivenUserLoggedIn_ClicksEditDeviceButton_OpensEditDeviceModal() has 30 lines of code. Current threshold is set to 25. Avoid really long methods.
Open

    public function testDevices_GivenUserLoggedIn_ClicksEditDeviceButton_OpensEditDeviceModal(): void
    {
        $this->browse(function (Browser $browser) {
            $deviceName = self::$faker->word();
            $deviceDescription = self::$faker->sentence();
Severity: Minor
Found in tests/Browser/DevicesTest.php by phpmd

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

    public function testMqtt_GivenUserWithInfoScope_ReturnsMqttSettings(): void
    {
        $user = factory(User::class)->make();
        $publicUserId = $user->public_id;

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

Avoid unused parameters such as '$schedule'.
Open

    protected function schedule(Schedule $schedule): void
Severity: Minor
Found in app/Console/Kernel.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

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

Avoid using App\Http\Controllers\API\count() function in for loops.
Open

        for ($i = 0; $i < count($devicesForCurrentUser); $i++) {
            $appliance = [
                'actions' => $actions,
                'additionalApplianceDetails' => (object)[],
                'applianceId' => $devicesForCurrentUser[$i]->id,

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

            ->shouldReceive('getAttribute')->with('public_id')->atLeast()->once()->andReturn(self::$faker->randomDigit())

Line exceeds 120 characters; contains 139 characters
Open

            ->whenAvailable('#add-device-modal', function ($modal) use ($deviceName, $deviceDescription, $onCode, $offCode, $pulseLength) {

Line exceeds 120 characters; contains 147 characters
Open

Route::post('/devices/control/{action}', 'API\DevicesController@control')->name('control')->middleware('scope:control', 'apiVerifyUserOwnsDevice');
Severity: Minor
Found in routes/api.php by phpcodesniffer

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

    public function __construct(IDeviceRepository $deviceRepository, IDeviceActionInfoBroker $deviceInformationBroker, MessagePublisher $messagePublisher)

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

            return $this->redirectToDevicesWithMessage($request, FlashMessageLevels::DANGER, "Encountered an error while deleting device '$name'!");

Line exceeds 120 characters; contains 126 characters
Open

Route::post('/devices/{action}/{publicDeviceId}', 'Web\DevicesController@handleControlRequest')->name('handleControlRequest');
Severity: Minor
Found in routes/web.php by phpcodesniffer

Line exceeds 120 characters; contains 132 characters
Open

        return $this->redirectToDevicesWithMessage($request, FlashMessageLevels::SUCCESS, "Device '$name' was successfully added!");

Line exceeds 120 characters; contains 142 characters
Open

        return $this->redirectToDevicesWithMessage($request, FlashMessageLevels::SUCCESS, "Device '$device->name' was successfully updated!");

Line exceeds 120 characters; contains 123 characters
Open

        $this->assertJsonResponse($response, json_encode(['error' => "Action '$action' not implemented for device"]), 400);
Severity
Category
Status
Source
Language