modules/OSSEmployees/models/Module.php
Avoid using undefined variables such as '$result' which will lead to PHP notices. Open
Open
return $result;
- Read upRead up
- Exclude checks
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
Open
$result[$key] = $colors[$i];
- Read upRead up
- Exclude checks
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
Open
foreach ($chartData as $key => $value) {
- Read upRead up
- Exclude checks
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
Open
$result[$key] = $colors[$i];
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class OSSEmployees_Module_Model extends Vtiger_Module_Model
- Exclude checks
The class OSSEmployees_Module_Model is not named in CamelCase. Open
Open
class OSSEmployees_Module_Model extends Vtiger_Module_Model
{
public function getWorkingDays($startDate, $endDate)
{
$begin = strtotime($startDate);
- Read upRead up
- Exclude checks
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
Open
$i = 0;
- 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
$whatDay = date('N', $begin);
- 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 $result;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$begin += 86400; // +1 day
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getBarChartColors($chartData)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$end = strtotime($endDate);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ($begin > $end) {
- 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
while ($begin <= $end) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
foreach ($chartData as $key => $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getWorkingDays($startDate, $endDate)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$begin = strtotime($startDate);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$noDays = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$result[$key] = $colors[$i];
- 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
$colors = ['#4bb2c5', '#EAA228', '#c5b47f'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return 0;
- 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
++$weekends;
- 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
if ($whatDay > 5) { // 6 and 7 are weekend days
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
++$i;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
++$noDays; // no of days in the given interval
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$i = 0;
- 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
$weekends = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $noDays - $weekends;
- Exclude checks
Class name "OSSEmployees_Module_Model" is not in camel caps format Open
Open
class OSSEmployees_Module_Model extends Vtiger_Module_Model
- Exclude checks