YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/widgets/RelatedModule.php

Summary

Maintainability
B
6 hrs
Test Coverage
F
11%

Function getWidget has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public function getWidget()
    {
        $widget = [];
        $model = Vtiger_Module_Model::getInstance($this->Data['relatedmodule']);
        if ($model && $model->isPermitted('DetailView')) {
Severity: Minor
Found in modules/Vtiger/widgets/RelatedModule.php - About 3 hrs 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

Method getWidget has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getWidget()
    {
        $widget = [];
        $model = Vtiger_Module_Model::getInstance($this->Data['relatedmodule']);
        if ($model && $model->isPermitted('DetailView')) {
Severity: Major
Found in modules/Vtiger/widgets/RelatedModule.php - About 2 hrs to fix

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

        public function getUrl()
        {
            $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];
            $url = 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showRelatedRecords&relatedModule=' . $moduleName . '&page=1&limit=' . $this->Data['limit'] . '&viewType=' . $this->Data['viewtype'] . '&relationId=' . $this->Data['relation_id'];
            if (isset($this->Data['no_result_text'])) {
    Severity: Minor
    Found in modules/Vtiger/widgets/RelatedModule.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 getWidget() has an NPath complexity of 242. The configured NPath complexity threshold is 200.
    Open

        public function getWidget()
        {
            $widget = [];
            $model = Vtiger_Module_Model::getInstance($this->Data['relatedmodule']);
            if ($model && $model->isPermitted('DetailView')) {

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

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

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

        public function getWidget()
        {
            $widget = [];
            $model = Vtiger_Module_Model::getInstance($this->Data['relatedmodule']);
            if ($model && $model->isPermitted('DetailView')) {

    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 31 to the 15 allowed.
    Open

        public function getWidget()

    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 undefined variables such as '$whereOnCondition' which will lead to PHP notices.
    Open

                    $this->Config['checkbox']['on'] = \App\Json::encode($whereOnCondition);

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$whereOnCondition' which will lead to PHP notices.
    Open

                    $whereOnCondition[] = [$columnName, 'e', 1];

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$whereOnCondition' which will lead to PHP notices.
    Open

                    $whereCondition = [$whereOnCondition];

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$whereOffCondition' which will lead to PHP notices.
    Open

                    $whereOffCondition[] = [$columnName, 'e', 0];

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$whereOffCondition' which will lead to PHP notices.
    Open

                    $this->Config['checkbox']['off'] = \App\Json::encode($whereOffCondition);

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using static access to class '\App\Json' in method 'getUrl'.
    Open

                $url .= '&orderby=' . \App\Json::encode($this->Data['orderby']);

    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\Module' in method 'getUrl'.
    Open

            $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

    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_Module_Model' in method 'getWidget'.
    Open

            $model = Vtiger_Module_Model::getInstance($this->Data['relatedmodule']);

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

                    } else {
                        $url = $model->getQuickCreateUrl();
                    }

    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 using static access to class '\App\Json' in method 'getWidget'.
    Open

                        $this->Config['switchHeader']['off'] = \App\Json::encode($whereConditionOff);

    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\Language' in method 'getCheckboxLables'.
    Open

            $translateOff = \App\Language::translate($off, $model->getName());

    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 'Settings_Widgets_Module_Model' in method 'getWidget'.
    Open

                    $switchHeaderData = Settings_Widgets_Module_Model::getHeaderSwitch($this->Module, [$this->Data['relatedmodule'], $this->Data['switchHeader']]);

    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\Language' in method 'getCheckboxLables'.
    Open

                $translateOff = \App\Language::translate('LBL_NO', $model->getName());

    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\Module' in method 'getApiData'.
    Open

            $relModuleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

    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\Json' in method 'getWidget'.
    Open

                        $this->Config['switchHeader']['on'] = \App\Json::encode($whereCondition);

    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\Json' in method 'getWidget'.
    Open

                    $this->Config['url'] .= '&search_params=' . \App\Json::encode($whereCondition);

    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\Json' in method 'getWidget'.
    Open

                    $this->Config['checkbox']['on'] = \App\Json::encode($whereOnCondition);

    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\Language' in method 'getCheckboxLables'.
    Open

                $translateOn = \App\Language::translate('LBL_YES', $model->getName());

    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\Privilege' in method 'getApiData'.
    Open

            if (!\App\Privilege::isPermitted($row['data']['relatedModuleName'])) {

    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\Language' in method 'getCheckboxLables'.
    Open

            $translateOn = \App\Language::translate($on, $model->getName());

    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\Json' in method 'getWidget'.
    Open

                    $this->Config['checkbox']['off'] = \App\Json::encode($whereOffCondition);

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

                    } else {
                        $columnName = $this->Data['checkbox'];
                    }

    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 using static access to class '\App\Language' in method 'getApiData'.
    Open

            $row['name'] = \App\Language::translate($row['label'] ?: $relModuleName, $relModuleName, false, false);

    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

    Define a constant instead of duplicating this literal "checkbox" 8 times.
    Open

                if (isset($this->Data['checkbox']) && '-' !== $this->Data['checkbox']) {

    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 "relatedmodule" 8 times.
    Open

            $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

    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 "relatedfields" 3 times.
    Open

            if (!empty($this->Data['relatedfields'])) {

    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 "switchHeader" 6 times.
    Open

                if (isset($this->Data['switchHeader']) && '-' != $this->Data['switchHeader']) {

    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.

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

            if (!empty($this->Data['relatedfields'])) {

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

            $url = 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showRelatedRecords&relatedModule=' . $moduleName . '&page=1&limit=' . $this->Data['limit'] . '&viewType=' . $this->Data['viewtype'] . '&relationId=' . $this->Data['relation_id'];

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

            if (!empty($this->Data['customView'])) {

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

                $url .= '&orderby=' . \App\Json::encode($this->Data['orderby']);

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

                $url .= '&no_result_text=' . $this->Data['no_result_text'];

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

            if (!empty($this->Data['orderby'])) {

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

                if (isset($this->Data['switchHeader']) && '-' != $this->Data['switchHeader']) {

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

                        $columnName = $this->Data['checkbox'];

    Argument 2 (moduleName) is false but \App\Language::translate() takes string defined at /code/app/Language.php:161
    Open

                $translateOn = \App\Language::translate('LBL_YES', $model->getName());

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data (Did you mean $data)
    Open

            $relModuleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

            $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

            $on = $prefix . 'ON_' . strtoupper($this->Data[$type]);

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

                    if (false !== strpos($this->Data['checkbox'], '.')) {

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

                if (1 == $this->Data['action']) {

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

            $model = Vtiger_Module_Model::getInstance($this->Data['relatedmodule']);

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

                    $this->Config['actionURL'] = $url . "&sourceRecord={$this->Record}&sourceModule={$this->Module}&relationOperation=true&relationId=" . $this->Data['relation_id'];

    Variable $whereOffCondition was undeclared, but array fields are being added to it.
    Open

                    $whereOffCondition[] = [$columnName, 'e', 0];

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

            $data = $this->Data;

    Suspicious type false of a variable or expression used to build a string. (Expected type to be able to cast to a string)
    Open

                    $this->Config['actionURL'] = $url . "&sourceRecord={$this->Record}&sourceModule={$this->Module}&relationOperation=true&relationId=" . $this->Data['relation_id'];

    Variable $whereOnCondition was undeclared, but array fields are being added to it.
    Open

                    $whereOnCondition[] = [$columnName, 'e', 1];

    Argument 2 (moduleName) is false but \App\Language::translate() takes string defined at /code/app/Language.php:161
    Open

                $translateOff = \App\Language::translate('LBL_NO', $model->getName());

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

                $cvId = reset($this->Data['customView']);

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

            $off = $prefix . 'OFF_' . strtoupper($this->Data[$type]);

    Argument 2 (moduleName) is false but \App\Language::translate() takes string defined at /code/app/Language.php:161
    Open

            $translateOn = \App\Language::translate($on, $model->getName());

    Argument 2 (moduleName) is false but \App\Language::translate() takes string defined at /code/app/Language.php:161
    Open

            $translateOff = \App\Language::translate($off, $model->getName());

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

                foreach ((array) $this->Data['relatedfields'] as $field) {

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

            if (isset($this->Data['no_result_text'])) {

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

                if (isset($this->Data['checkbox']) && '-' !== $this->Data['checkbox']) {

    Argument 3 (language) is false but \App\Language::translate() takes null|string defined at /code/app/Language.php:161
    Open

            $row['name'] = \App\Language::translate($row['label'] ?: $relModuleName, $relModuleName, false, false);

    Suspicious type false of a variable or expression used to build a string. (Expected type to be able to cast to a string)
    Open

            $url = 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showRelatedRecords&relatedModule=' . $moduleName . '&page=1&limit=' . $this->Data['limit'] . '&viewType=' . $this->Data['viewtype'] . '&relationId=' . $this->Data['relation_id'];

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

                        $separateData = explode('.', $this->Data['checkbox']);

    Reference to undeclared property \Vtiger_RelatedModule_Widget->Data
    Open

                    $switchHeaderData = Settings_Widgets_Module_Model::getHeaderSwitch($this->Module, [$this->Data['relatedmodule'], $this->Data['switchHeader']]);

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

    class Vtiger_RelatedModule_Widget extends Vtiger_Basic_Widget

    The class Vtiger_RelatedModule_Widget is not named in CamelCase.
    Open

    class Vtiger_RelatedModule_Widget extends Vtiger_Basic_Widget
    {
        public function getUrl()
        {
            $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

    CamelCaseClassName

    Since: 0.2

    It is considered best practice to use the CamelCase notation to name classes.

    Example

    class class_name {
    }

    Source

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

            $on = $prefix . 'ON_' . strtoupper($this->Data[$type]);

    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

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

            if (!empty($this->Data['orderby'])) {

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

            if (!empty($this->Data['customView'])) {

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

            $url = 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showRelatedRecords&relatedModule=' . $moduleName . '&page=1&limit=' . $this->Data['limit'] . '&viewType=' . $this->Data['viewtype'] . '&relationId=' . $this->Data['relation_id'];

    Line exceeds 120 characters; contains 269 characters
    Open

            $url = 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showRelatedRecords&relatedModule=' . $moduleName . '&page=1&limit=' . $this->Data['limit'] . '&viewType=' . $this->Data['viewtype'] . '&relationId=' . $this->Data['relation_id'];

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

            $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

    Line exceeds 120 characters; contains 152 characters
    Open

            $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

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

                $cvId = reset($this->Data['customView']);

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

            }

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

                $url .= '&cvId=' . $cvId;

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

        public function getUrl()

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

            }

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

                $url .= '&no_result_text=' . $this->Data['no_result_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

            if (isset($this->Data['no_result_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

        public function getWidget()

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

            if ($model && $model->isPermitted('DetailView')) {

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

                $this->Config['tpl'] = 'Basic.tpl';

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

                if (isset($this->Data['switchHeader']) && '-' != $this->Data['switchHeader']) {

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

                    if ($switchHeaderData && 1 === $switchHeaderData['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

                    $whereOnCondition[] = [$columnName, 'e', 1];

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

                    $this->Config['url'] .= '&search_params=' . \App\Json::encode($whereCondition);

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

                $widget = $this->Config;

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

                $widget['instance'] = $this;

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

        }

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

            $off = $prefix . 'OFF_' . strtoupper($this->Data[$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 getConfigTplName()

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

        }

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

            $widget = [];

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

                            $whereConditionOff[] = [$name, 'e', implode('##', $value)];

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

            }

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

            $data['relatedModuleName'] = $relModuleName;

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

                        $whereConditionOff = [];

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

            return $widget;

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

            $relModuleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

    Line exceeds 120 characters; contains 155 characters
    Open

            $relModuleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

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

            }

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

                    $fields[] = $fieldName;

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

            $model = Vtiger_Module_Model::getInstance($this->Data['relatedmodule']);

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

                if (1 == $this->Data['action']) {

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

                    $switchHeaderData = Settings_Widgets_Module_Model::getHeaderSwitch($this->Module, [$this->Data['relatedmodule'], $this->Data['switchHeader']]);

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

                        $this->getCheckboxLables($model, 'switchHeader', 'LBL_SWITCHHEADER_');

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

                        foreach ($switchHeaderData['value'] as $name => $value) {

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

                        $this->Config['switchHeader']['off'] = \App\Json::encode($whereConditionOff);

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

                    $whereOffCondition[] = [$columnName, 'e', 0];

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

                    $this->Config['checkbox']['on'] = \App\Json::encode($whereOnCondition);

    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

            $translateOn = \App\Language::translate($on, $model->getName());

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

                $translateOn = \App\Language::translate('LBL_YES', $model->getName());

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

            if ($on === $translateOn) {

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

        }

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

            $data = $this->Data;

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

            $row['name'] = \App\Language::translate($row['label'] ?: $relModuleName, $relModuleName, false, false);

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

                foreach ((array) $this->Data['relatedfields'] as $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

                $this->Config['isQuickCreateSupport'] = $isQuickCreateSupport;

    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 [];

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

            return $row;

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

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

                        $url = $model->getQuickCreateUrl();

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

                        $this->Config['switchHeader']['on'] = \App\Json::encode($whereCondition);

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

            $on = $prefix . 'ON_' . strtoupper($this->Data[$type]);

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

            if ($off === $translateOff) {

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

                $translateOff = \App\Language::translate('LBL_NO', $model->getName());

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

            }

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

                $url .= '&fields=' . implode(',', $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

                if (isset($this->Data['checkbox']) && '-' !== $this->Data['checkbox']) {

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

                        $columnName = $this->Data['checkbox'];

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

            $translateOff = \App\Language::translate($off, $model->getName());

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

            if ($fields) {

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

            return $url;

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

                            $whereCondition[] = [$name, 'n', implode('##', $value)];

    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

                $fieldName = explode('::', $fieldName)[1];

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

        {

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

                    $createPermission = $model->isPermitted('CreateView');

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

                        $url = $model->getCreateRecordUrl();

    Line exceeds 120 characters; contains 177 characters
    Open

                    $this->Config['actionURL'] = $url . "&sourceRecord={$this->Record}&sourceModule={$this->Module}&relationOperation=true&relationId=" . $this->Data['relation_id'];

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

                    $this->getCheckboxLables($model, 'checkbox', 'LBL_SWITCH_');

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

                if (!empty($whereCondition)) {

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

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

        public function getCheckboxLables($model, $type, $prefix)

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

            $this->Config[$type . 'Lables'] = ['on' => $translateOn, 'off' => $translateOff];

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

            return 'RelatedModuleConfig';

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

            foreach ($data['relatedfields'] as &$fieldName) {

    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

                }

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

            }

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

                    $this->Config['action'] = (true === $createPermission) ? 1 : 0;

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

                }

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

                        $columnName = $separateData[1];

    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

                $row = [];

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

                $url .= '&orderby=' . \App\Json::encode($this->Data['orderby']);

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

                $this->Config['url'] = $this->getUrl();

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

                    $this->Config['actionURL'] = $url . "&sourceRecord={$this->Record}&sourceModule={$this->Module}&relationOperation=true&relationId=" . $this->Data['relation_id'];

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

                        $whereCondition = [$whereCondition];

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

                    if (false !== strpos($this->Data['checkbox'], '.')) {

    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

         * @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

                $whereCondition = [];

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

                $isQuickCreateSupport = !$model->isQuickCreateSupported();

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

                    }

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

                        $separateData = explode('.', $this->Data['checkbox']);

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

                    $this->Config['checkbox']['off'] = \App\Json::encode($whereOffCondition);

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

        /** {@inheritdoc} */

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

                    [, $fieldName] = explode('::', $field);

    Line exceeds 120 characters; contains 159 characters
    Open

                    $switchHeaderData = Settings_Widgets_Module_Model::getHeaderSwitch($this->Module, [$this->Data['relatedmodule'], $this->Data['switchHeader']]);

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

                    $whereCondition = [$whereOnCondition];

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

                $this->Config['buttonHeader'] = $this->getHeaderButtons();

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

        public function getApiData(array $row): array

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

            $row['data'] = $data;

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

            if (!\App\Privilege::isPermitted($row['data']['relatedModuleName'])) {

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

            if (!empty($this->Data['relatedfields'])) {

    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

         * Gets buttons.

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

    class Vtiger_RelatedModule_Widget extends Vtiger_Basic_Widget

    There are no issues that match your filters.

    Category
    Status