dbudwin/RoboHome-Web

View on GitHub
tests/Browser/DevicesTest.php

Summary

Maintainability
A
3 hrs
Test Coverage

The class DevicesTest has 13 public methods. Consider refactoring DevicesTest to keep number of public methods under 10.
Open

class DevicesTest extends DuskTestCase
{
    private $user;

    public function setUp(): void
Severity: Minor
Found in tests/Browser/DevicesTest.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

Method testDevices_GivenUserLoggedIn_EditsDevice_DevicesUpdatedOnPage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
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 - About 1 hr to fix

    Method testDevices_GivenUserLoggedIn_ClicksEditDeviceButton_OpensEditDeviceModal has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    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 - About 1 hr to fix

      Method loginAndAddDevice has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private function loginAndAddDevice(Browser $browser, string $deviceName, string $deviceDescription, int $onCode, int $offCode, int $pulseLength) : Browser
      Severity: Minor
      Found in tests/Browser/DevicesTest.php - About 45 mins to fix

        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_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

        Line exceeds 120 characters; contains 144 characters
        Open

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

        Line exceeds 120 characters; contains 159 characters
        Open

                        ->whenAvailable('#edit-device-modal', function ($modal) use ($newDeviceName, $newDeviceDescription, $newOnCode, $newOffCode, $newPulseLength) {

        Line exceeds 120 characters; contains 158 characters
        Open

            private function loginAndAddDevice(Browser $browser, string $deviceName, string $deviceDescription, int $onCode, int $offCode, int $pulseLength) : Browser

        Line exceeds 120 characters; contains 139 characters
        Open

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

        There are no issues that match your filters.

        Category
        Status