alientronics/fleetany-api

View on GitHub

Showing 235 of 235 total issues

Method sendAlertTireMail has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function sendAlertTireMail($company, $vehicle_id, $tireSensor, $ideal_pressure, $users)
    {
        try {
            $vehicle = Vehicle::where('id', $vehicle_id)->first();
    
Severity: Major
Found in app/Http/Controllers/AlertController.php - About 2 hrs to fix

    Function generateEntry has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        private function generateEntry($company, $tireSensor, $ideal_pressure)
        {
            if (!$this->hasPressureIssue($company, $tireSensor, $ideal_pressure)) {
                $tireSensor = TireSensor::where('part_id', $tireSensor->part_id)
                    ->where('created_at', '<', $tireSensor->created_at)
    Severity: Minor
    Found in app/Http/Controllers/TireConditionController.php - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method getPart has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function getPart($user, $json, $inputs)
        {
            $part = Part::select('id')->where('number', $json['id'])
                ->where('company_id', $user->company_id)
                ->first();
    Severity: Minor
    Found in app/Http/Controllers/TireSensorController.php - About 1 hr to fix

      Method generateEntry has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function generateEntry($company, $tireSensor, $ideal_pressure)
          {
              if (!$this->hasPressureIssue($company, $tireSensor, $ideal_pressure)) {
                  $tireSensor = TireSensor::where('part_id', $tireSensor->part_id)
                      ->where('created_at', '<', $tireSensor->created_at)
      Severity: Minor
      Found in app/Http/Controllers/TireConditionController.php - About 1 hr to fix

        Avoid using undefined variables such as '$response' which will lead to PHP notices.
        Open

                $response['fuelTypes'] = Type::where('entity_key', 'fuel')
        Severity: Minor
        Found in tests/UserTest.php by phpmd

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$response' which will lead to PHP notices.
        Open

                    ->seeJson($response);
        Severity: Minor
        Found in tests/UserTest.php by phpmd

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$response' which will lead to PHP notices.
        Open

                $response['vehicles'] = $vehicles->toArray();
        Severity: Minor
        Found in tests/UserTest.php by phpmd

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$inputsCreate' which will lead to PHP notices.
        Open

                        $inputsCreate['vehicle_id'] = $gpsData['vehicle_id'];

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$inputsCreate' which will lead to PHP notices.
        Open

                        $inputsCreate['altitude'] = $inputs['altitude'];

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$inputsCreate' which will lead to PHP notices.
        Open

                    $inputsCreate['company_id'] = $user->company_id;

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$inputsCreate' which will lead to PHP notices.
        Open

                    $inputsCreate['fuel_amount'] = $inputs['fuel_amount'];

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$response' which will lead to PHP notices.
        Open

                $response['vehicles'] = $user->company->vehicles;

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$inputsCreate' which will lead to PHP notices.
        Open

                        $Gps = Gps::forceCreate($inputsCreate);

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$inputsCreate' which will lead to PHP notices.
        Open

                    $inputsCreate['driver_id'] = $user->contact->id;

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$response' which will lead to PHP notices.
        Open

                return response()->json($response);

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$inputsCreate' which will lead to PHP notices.
        Open

                        $inputsCreate['company_id'] = $user->company_id;

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$inputsCreate' which will lead to PHP notices.
        Open

                        $inputsCreate['longitude'] = $inputs['longitude'];

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$inputsCreate' which will lead to PHP notices.
        Open

                    $inputsCreate['end_mileage'] = $inputs['end_mileage'];

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$inputsCreate' which will lead to PHP notices.
        Open

                    $inputsCreate['tank_fill_up'] = $inputs['tank_fill_up'];

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Avoid using undefined variables such as '$inputsCreate' which will lead to PHP notices.
        Open

                    $inputsCreate['trip_type_id'] = $type->id;

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        Severity
        Category
        Status
        Source
        Language