YetiForceCompany/YetiForceCRM

View on GitHub
modules/com_vtiger_workflow/VTTask.php

Summary

Maintainability
A
0 mins
Test Coverage
F
35%

Avoid unused parameters such as '$recordModel'.
Open

    public function getContents($recordModel)

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

Argument 1 (input) is float|int but \str_pad() takes string
Open

        $mn = str_pad($m - $m % 15, 2, 0, STR_PAD_LEFT);
Severity: Minor
Found in modules/com_vtiger_workflow/VTTask.php by phan

Saw possibly unextractable annotation for a fragment of comment '* @param Vtiger_Record_Model': after Vtiger_Record_Model, did not see an element name (will guess based on comment order)
Open

     * @param Vtiger_Record_Model

Argument 3 (pad_string) is 0 but \str_pad() takes string
Open

        return str_pad(($h % 12), 2, 0, STR_PAD_LEFT) . ':' . $mn . $AM_PM[($h / 12) % 2];
Severity: Minor
Found in modules/com_vtiger_workflow/VTTask.php by phan

Argument 1 (input) is int but \str_pad() takes string
Open

        return str_pad(($h % 12), 2, 0, STR_PAD_LEFT) . ':' . $mn . $AM_PM[($h / 12) % 2];
Severity: Minor
Found in modules/com_vtiger_workflow/VTTask.php by phan

Argument 3 (pad_string) is 0 but \str_pad() takes string
Open

        $mn = str_pad($m - $m % 15, 2, 0, STR_PAD_LEFT);
Severity: Minor
Found in modules/com_vtiger_workflow/VTTask.php by phan

Assigning int to property but \VTTask->recordEventState is bool
Open

    public $recordEventState = self::RECORD_EVENT_ACTIVE;
Severity: Minor
Found in modules/com_vtiger_workflow/VTTask.php by phan

Remove the unused function parameter "$recordModel".
Open

    public function getContents($recordModel)

Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.

Noncompliant Code Example

function doSomething($a, $b) { // "$a" is unused
  return compute($b);
}

Compliant Solution

function doSomething($b) {
  return compute($b);
}

Exceptions

Functions in classes that override a class or implement interfaces are ignored.

class C extends B {

  function doSomething($a, $b) {     // no issue reported on $b
    compute($a);
  }

}

See

  • MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
  • MISRA C:2012, 2.7 - There should be no unused parameters in functions
  • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
  • CERT, MSC12-CPP. - Detect and remove code that has no effect

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

abstract class VTTask

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

        [$h, $m] = explode(':', $time);

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

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

        [$h, $m] = explode(':', $time);

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

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

        $mn = str_pad($m - $m % 15, 2, 0, STR_PAD_LEFT);

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

     * Do task.

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

     * Set contents.

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

     * Task contents.

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

     * @param mixed $recordModel

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 [];

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

    public function getContents($recordModel)

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

     *

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

    public function getTimeFieldList()

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

    /** @var int */

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

     * @param Vtiger_Record_Model

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

    abstract public function getFieldNames();

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 Vtiger_Record_Model

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

     */

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

    /** @var int */

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

     *

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

    abstract public function doTask($recordModel);

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

        return $this->contents;

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

    public const RECORD_EVENT_INACTIVE = 1;

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

     * Return time field list.

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

     * @param Vtiger_Record_Model $recordModel

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

    public const RECORD_EVENT_ACTIVE = 0;

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

     * @var Vtiger_Record_Model

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 array

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

    {

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

    public $contents;

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

     *

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

    /** @var bool The record event. */

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

    /** @var int */

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

    public const RECORD_EVENT_DOUBLE_MODE = 2;

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

    /**

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

    public function setContents($recordModel)

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

    public $recordEventState = self::RECORD_EVENT_ACTIVE;

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

     * Return field names.

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

     * Return content.

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

     * @param Vtiger_Record_Model $recordModel

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

        return str_pad(($h % 12), 2, 0, STR_PAD_LEFT) . ':' . $mn . $AM_PM[($h / 12) % 2];

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

     * @return string

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

     * @param string $time

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

        return false;

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

    public function hasContents($recordModel)

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

     * @param Vtiger_Record_Model $recordModel

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

        if ($this->getContents($recordModel)) {

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

     *

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 bool

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

     * Return formatted time for timepicker.

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

        [$h, $m] = explode(':', $time);

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

        $this->contents = $recordModel;

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

     * Check if has contents.

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

    public function formatTimeForTimePicker($time)

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

            return true;

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

        $AM_PM = ['am', 'pm'];

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

     *

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

        $mn = str_pad($m - $m % 15, 2, 0, STR_PAD_LEFT);

The variable $AM_PM is not named in camelCase.
Open

    public function formatTimeForTimePicker($time)
    {
        [$h, $m] = explode(':', $time);
        $mn = str_pad($m - $m % 15, 2, 0, STR_PAD_LEFT);
        $AM_PM = ['am', 'pm'];

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $AM_PM is not named in camelCase.
Open

    public function formatTimeForTimePicker($time)
    {
        [$h, $m] = explode(':', $time);
        $mn = str_pad($m - $m % 15, 2, 0, STR_PAD_LEFT);
        $AM_PM = ['am', 'pm'];

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status