Function process
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function process()
{
$html = '';
if (!$this->textParser->recordModel->getModule()->isInventory()) {
return $html;
- 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 '\Vtiger_Inventory_Model' in method 'process'. Open
$inventory = \Vtiger_Inventory_Model::getInstance($this->textParser->moduleName);
- 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 '41', column '101'). Open
public function process()
{
$html = '';
if (!$this->textParser->recordModel->getModule()->isInventory()) {
return $html;
- 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 assigning values to variables in if clauses and the like (line '41', column '41'). Open
public function process()
{
$html = '';
if (!$this->textParser->recordModel->getModule()->isInventory()) {
return $html;
- 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
Reference to instance property recordModel
from undeclared class \App\TextParser
Open
if (!$this->textParser->recordModel->getModule()->isInventory()) {
- Exclude checks
Reference to instance property moduleName
from undeclared class \App\TextParser
Open
$inventory = \Vtiger_Inventory_Model::getInstance($this->textParser->moduleName);
- Exclude checks
Reference to instance property recordModel
from undeclared class \App\TextParser
Open
$inventoryRows = $this->textParser->recordModel->getInventoryData();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function process()
- 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 string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$inventory = \Vtiger_Inventory_Model::getInstance($this->textParser->moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$field = $inventory->getField('name');
- 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
/** @var string Class name */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $type = 'pdf';
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$comments = $inventory->getFieldsByType('Comment');
- 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
$html .= '<br />' . $comment;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($field->isVisible()) {
- 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
$inventoryRows = $this->textParser->recordModel->getInventoryData();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($comments as $fieldComment) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldComment->isVisible() && ($value = $inventoryRow[$fieldComment->getColumnName()]) && ($comment = $fieldComment->getDisplayValue($value, $inventoryRow))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->textParser->recordModel->getModule()->isInventory()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $html;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html .= $field->getDisplayValue($inventoryRow[$field->getColumnName()], $inventoryRow);
- 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
/** @var mixed Parser type */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($inventoryRows as $inventoryRow) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 183 characters Open
if ($fieldComment->isVisible() && ($value = $inventoryRow[$fieldComment->getColumnName()]) && ($comment = $fieldComment->getDisplayValue($value, $inventoryRow))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $html;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $name = 'LBL_PRODUCTS_TABLE_DESCRIPTION';
- 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