YetiForceCompany/YetiForceCRM

View on GitHub
app/TextParser/ProductsTableDescription.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

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;
Severity: Minor
Found in app/TextParser/ProductsTableDescription.php - About 1 hr to fix

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);

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;

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;

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()) {

Reference to instance property moduleName from undeclared class \App\TextParser
Open

        $inventory = \Vtiger_Inventory_Model::getInstance($this->textParser->moduleName);

Reference to instance property recordModel from undeclared class \App\TextParser
Open

            $inventoryRows = $this->textParser->recordModel->getInventoryData();

Spaces must be used to indent lines; tabs are not allowed
Open

    public function process()

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string

Spaces must be used to indent lines; tabs are not allowed
Open

        $inventory = \Vtiger_Inventory_Model::getInstance($this->textParser->moduleName);

Spaces must be used to indent lines; tabs are not allowed
Open

        $field = $inventory->getField('name');

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var string Class name */

Spaces must be used to indent lines; tabs are not allowed
Open

    public $type = 'pdf';

Spaces must be used to indent lines; tabs are not allowed
Open

     * Process.

Spaces must be used to indent lines; tabs are not allowed
Open

                }

Spaces must be used to indent lines; tabs are not allowed
Open

            $comments = $inventory->getFieldsByType('Comment');

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

                        $html .= '<br />' . $comment;

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($field->isVisible()) {

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

            $inventoryRows = $this->textParser->recordModel->getInventoryData();

Spaces must be used to indent lines; tabs are not allowed
Open

        $html = '';

Spaces must be used to indent lines; tabs are not allowed
Open

                foreach ($comments as $fieldComment) {

Spaces must be used to indent lines; tabs are not allowed
Open

                    if ($fieldComment->isVisible() && ($value = $inventoryRow[$fieldComment->getColumnName()]) && ($comment = $fieldComment->getDisplayValue($value, $inventoryRow))) {

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!$this->textParser->recordModel->getModule()->isInventory()) {

Spaces must be used to indent lines; tabs are not allowed
Open

            return $html;

Spaces must be used to indent lines; tabs are not allowed
Open

                $html .= $field->getDisplayValue($inventoryRow[$field->getColumnName()], $inventoryRow);

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var mixed Parser type */

Spaces must be used to indent lines; tabs are not allowed
Open

            foreach ($inventoryRows as $inventoryRow) {

Spaces must be used to indent lines; tabs are not allowed
Open

                    }

Line exceeds 120 characters; contains 183 characters
Open

                    if ($fieldComment->isVisible() && ($value = $inventoryRow[$fieldComment->getColumnName()]) && ($comment = $fieldComment->getDisplayValue($value, $inventoryRow))) {

Spaces must be used to indent lines; tabs are not allowed
Open

        return $html;

Spaces must be used to indent lines; tabs are not allowed
Open

    public $name = 'LBL_PRODUCTS_TABLE_DESCRIPTION';

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        }

There are no issues that match your filters.

Category
Status