Method process
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(App\Request $request)
{
$moduleName = $request->getModule();
$mailModuleActive = \App\Module::getModuleId('OSSMail');
$mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');
Function process
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function process(App\Request $request)
{
$moduleName = $request->getModule();
$mailModuleActive = \App\Module::getModuleId('OSSMail');
$mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid using undefined variables such as '$numbering' which will lead to PHP notices. Open
$viewer->assign('RECORDNUMBERING', $numbering ?? []);
- 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 '$numbering' which will lead to PHP notices. Open
$numbering[$supportedModule->name] = \App\Fields\RecordNumber::getInstance($supportedModule->name);
- 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 static access to class 'OSSMailScanner_Record_Model' in method 'process'. Open
$emailSearchList = OSSMailScanner_Record_Model::getEmailSearchList();
- 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 'OSSMailScanner_Record_Model' in method 'process'. Open
$actionsList = OSSMailScanner_Record_Model::getActionsList();
- 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_Record_Model' in method 'process'. Open
$mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');
- 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 'OSSMailScanner_Record_Model' in method 'process'. Open
$ConfigFolderList = OSSMailScanner_Record_Model::getConfigFolderList();
- 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 'OSSMailScanner_Record_Model' in method 'process'. Open
$identityList[$account['user_id']] = OSSMailScanner_Record_Model::getIdentities($account['user_id']);
- 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 'OSSMailScanner_Record_Model' in method 'process'. Open
$widgetCfg = OSSMailScanner_Record_Model::getConfig(false);
- 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\Fields\RecordNumber' in method 'process'. Open
$numbering[$supportedModule->name] = \App\Fields\RecordNumber::getInstance($supportedModule->name);
- 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 'OSSMailScanner_Record_Model' in method 'process'. Open
$emailSearch = OSSMailScanner_Record_Model::getEmailSearch(false, false);
- 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 'OSSMailScanner_Record_Model' in method 'process'. Open
$checkCron = OSSMailScanner_Record_Model::getCron();
- 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\Module' in method 'process'. Open
$mailModuleActive = \App\Module::getModuleId('OSSMail');
- 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 'OSSMail_Record_Model' in method 'process'. Open
$accountsList = OSSMail_Record_Model::getAccountsList(false, false, false, false);
- 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 'Settings_RecordNumbering_Module_Model' in method 'process'. Open
$supportedModules = Settings_RecordNumbering_Module_Model::getSupportedModules();
- 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
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('RECORDNUMBERING', $numbering ?? []);
- Exclude checks
Call to method getConfigFolderList
from undeclared class \OSSMailScanner_Record_Model
Open
$ConfigFolderList = OSSMailScanner_Record_Model::getConfigFolderList();
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('ACCOUNTS_LIST', $accountsList);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('CONFIGFOLDERLIST', $ConfigFolderList);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('MODULE_NAME', $moduleName);
- Exclude checks
Call to method getConfig
from undeclared class \OSSMailScanner_Record_Model
Open
$widgetCfg = OSSMailScanner_Record_Model::getConfig(false);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('WIDGET_CFG', $widgetCfg);
- Exclude checks
Call to method getIdentities
from undeclared class \OSSMailScanner_Record_Model
Open
$identityList[$account['user_id']] = OSSMailScanner_Record_Model::getIdentities($account['user_id']);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('CHECKCRON', $checkCron);
- Exclude checks
Call to method getInstance
from undeclared class \App\Fields\RecordNumber
(Did you mean class \Tests\Base\RecordNumber) Open
$numbering[$supportedModule->name] = \App\Fields\RecordNumber::getInstance($supportedModule->name);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('ERRORNOMODULE', !$mailModuleActive);
- Exclude checks
Call to method getActionsList
from undeclared class \OSSMailScanner_Record_Model
Open
$actionsList = OSSMailScanner_Record_Model::getActionsList();
- Exclude checks
Variable $numbering
was undeclared, but array fields are being added to it. Open
$numbering[$supportedModule->name] = \App\Fields\RecordNumber::getInstance($supportedModule->name);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('RECORD_MODEL', $mailScannerRecordModel);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('ACTIONS_LIST', $actionsList);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('IDENTITYLIST', $identityList);
- Exclude checks
Call to method getEmailSearchList
from undeclared class \OSSMailScanner_Record_Model
Open
$emailSearchList = OSSMailScanner_Record_Model::getEmailSearchList();
- Exclude checks
Call to method getCron
from undeclared class \OSSMailScanner_Record_Model
Open
$checkCron = OSSMailScanner_Record_Model::getCron();
- Exclude checks
Call to method getEmailSearch
from undeclared class \OSSMailScanner_Record_Model
Open
$emailSearch = OSSMailScanner_Record_Model::getEmailSearch(false, false);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('EMAILSEARCHLIST', $emailSearchList);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('EMAILSEARCH', $emailSearch);
- Exclude checks
Avoid excessively long variable names like $mailScannerRecordModel. Keep variable name length under 20. Open
$mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');
- 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 Settings_OSSMailScanner_Index_View extends Settings_Vtiger_Index_View
- Exclude checks
The class Settings_OSSMailScanner_Index_View is not named in CamelCase. Open
class Settings_OSSMailScanner_Index_View extends Settings_Vtiger_Index_View
{
private $prefixesForModules = ['Project', 'HelpDesk', 'SSalesProcesses', 'Campaigns'];
/** {@inheritdoc} */
- 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
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
if ($mailModuleActive) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$accountsList = OSSMail_Record_Model::getAccountsList(false, false, false, false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('ACTIONS_LIST', $actionsList);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('WIDGET_CFG', $widgetCfg);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('CHECKCRON', $checkCron);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $prefixesForModules = ['Project', 'HelpDesk', 'SSalesProcesses', 'Campaigns'];
- 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
$viewer->assign('ACCOUNTS_LIST', $accountsList);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$emailSearch = OSSMailScanner_Record_Model::getEmailSearch(false, false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$identityList = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($supportedModules as $supportedModule) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('EMAILSEARCH', $emailSearch);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($accountsList as $account) {
- 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
$checkCron = OSSMailScanner_Record_Model::getCron();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$actionsList = OSSMailScanner_Record_Model::getActionsList();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widgetCfg = OSSMailScanner_Record_Model::getConfig(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('EMAILSEARCHLIST', $emailSearchList);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
echo $viewer->view('Index.tpl', $request->getModule(false), true);
- 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 array_merge(parent::getFooterScripts($request), $this->checkAndConvertJsScripts([
- 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 process(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$emailSearchList = OSSMailScanner_Record_Model::getEmailSearchList();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$identityList[$account['user_id']] = OSSMailScanner_Record_Model::getIdentities($account['user_id']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array($supportedModule->name, $this->prefixesForModules)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'~layouts/resources/libraries/jstree.checkbox.js',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$supportedModules = Settings_RecordNumbering_Module_Model::getSupportedModules();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('RECORD_MODEL', $mailScannerRecordModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('RECORDNUMBERING', $numbering ?? []);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('ERRORNOMODULE', !$mailModuleActive);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('IDENTITYLIST', $identityList);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$mailModuleActive = \App\Module::getModuleId('OSSMail');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ConfigFolderList = OSSMailScanner_Record_Model::getConfigFolderList();
- 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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer = $this->getViewer($request);
- 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
$viewer->assign('MODULE_NAME', $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFooterScripts(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $request->getModule();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$numbering[$supportedModule->name] = \App\Fields\RecordNumber::getInstance($supportedModule->name);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('CONFIGFOLDERLIST', $ConfigFolderList);
- Exclude checks
Class name "Settings_OSSMailScanner_Index_View" is not in camel caps format Open
class Settings_OSSMailScanner_Index_View extends Settings_Vtiger_Index_View
- Exclude checks
The variable $ConfigFolderList is not named in camelCase. Open
public function process(App\Request $request)
{
$moduleName = $request->getModule();
$mailModuleActive = \App\Module::getModuleId('OSSMail');
$mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');
- 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 $ConfigFolderList is not named in camelCase. Open
public function process(App\Request $request)
{
$moduleName = $request->getModule();
$mailModuleActive = \App\Module::getModuleId('OSSMail');
$mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');
- 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();
}
}