Method showFieldLayout
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function showFieldLayout(App\Request $request)
{
$sourceModule = $request->getByType('sourceModule', 2);
$menuModelsList = \App\Module::getQuickCreateModules();
Function showFieldLayout
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function showFieldLayout(App\Request $request)
{
$sourceModule = $request->getByType('sourceModule', 2);
$menuModelsList = \App\Module::getQuickCreateModules();
- 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 static access to class '\App\Module' in method 'showFieldLayout'. Open
$menuModelsList = \App\Module::getQuickCreateModules();
- 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 'showFieldLayout'. Open
$recordModel = Vtiger_Record_Model::getCleanInstance($sourceModule);
- 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
The method process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->showFieldLayout($request);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method showFieldLayout uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
unset($blockModels[$blockKey]);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('LAYOUT', $layout);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('SELECTED_MODULE_MODEL', $selectedModuleModel);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('SUPPORTED_MODULES', $menuModelsList);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('SELECTED_MODULE_NAME', $sourceModule);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('BLOCKS', $blockModels);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('RECORD_STRUCTURE', $quickCreateFields);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_QuickCreateEditor_Index_View extends Settings_Vtiger_Index_View
- Exclude checks
The class Settings_QuickCreateEditor_Index_View is not named in CamelCase. Open
class Settings_QuickCreateEditor_Index_View extends Settings_Vtiger_Index_View
{
use \App\Controller\ExposeMethod;
public function __construct()
- 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
$this->showFieldLayout($request);
- Exclude checks
Line exceeds 120 characters; contains 181 characters Open
$quickCreateFields = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($recordModel, Vtiger_RecordStructure_Model::RECORD_STRUCTURE_MODE_QUICKCREATE)->getStructure();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$mode = $request->getMode();
- 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
$blockIdFieldMap = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($blockIdFieldMap[$blockModel->get('id')])) {
- 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
$this->invokeExposedMethod($mode, $request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($sourceModule)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = Vtiger_Record_Model::getCleanInstance($sourceModule);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockModels = $selectedModuleModel->getBlocks();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($blockModels as $blockKey => $blockModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->isMethodExposed($mode)) {
- 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
} else {
- 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 __construct()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$selectedModuleModel = Settings_LayoutEditor_Module_Model::getInstance('Settings:LayoutEditor')->setSourceModule($sourceModule);
- 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
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Process.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($quickCreateFields as $fieldModel) {
- 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
$fieldModelList = $blockIdFieldMap[$blockModel->get('id')];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('SELECTED_MODULE_NAME', $sourceModule);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::__construct();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$menuModelsList = \App\Module::getQuickCreateModules();
- 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
$blockIdFieldMap[$fieldModel->getBlockId()][$fieldModel->getName()] = $fieldModel;
- 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
$this->exposeMethod('showFieldLayout');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function showFieldLayout(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('blocks' === $layout) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->view('Index.tpl', $request->getModule(false));
- 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
$firstElement = reset($menuModelsList);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$layout = $recordModel->getModule()->getLayoutTypeForQuickCreate();
- 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('SUPPORTED_MODULES', $menuModelsList);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('BLOCKS', $blockModels);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('RECORD_STRUCTURE', $quickCreateFields);
- 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
* View.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceModule = $request->getByType('sourceModule', 2);
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
$selectedModuleModel = Settings_LayoutEditor_Module_Model::getInstance('Settings:LayoutEditor')->setSourceModule($sourceModule);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
use \App\Controller\ExposeMethod;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceModule = $firstElement->get('name');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($blockModels[$blockKey]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('LAYOUT', $layout);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('SELECTED_MODULE_MODEL', $selectedModuleModel);
- 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
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quickCreateFields = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($recordModel, Vtiger_RecordStructure_Model::RECORD_STRUCTURE_MODE_QUICKCREATE)->getStructure();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockModel->setFields($fieldModelList);
- Exclude checks
Class name "Settings_QuickCreateEditor_Index_View" is not in camel caps format Open
class Settings_QuickCreateEditor_Index_View extends Settings_Vtiger_Index_View
- Exclude checks