YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/models/ProcessWizard.php

Summary

Maintainability
D
2 days
Test Coverage
F
0%

Function getFieldsStructure has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

    public function getFieldsStructure(array $block): array
    {
        $fields = [];
        foreach ($block['fields'] as $field) {
            if (\is_array($field) && 'relatedField' === $field['type']) {
Severity: Minor
Found in modules/Vtiger/models/ProcessWizard.php - About 1 day 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

The class Vtiger_ProcessWizard_Model has an overall complexity of 73 which is very high. The configured complexity threshold is 50.
Open

class Vtiger_ProcessWizard_Model extends \App\Base
{
    /**
     * The current process wizard map.
     *

Method getFieldsStructure has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getFieldsStructure(array $block): array
    {
        $fields = [];
        foreach ($block['fields'] as $field) {
            if (\is_array($field) && 'relatedField' === $field['type']) {
Severity: Major
Found in modules/Vtiger/models/ProcessWizard.php - About 2 hrs to fix

    Function loadConditions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function loadConditions(): void
        {
            foreach ($this->wizardMap as $id => &$map) {
                $map['id'] = $id;
                if (isset($map['conditionsStatus'])) {
    Severity: Minor
    Found in modules/Vtiger/models/ProcessWizard.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

    Function getStepBlocks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getStepBlocks(): array
        {
            $blocks = [];
            if ($step = $this->getStep()) {
                foreach ($step['blocks'] as $block) {
    Severity: Minor
    Found in modules/Vtiger/models/ProcessWizard.php - About 45 mins 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

    Function getActions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getActions(): array
        {
            $actions = [];
            if (($step = $this->getStep()) && !empty($step['actions']) && $step['conditionsStatus']) {
                foreach ($step['actions'] as $action) {
    Severity: Minor
    Found in modules/Vtiger/models/ProcessWizard.php - About 45 mins 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

    Function loadGroup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function loadGroup(): void
        {
            if (isset($this->wizardMap[0]['groupConditions'])) {
                foreach ($this->wizardMap as $groupMap) {
                    if (isset($groupMap['groupConditions']) && \App\Condition::checkConditions($groupMap['groupConditions'], $this->recordModel)) {
    Severity: Minor
    Found in modules/Vtiger/models/ProcessWizard.php - About 35 mins 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

    The method getFieldsStructure() has a Cyclomatic Complexity of 29. The configured cyclomatic complexity threshold is 10.
    Open

        public function getFieldsStructure(array $block): array
        {
            $fields = [];
            foreach ($block['fields'] as $field) {
                if (\is_array($field) && 'relatedField' === $field['type']) {

    CyclomaticComplexity

    Since: 0.1

    Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

    Example

    // Cyclomatic Complexity = 11
    class Foo {
    1   public function example() {
    2       if ($a == $b) {
    3           if ($a1 == $b1) {
                    fiddle();
    4           } elseif ($a2 == $b2) {
                    fiddle();
                } else {
                    fiddle();
                }
    5       } elseif ($c == $d) {
    6           while ($c == $d) {
                    fiddle();
                }
    7        } elseif ($e == $f) {
    8           for ($n = 0; $n < $h; $n++) {
                    fiddle();
                }
            } else {
                switch ($z) {
    9               case 1:
                        fiddle();
                        break;
    10              case 2:
                        fiddle();
                        break;
    11              case 3:
                        fiddle();
                        break;
                    default:
                        fiddle();
                        break;
                }
            }
        }
    }

    Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

    Refactor this function to reduce its Cognitive Complexity from 69 to the 15 allowed.
    Open

        public function getFieldsStructure(array $block): array

    Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

    See

    Avoid using static access to class 'App\Record' in method 'getFieldsStructure'.
    Open

                    if ($fieldValue && App\Record::isExists($fieldValue)) {

    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\Record' in method 'getFieldsStructure'.
    Open

                    if ($fieldValue && App\Record::isExists($fieldValue)) {

    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\Condition' in method 'loadConditions'.
    Open

                    $map['conditionsStatus'] = \App\Condition::checkConditions($map['conditions'], $this->recordModel);

    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 '145', column '7').
    Open

        public function getStepBlocks(): array
        {
            $blocks = [];
            if ($step = $this->getStep()) {
                foreach ($step['blocks'] as $block) {

    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 using static access to class '\Vtiger_Record_Model' in method 'getFieldsStructure'.
    Open

                        $relatedRecordModel = \Vtiger_Record_Model::getInstanceById($fieldValue);

    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_Link_Model' in method 'getActions'.
    Open

                        $actions[] = Vtiger_Link_Model::getInstanceFromValues($action);

    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_Relation_Model' in method 'getRelatedListStructure'.
    Open

            $relation = Vtiger_Relation_Model::getInstanceById($block['relationId']);

    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\Record' in method 'getRelatedListReferenceStructure'.
    Open

            if ($fieldValue && App\Record::isExists($fieldValue)) {

    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 'getFieldsStructure'.
    Open

                            $relatedRecordModel2 = \Vtiger_Record_Model::getInstanceById($relatedFieldValue);

    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\Record' in method 'getFieldsStructure'.
    Open

                        if ($relatedFieldValue && App\Record::isExists($relatedFieldValue)) {

    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_Link_Model' in method 'getRelatedListStructure'.
    Open

            $block['relationStructure'] = Vtiger_Link_Model::getInstanceFromValues([
                'linklabel' => $block['label'] ?? $relation->get('label'),
                'linkurl' => $relation->getListUrl($this->recordModel) . ($block['relationConditions'] ?? ''),
                'linkicon' => '',
                'relatedModuleName' => $relation->getRelationModuleName(),

    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 'getRelatedListReferenceStructure'.
    Open

                $relatedRecordModel = \Vtiger_Record_Model::getInstanceById($fieldValue);

    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_Link_Model' in method 'getRelatedListReferenceStructure'.
    Open

                $block['relationStructure'] = Vtiger_Link_Model::getInstanceFromValues([
                    'linklabel' => ($block['label'] ?? $relation->get('label')),
                    'linkurl' => $relation->getListUrl($relatedRecordModel) . ($block['relationConditions'] ?? ''),
                    'linkicon' => '',
                    'relatedModuleName' => $relation->getRelationModuleName(),

    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 'getFieldsStructure'.
    Open

                        $relatedRecordModel = \Vtiger_Record_Model::getInstanceById($this->recordModel->get($field['field']));

    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\Condition' in method 'loadGroup'.
    Open

                    if (isset($groupMap['groupConditions']) && \App\Condition::checkConditions($groupMap['groupConditions'], $this->recordModel)) {

    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\Record' in method 'getFieldsStructure'.
    Open

                    if (App\Record::isExists($this->recordModel->get($field['field']))) {

    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_Relation_Model' in method 'getRelatedListReferenceStructure'.
    Open

                $relation = Vtiger_Relation_Model::getInstanceById($block['relationId']);

    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_Loader' in method 'getInstance'.
    Open

            $className = Vtiger_Loader::getComponentClassName('Model', 'ProcessWizard', $recordModel->getModuleName());

    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 'getFieldsStructure'.
    Open

                        $relatedRecordModel = \Vtiger_Record_Model::getInstanceById($fieldValue);

    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_Field_Model' in method 'getFieldsStructure'.
    Open

                        $fieldModel = \Vtiger_Field_Model::init($this->recordModel->getModuleName(), [
                            'uitype' => 19,
                            'label' => $field['label'],
                            'fieldvalue' => $text,
                            'displaytype' => 10,

    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 getFieldsStructure uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    $fieldModel = $this->recordModel->getField($field);
                    if ($fieldModel && $fieldModel->isViewable()) {
                        $fieldModel->set('fieldvalue', $this->recordModel->get($field));
                        $fields[] = $fieldModel;

    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

    Avoid assigning values to variables in if clauses and the like (line '305', column '8').
    Open

        public function getActions(): array
        {
            $actions = [];
            if (($step = $this->getStep()) && !empty($step['actions']) && $step['conditionsStatus']) {
                foreach ($step['actions'] as $action) {

    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

    Rename "$step" which has the same name as the field declared at line 34.
    Open

            if ($step = $this->getStep()) {

    Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

    Noncompliant Code Example

    class Foo {
      public $myField;
    
      public function doSomething() {
        $myField = 0;
        ...
      }
    }
    

    See

    Define a constant instead of duplicating this literal "field" 4 times.
    Open

                    $fieldValue = $this->recordModel->get($field['field']);

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "relatedField2" 3 times.
    Open

                } elseif (\is_array($field) && 'relatedField2' === $field['type']) {

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Rename "$step" which has the same name as the field declared at line 34.
    Open

            if (($step = $this->getStep()) && !empty($step['actions']) && $step['conditionsStatus']) {

    Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

    Noncompliant Code Example

    class Foo {
      public $myField;
    
      public function doSomething() {
        $myField = 0;
        ...
      }
    }
    

    See

    Define a constant instead of duplicating this literal "conditionsStatus" 5 times.
    Open

                if (isset($map['conditionsStatus'])) {

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "groupConditions" 3 times.
    Open

            if (isset($this->wizardMap[0]['groupConditions'])) {

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Rename "$step" which has the same name as the field declared at line 34.
    Open

            $step = $this->getStep();

    Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

    Noncompliant Code Example

    class Foo {
      public $myField;
    
      public function doSomething() {
        $myField = 0;
        ...
      }
    }
    

    See

    Define a constant instead of duplicating this literal "displaytype" 3 times.
    Open

                            $fieldModel->set('displaytype', 10);

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "label" 12 times.
    Open

                            if (isset($field['label'])) {

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "fieldvalue" 4 times.
    Open

                            $fieldModel->set('fieldvalue', $relatedRecordModel->get($field['relatedField']));

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Add a "case default" clause to this "switch" statement.
    Open

                    switch ($block['type']) {

    The requirement for a final case default clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken. Even when the switch covers all current values of an enum, a default case should still be used because there is no guarantee that the enum won't be extended.

    Noncompliant Code Example

    switch ($param) {  //missing default clause
      case 0:
        do_something();
        break;
      case 1:
        do_something_else();
        break;
    }
    
    switch ($param) {
      default: // default clause should be the last one
        error();
        break;
      case 0:
        do_something();
        break;
      case 1:
        do_something_else();
        break;
    }
    

    Compliant Solution

    switch ($param) {
      case 0:
        do_something();
        break;
      case 1:
        do_something_else();
        break;
      default:
        error();
        break;
    }
    

    See

    • MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
    • MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
    • MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
    • MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
    • MISRA C:2012, 16.1 - All switch statements shall be well-formed
    • MISRA C:2012, 16.4 - Every switch statement shall have a default label
    • MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
    • MITRE, CWE-478 - Missing Default Case in Switch Statement
    • CERT, MSC01-C. - Strive for logical completeness
    • CERT, MSC01-CPP. - Strive for logical completeness

    Define a constant instead of duplicating this literal "relationId" 4 times.
    Open

            $relation = Vtiger_Relation_Model::getInstanceById($block['relationId']);

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "permissionsToStep" 5 times.
    Open

            if (isset($step['permissionsToStep'])) {

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "relatedField" 4 times.
    Open

                if (\is_array($field) && 'relatedField' === $field['type']) {

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Avoid unused local variables such as '$id'.
    Open

            foreach ($this->wizardMap as $id => $map) {

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    Assigning null to property but \Vtiger_ProcessWizard_Model->step is array
    Open

            return $this->step = null;

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                        if ($relatedFieldValue && App\Record::isExists($relatedFieldValue)) {
                            $relatedRecordModel2 = \Vtiger_Record_Model::getInstanceById($relatedFieldValue);
                            $fieldModel = $relatedRecordModel2->getField($field['relatedField2']);
                            if ($fieldModel && $fieldModel->isViewable()) {
                                $fieldModel->set('fieldvalue', $relatedRecordModel2->get($field['relatedField2']));
    Severity: Major
    Found in modules/Vtiger/models/ProcessWizard.php and 1 other location - About 2 hrs to fix
    modules/Vtiger/models/ProcessWizard.php on lines 179..190

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 129.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                    if ($fieldValue && App\Record::isExists($fieldValue)) {
                        $relatedRecordModel = \Vtiger_Record_Model::getInstanceById($fieldValue);
                        $fieldModel = $relatedRecordModel->getField($field['relatedField']);
                        if ($fieldModel && $fieldModel->isViewable()) {
                            $fieldModel->set('fieldvalue', $relatedRecordModel->get($field['relatedField']));
    Severity: Major
    Found in modules/Vtiger/models/ProcessWizard.php and 1 other location - About 2 hrs to fix
    modules/Vtiger/models/ProcessWizard.php on lines 219..230

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 129.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Each class must be in a namespace of at least one level (a top-level vendor name)
    Open

    class Vtiger_ProcessWizard_Model extends \App\Base

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

        public function setStep(int $id): void

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    The class Vtiger_ProcessWizard_Model is not named in CamelCase.
    Open

    class Vtiger_ProcessWizard_Model extends \App\Base
    {
        /**
         * The current process wizard map.
         *

    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

         * @var Vtiger_Record_Model

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

         */

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

         * @param Vtiger_Record_Model $recordModel

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

         *

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

        public function loadGroup(): void

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

            $instance->loadConditions();

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

        protected $recordModel;

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

         * Get instance model.

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

            return $instance;

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

                $instance->load();

    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

        }

    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

         */

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

        public static function getInstance(Vtiger_Record_Model $recordModel): self

    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 void

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

         * @var array

    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 self

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

         *

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

            if (isset($this->wizardMap[0]['groupConditions'])) {

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

            }

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

                foreach ($this->wizardMap as $groupMap) {

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

         * Current process step.

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

            $className = Vtiger_Loader::getComponentClassName('Model', 'ProcessWizard', $recordModel->getModuleName());

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

         * Load current map group.

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

         * The current process wizard map.

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

            $instance->loadGroup();

    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 array

    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

        /**

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

                    if (isset($groupMap['groupConditions']) && \App\Condition::checkConditions($groupMap['groupConditions'], $this->recordModel)) {

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

            }

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

            foreach ($this->wizardMap as $id => &$map) {

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

        }

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

         * Set the active step of the process wizard.

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

         *

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

                            break;

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

                        case 'relatedListsFromReference':

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

                            $blocks[] = $block;

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

            }

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

                                if ($fieldModel->isViewable() && '' !== $relatedRecordModel->get($relatedField)) {

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

        /**

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

        protected $step;

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

            if (method_exists($instance, 'load')) {

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

        protected $wizardMap;

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

            $instance = new $className();

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

            $instance->recordModel = $recordModel;

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

                        $this->wizardMap = $groupMap['group'];

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

         * Get active process wizard step.

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

        }

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

                            $blocks[] = $this->getFieldsStructure($block);

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

                            break;

    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

         * Vtiger_Record_Model.

    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

         *

    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 $this->wizardMap;

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

         * @return array|null

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

                foreach ($step['blocks'] as $block) {

    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 array

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

        public function getFieldsStructure(array $block): array

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

                        $fieldModel = $relatedRecordModel->getField($field['relatedField']);

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

                            $fieldModel->set('fieldvalue', $relatedRecordModel->get($field['relatedField']));

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

                            'displaytype' => 10,

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

                $this->wizardMap = [];

    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

                        $relatedRecordModel = \Vtiger_Record_Model::getInstanceById($fieldValue);

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

                        if ($fieldModel && $fieldModel->isViewable()) {

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

                        $relatedRecordModel = \Vtiger_Record_Model::getInstanceById($this->recordModel->get($field['field']));

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

                                }

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

                            'isViewableInDetailView' => true,

    Line exceeds 120 characters; contains 143 characters
    Open

                    if (isset($groupMap['groupConditions']) && \App\Condition::checkConditions($groupMap['groupConditions'], $this->recordModel)) {

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

            }

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

         * Get process wizard steps.

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

            foreach ($this->wizardMap as $id => $map) {

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

         */

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

                            break;

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

                        case '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

         * @param array $block

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

                            if (isset($field['label'])) {

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

         * @return void

    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

         */

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

         * @return void

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

        public function setStep(int $id): void

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

            if (empty($this->getStep()) || $id < $this->getStep()['id']) {

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

        /**

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

         * Get the blocks of the current step.

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

                        $text = '';

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

                            'uitype' => 19,

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

                        ], $field['name']);

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

                } elseif (\is_array($field) && 'relatedField2' === $field['type']) {

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

        /**

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

        public function loadConditions(): void

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

                if (isset($map['conditions'])) {

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

        public function getStep(): ?array

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

                    switch ($block['type']) {

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

                            $blocks[] = $this->getRelatedListReferenceStructure($block);

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

         *

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

                    $fieldValue = $this->recordModel->get($field['field']);

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

                        $fields[] = $fieldModel;

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

                return $this->step;

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

                $this->step = $this->wizardMap[$id];

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

                            $blocks[] = $this->getRelatedListStructure($block);

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

                        foreach ($field['relatedFields'] as $relatedField) {

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

                                    $text .= $fieldModel->getDisplayValue($relatedRecordModel->get($relatedField), false, false, true) . ' ';

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

                            'fieldvalue' => $text,

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

                    }

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

                    $map['conditionsStatus'] = \App\Condition::checkConditions($map['conditions'], $this->recordModel);

    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 $this->step = $map;

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

            }

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

            if ($step = $this->getStep()) {

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

            $fields = [];

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

                    if ($fieldValue && App\Record::isExists($fieldValue)) {

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

                                $fieldModel->set('label', $field['label']);

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

                    if ($fieldValue && App\Record::isExists($fieldValue)) {

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

         * Load and check the process wizard conditions.

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

         *

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

            if (isset($this->step)) {

    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

         * @return array

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

        {

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

                        case 'fields':

    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

                    }

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

                    if (App\Record::isExists($this->recordModel->get($field['field']))) {

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

                                $text .= PHP_EOL;

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

                            'label' => $field['label'],

    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

        /**

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

         *

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

                        case 'relatedLists':

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

         */

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

            foreach ($block['fields'] as $field) {

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

                } elseif (\is_array($field) && 'relatedMergedFields' === $field['type']) {

    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 $block;

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

                    'relatedModuleName' => $relation->getRelationModuleName(),

    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

                            break;

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

                    }

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

         * Get fields structure for fields block type.

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

                        $fields[] = $fieldModel;

    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

         * @return array

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

                'relationId' => $relation->getId(),

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

         * @param array $block

    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

         */

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

        public function getActions(): array

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

                    continue;

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

                }

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

                if ($map['conditionsStatus']) {

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

         */

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

            $blocks = [];

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

                if (\is_array($field) && 'relatedField' === $field['type']) {

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

                            if ($fieldModel) {

    Line exceeds 120 characters; contains 137 characters
    Open

                                    $text .= $fieldModel->getDisplayValue($relatedRecordModel->get($relatedField), false, false, true) . ' ';

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

                        }

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

                    $fieldValue = $this->recordModel->get($field['field']);

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

                        }

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

                } else {

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

        }

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

                'relatedModuleName' => $relation->getRelationModuleName(),

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

                    'relationId' => $relation->getId(),

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

         *

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

            $block['relationStructure'] = Vtiger_Link_Model::getInstanceFromValues([

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

                'linkurl' => $relation->getListUrl($this->recordModel) . ($block['relationConditions'] ?? ''),

    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

            return $block;

    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 array

    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

                }

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

         *

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

        public function getSteps(): array

    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 $blocks;

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

                        }

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

                        $fieldModel = \Vtiger_Field_Model::init($this->recordModel->getModuleName(), [

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

                        $relatedRecordModel = \Vtiger_Record_Model::getInstanceById($fieldValue);

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

            $block['fieldsStructure'] = $fields;

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

         * @param array $block

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

                    'linkurl' => $relation->getListUrl($relatedRecordModel) . ($block['relationConditions'] ?? ''),

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

                    'linkicon' => '',

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

         * Get the actions of the current step..

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

         * @return bool

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

                    return $step['permissionsToStep'];

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

                if (\is_callable($step['permissionsToStep'])) {

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

        }

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

                        $relatedFieldValue = $relatedRecordModel->get($field['relatedField']);

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

        /**

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

                $block['icon'] = '';

    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

            if (($step = $this->getStep()) && !empty($step['actions']) && $step['conditionsStatus']) {

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

                foreach ($step['actions'] as $action) {

    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 $actions;

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

                    return \call_user_func($step['permissionsToStep']);

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

                        return;

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

         */

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

                $map['id'] = $id;

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

                    if ($map['conditionsStatus']) {

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

                        break;

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

                }

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

         * @param int $id

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

        public function getStepBlocks(): array

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

        }

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

                            $fieldModel->set('displaytype', 10);

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

                            $fields[] = $fieldModel;

    Line exceeds 120 characters; contains 122 characters
    Open

                        $relatedRecordModel = \Vtiger_Record_Model::getInstanceById($this->recordModel->get($field['field']));

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

                            $relatedRecordModel2 = \Vtiger_Record_Model::getInstanceById($relatedFieldValue);

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

                            $fieldModel = $relatedRecordModel2->getField($field['relatedField2']);

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

            return $block;

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

        public function getRelatedListReferenceStructure(array $block): array

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

                }

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

                if (isset($map['conditionsStatus'])) {

    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 array

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

            return $this->step = null;

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

                            $fieldModel = $relatedRecordModel->getField($relatedField);

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

                            } elseif ('__EOL__' === $relatedField) {

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

                    }

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

                            if ($fieldModel && $fieldModel->isViewable()) {

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

                                $fieldModel->set('displaytype', 10);

    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

         * @return array

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

         */

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

                $block['relationStructure'] = Vtiger_Link_Model::getInstanceFromValues([

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

         * Check permissions to step.

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

                                $fieldModel->set('fieldvalue', $relatedRecordModel2->get($field['relatedField2']));

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

                                    $fieldModel->set('label', $field['label']);

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

            if ($fieldValue && App\Record::isExists($fieldValue)) {

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

            if (empty($block['icon'])) {

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

            $actions = [];

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

                        $actions[] = Vtiger_Link_Model::getInstanceFromValues($action);

    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

        {

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

         *

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

                $relatedRecordModel = \Vtiger_Record_Model::getInstanceById($fieldValue);

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

                $block['icon'] = '';

    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

            if (empty($block['icon'])) {

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

        /**

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

                    'linklabel' => ($block['label'] ?? $relation->get('label')),

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

        /**

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

                    if ($fieldModel && $fieldModel->isViewable()) {

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

                'linkicon' => '',

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

        public function checkPermissionsToStep(): bool

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

                                if (isset($field['label'])) {

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

                                $fields[] = $fieldModel;

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

                            }

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

         * Get structure for related lists block type.

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

        public function getRelatedListStructure(array $block): array

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

            $relation = Vtiger_Relation_Model::getInstanceById($block['relationId']);

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

                    if (!isset($action['permissions']) || $action['permissions']) {

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

        {

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

                if (\is_bool($step['permissionsToStep'])) {

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

            return true;

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

                    $fieldModel = $this->recordModel->getField($field);

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

                        $fieldModel->set('fieldvalue', $this->recordModel->get($field));

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

                        if ($relatedFieldValue && App\Record::isExists($relatedFieldValue)) {

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

            if (empty($block['icon'])) {

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

            }

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

         * Get structure for related lists block type for reference record.

    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

                $relation = Vtiger_Relation_Model::getInstanceById($block['relationId']);

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

            $step = $this->getStep();

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

                ]);

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

            if (isset($step['permissionsToStep'])) {

    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

            }

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

                $block['icon'] = '';

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

         *

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

                'linklabel' => $block['label'] ?? $relation->get('label'),

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

            $fieldValue = $this->recordModel->get($block['referenceField']);

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

                    }

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

         */

    Class name "Vtiger_ProcessWizard_Model" is not in camel caps format
    Open

    class Vtiger_ProcessWizard_Model extends \App\Base

    There are no issues that match your filters.

    Category
    Status