Function getStructure
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function getStructure(): array
{
$summaryFieldsList = $this->getModule()->getSummaryViewFieldsList();
$recordModel = $this->getRecord();
$fieldsDependency = \App\FieldsDependency::getByRecordModel('Detail', $recordModel);
- 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\FieldsDependency' in method 'getStructure'. Open
$fieldsDependency = \App\FieldsDependency::getByRecordModel('Detail', $recordModel);
- 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 excessively long variable names like $summaryFieldModelsList. Keep variable name length under 20. Open
$summaryFieldModelsList = [];
- 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
Avoid excessively long variable names like $blockSeqSortSummaryFields. Keep variable name length under 20. Open
$blockSeqSortSummaryFields = [];
- 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 Vtiger_SummaryRecordStructure_Model extends Vtiger_DetailRecordStructure_Model
- Exclude checks
The class Vtiger_SummaryRecordStructure_Model is not named in CamelCase. Open
class Vtiger_SummaryRecordStructure_Model extends Vtiger_DetailRecordStructure_Model
{
/**
* Function to get the values in structured format.
*
- 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
$fieldModel->set('fieldvalue', $recordModel->get($fieldName));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array - values in structure array('block'=>array(fieldinfo));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockSeqSortSummaryFields = [];
- 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
if (!empty($fieldsDependency['hide']['frontend']) && \in_array($fieldName, $fieldsDependency['hide']['frontend'])) {
- 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
$recordModel = $this->getRecord();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
ksort($blockSeqSortSummaryFields);
- 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 $summaryFieldModelsList;
- Exclude checks
Line exceeds 120 characters; contains 173 characters Open
if ($fieldModel->isViewableInDetailView() && (empty($fieldsDependency['hide']['backend']) || !\in_array($fieldName, $fieldsDependency['hide']['backend']))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($blockSeqSortSummaryFields as $blockSequence => $summaryFields) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->set('hideField', 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
public function getStructure(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($summaryFieldsList) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockSequence = $fieldModel->block->sequence;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockSeqSortSummaryFields[$blockSequence]['SUMMARY_FIELDS'][$fieldName] = $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
* Function to get the values in structured format.
- 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
$summaryFieldsList = $this->getModule()->getSummaryViewFieldsList();
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
if (!empty($fieldsDependency['hide']['frontend']) && \in_array($fieldName, $fieldsDependency['hide']['frontend'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldModel->isViewableInDetailView() && (empty($fieldsDependency['hide']['backend']) || !\in_array($fieldName, $fieldsDependency['hide']['backend']))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$summaryFieldModelsList = array_replace_recursive($summaryFieldModelsList, $summaryFields);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsDependency = \App\FieldsDependency::getByRecordModel('Detail', $recordModel);
- 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
foreach ($summaryFieldsList as $fieldName => $fieldModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$summaryFieldModelsList = [];
- Exclude checks
Class name "Vtiger_SummaryRecordStructure_Model" is not in camel caps format Open
class Vtiger_SummaryRecordStructure_Model extends Vtiger_DetailRecordStructure_Model
- Exclude checks