YetiForceCompany/YetiForceCRM

View on GitHub
modules/OSSEmployees/models/Module.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

        return $result;

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 '$result' which will lead to PHP notices.
Open

            $result[$key] = $colors[$i];

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 unused local variables such as '$value'.
Open

        foreach ($chartData as $key => $value) {

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

Variable $result was undeclared, but array fields are being added to it.
Open

            $result[$key] = $colors[$i];

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class OSSEmployees_Module_Model extends Vtiger_Module_Model

The class OSSEmployees_Module_Model is not named in CamelCase.
Open

class OSSEmployees_Module_Model extends Vtiger_Module_Model
{
    public function getWorkingDays($startDate, $endDate)
    {
        $begin = strtotime($startDate);

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Avoid variables with short names like $i. Configured minimum length is 3.
Open

        $i = 0;

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Spaces must be used to indent lines; tabs are not allowed
Open

            $whatDay = date('N', $begin);

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        return $result;

Spaces must be used to indent lines; tabs are not allowed
Open

            $begin += 86400; // +1 day

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getBarChartColors($chartData)

Spaces must be used to indent lines; tabs are not allowed
Open

        $end = strtotime($endDate);

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($begin > $end) {

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        while ($begin <= $end) {

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($chartData as $key => $value) {

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getWorkingDays($startDate, $endDate)

Spaces must be used to indent lines; tabs are not allowed
Open

        $begin = strtotime($startDate);

Spaces must be used to indent lines; tabs are not allowed
Open

        $noDays = 0;

Spaces must be used to indent lines; tabs are not allowed
Open

            $result[$key] = $colors[$i];

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        $colors = ['#4bb2c5', '#EAA228', '#c5b47f'];

Spaces must be used to indent lines; tabs are not allowed
Open

            return 0;

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

                ++$weekends;

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

            if ($whatDay > 5) { // 6 and 7 are weekend days

Spaces must be used to indent lines; tabs are not allowed
Open

            ++$i;

Spaces must be used to indent lines; tabs are not allowed
Open

            ++$noDays; // no of days in the given interval

Spaces must be used to indent lines; tabs are not allowed
Open

        $i = 0;

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

        $weekends = 0;

Spaces must be used to indent lines; tabs are not allowed
Open

        return $noDays - $weekends;

Class name "OSSEmployees_Module_Model" is not in camel caps format
Open

class OSSEmployees_Module_Model extends Vtiger_Module_Model

There are no issues that match your filters.

Category
Status