modules/com_vtiger_workflow/VTTask.php
Avoid unused parameters such as '$recordModel'. Open
Open
public function getContents($recordModel)
- Read upRead up
- Exclude checks
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
Open
$mn = str_pad($m - $m % 15, 2, 0, STR_PAD_LEFT);
- Exclude checks
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
Open
* @param Vtiger_Record_Model
- Exclude checks
Argument 3 (pad_string)
is 0
but \str_pad()
takes string
Open
Open
return str_pad(($h % 12), 2, 0, STR_PAD_LEFT) . ':' . $mn . $AM_PM[($h / 12) % 2];
- Exclude checks
Argument 1 (input)
is int
but \str_pad()
takes string
Open
Open
return str_pad(($h % 12), 2, 0, STR_PAD_LEFT) . ':' . $mn . $AM_PM[($h / 12) % 2];
- Exclude checks
Argument 3 (pad_string)
is 0
but \str_pad()
takes string
Open
Open
$mn = str_pad($m - $m % 15, 2, 0, STR_PAD_LEFT);
- Exclude checks
Assigning int
to property but \VTTask->recordEventState
is bool
Open
Open
public $recordEventState = self::RECORD_EVENT_ACTIVE;
- Exclude checks
Remove the unused function parameter "$recordModel". Open
Open
public function getContents($recordModel)
- Read upRead up
- Exclude checks
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
Open
abstract class VTTask
- Exclude checks
Avoid variables with short names like $m. Configured minimum length is 3. Open
Open
[$h, $m] = explode(':', $time);
- Read upRead up
- Exclude checks
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
Open
[$h, $m] = explode(':', $time);
- Read upRead up
- Exclude checks
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
Open
$mn = str_pad($m - $m % 15, 2, 0, STR_PAD_LEFT);
- Read upRead up
- Exclude checks
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
Open
* Do task.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Set contents.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Task contents.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param mixed $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getContents($recordModel)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getTimeFieldList()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** @var int */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param Vtiger_Record_Model
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
abstract public function getFieldNames();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return Vtiger_Record_Model
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** @var int */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
abstract public function doTask($recordModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $this->contents;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public const RECORD_EVENT_INACTIVE = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Return time field list.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public const RECORD_EVENT_ACTIVE = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @var Vtiger_Record_Model
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public $contents;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** @var bool The record event. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** @var int */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public const RECORD_EVENT_DOUBLE_MODE = 2;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function setContents($recordModel)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public $recordEventState = self::RECORD_EVENT_ACTIVE;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Return field names.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Return content.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return str_pad(($h % 12), 2, 0, STR_PAD_LEFT) . ':' . $mn . $AM_PM[($h / 12) % 2];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param string $time
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function hasContents($recordModel)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ($this->getContents($recordModel)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Return formatted time for timepicker.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
[$h, $m] = explode(':', $time);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$this->contents = $recordModel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Check if has contents.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function formatTimeForTimePicker($time)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$AM_PM = ['am', 'pm'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$mn = str_pad($m - $m % 15, 2, 0, STR_PAD_LEFT);
- Exclude checks
The variable $AM_PM is not named in camelCase. Open
Open
public function formatTimeForTimePicker($time)
{
[$h, $m] = explode(':', $time);
$mn = str_pad($m - $m % 15, 2, 0, STR_PAD_LEFT);
$AM_PM = ['am', 'pm'];
- Read upRead up
- Exclude checks
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
Open
public function formatTimeForTimePicker($time)
{
[$h, $m] = explode(':', $time);
$mn = str_pad($m - $m % 15, 2, 0, STR_PAD_LEFT);
$AM_PM = ['am', 'pm'];
- Read upRead up
- Exclude checks
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();
}
}