Avoid using static access to class 'Settings_Vtiger_MenuItem_Model' in method 'getSettingLinks'. Open
if ($menu = Settings_Vtiger_MenuItem_Model::getInstance('Mail View')) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Privilege' in method 'isPermitted'. Open
return $this->isActive() && \App\Privilege::isPermitted($this->getName(), $actionName);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Vtiger_Theme' in method 'getSettingLinks'. Open
$layoutEditorImagePath = Vtiger_Theme::getImagePath('LayoutEditor.gif');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid assigning values to variables in if clauses and the like (line '16', column '7'). Open
public function getSettingLinks(): array
{
$settingsLinks = parent::getSettingLinks();
$layoutEditorImagePath = Vtiger_Theme::getImagePath('LayoutEditor.gif');
if ($menu = Settings_Vtiger_MenuItem_Model::getInstance('Mail View')) {
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid excessively long variable names like $layoutEditorImagePath. Keep variable name length under 20. Open
$layoutEditorImagePath = Vtiger_Theme::getImagePath('LayoutEditor.gif');
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class OSSMailView_Module_Model extends Vtiger_Module_Model
- Exclude checks
The class OSSMailView_Module_Model is not named in CamelCase. Open
class OSSMailView_Module_Model extends Vtiger_Module_Model
{
/** {@inheritdoc} */
public function getSettingLinks(): array
{
- 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 $id. Configured minimum length is 3. Open
public function getPreviewViewUrl($id)
- 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
public function getSettingLinks(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $settingsLinks;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getPreviewViewUrl($id)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->isActive() && \App\Privilege::isPermitted($this->getName(), $actionName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 156 characters Open
'linkurl' => 'index.php?module=OSSMailView&parent=Settings&view=index&block=' . $menu->get('blockid') . '&fieldid=' . $menu->get('fieldid'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => $layoutEditorImagePath,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'index.php?module=' . $this->get('name') . '&view=Preview&record=' . $id;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$layoutEditorImagePath = Vtiger_Theme::getImagePath('LayoutEditor.gif');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($menu = Settings_Vtiger_MenuItem_Model::getInstance('Mail View')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$settingsLinks = parent::getSettingLinks();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'LBL_MODULE_CONFIGURATION',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => 'index.php?module=OSSMailView&parent=Settings&view=index&block=' . $menu->get('blockid') . '&fieldid=' . $menu->get('fieldid'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isPermitted($actionName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'LISTVIEWSETTING',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('EditView' === $actionName || 'CreateView' === $actionName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$settingsLinks[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isQuickCreateSupported()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Class name "OSSMailView_Module_Model" is not in camel caps format Open
class OSSMailView_Module_Model extends Vtiger_Module_Model
- Exclude checks