YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/WebserviceUsers/services/WebservicePremium.php

Summary

Maintainability
C
7 hrs
Test Coverage
F
0%

Method getFieldInstanceByName has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getFieldInstanceByName($name)
    {
        $moduleName = $this->getModule()->getName(true);
        $fieldsLabel = $this->getEditFields();
        $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'label' => $fieldsLabel[$name], 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];
Severity: Major
Found in modules/Settings/WebserviceUsers/services/WebservicePremium.php - About 2 hrs to fix

    Function getFieldInstanceByName has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getFieldInstanceByName($name)
        {
            $moduleName = $this->getModule()->getName(true);
            $fieldsLabel = $this->getEditFields();
            $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'label' => $fieldsLabel[$name], 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];
    Severity: Minor
    Found in modules/Settings/WebserviceUsers/services/WebservicePremium.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 setDataFromRequest has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function setDataFromRequest(App\Request $request)
        {
            foreach (array_keys($this->getEditFields()) as $field) {
                if ($request->has($field)) {
                    switch ($field) {
    Severity: Minor
    Found in modules/Settings/WebserviceUsers/services/WebservicePremium.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

    Method setDataFromRequest has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function setDataFromRequest(App\Request $request)
        {
            foreach (array_keys($this->getEditFields()) as $field) {
                if ($request->has($field)) {
                    switch ($field) {
    Severity: Minor
    Found in modules/Settings/WebserviceUsers/services/WebservicePremium.php - About 1 hr to fix

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

          public function getFieldInstanceByName($name)
          {
              $moduleName = $this->getModule()->getName(true);
              $fieldsLabel = $this->getEditFields();
              $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'label' => $fieldsLabel[$name], 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];

      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

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

          public function setDataFromRequest(App\Request $request)
          {
              foreach (array_keys($this->getEditFields()) as $field) {
                  if ($request->has($field)) {
                      switch ($field) {

      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

      Missing class import via use statement (line '166', column '16').
      Open

                          throw new \App\Exceptions\Security("ERR_ILLEGAL_FIELD_VALUE||{$field}", 406);

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '160', column '18').
      Open

                                  throw new \App\Exceptions\Security("ERR_ILLEGAL_FIELD_VALUE||{$field}", 406);

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Avoid using static access to class '\App\Language' in method 'getFieldInstanceByName'.
      Open

                          'PLL_PASSWORD_2FA' => \App\Language::translate('PLL_PASSWORD_2FA', 'Users'),

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

                          '-' => \App\Language::translate('LBL_NONE'),

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

                      $params['picklistValues'] = \App\Language::getAll();

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

                          'PLL_AUTHY_TOTP' => \App\Language::translate('PLL_AUTHY_TOTP', 'Users'),

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

                          'PLL_PASSWORD' => \App\Language::translate('PLL_PASSWORD', 'Users'),

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

                      $params['picklistValues'] = [1 => \App\Language::translate('FL_ACTIVE'), 0 => \App\Language::translate('FL_INACTIVE')];

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

                          $params['picklistValues'][$key] = \App\Language::translate($value, $moduleName);

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class 'App\Encryption' in method 'getValueToSave'.
      Open

                      $value = App\Encryption::createPasswordHash($value, 'WebservicePremium');

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

                      $params['picklistValues'] = [1 => \App\Language::translate('FL_ACTIVE'), 0 => \App\Language::translate('FL_INACTIVE')];

      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_WebserviceApps_Module_Model' in method 'getFieldInstanceByName'.
      Open

                      $servers = Settings_WebserviceApps_Module_Model::getActiveServers($this->getModule()->typeApi);

      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_Vtiger_Field_Model' in method 'getFieldInstanceByName'.
      Open

              return $params ? Settings_Vtiger_Field_Model::init($moduleName, $params) : null;

      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 "typeofdata" 5 times.
      Open

              $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'label' => $fieldsLabel[$name], 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];

      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 "istorage" 5 times.
      Open

              'istorage' => 'FL_STORAGE',

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

              'language' => 'FL_LANGUAGE',

      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 "picklistValues" 9 times.
      Open

                      $params['picklistValues'] = [1 => \App\Language::translate('FL_ACTIVE'), 0 => \App\Language::translate('FL_INACTIVE')];

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

              'authy_methods' => 'FL_AUTHY_METHODS',

      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 "uitype" 11 times.
      Open

              $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'label' => $fieldsLabel[$name], 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];

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

              'status' => 'FL_STATUS',

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

              'status' => 'FL_STATUS',

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

              'crmid' => 'FL_RECORD_NAME',

      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 "login_method" 4 times.
      Open

              'login_method' => 'FL_LOGIN_METHOD',

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

                          'PLL_PASSWORD' => \App\Language::translate('PLL_PASSWORD', 'Users'),

      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 "server_id" 5 times.
      Open

              'server_id' => 'FL_SERVER',

      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 "password" 4 times.
      Open

              'password' => 'FL_PASSWORD',

      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 "user_id" 5 times.
      Open

              'user_id' => 'FL_USER',

      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.

      Returning type \Vtiger_Field_Model but getFieldInstanceByName() is declared to return string[]
      Open

              return $params ? Settings_Vtiger_Field_Model::init($moduleName, $params) : null;

      Call to method createPasswordHash from undeclared class \App\Encryption (Did you mean class \Tests\App\Encryption)
      Open

                      $value = App\Encryption::createPasswordHash($value, 'WebservicePremium');

      Call to method getInstance from undeclared class \App\Fields\Owner
      Open

                      $params['picklistValues'] = \App\Fields\Owner::getInstance($moduleName)->getAccessibleUsers('', 'owner');

      Returning type null but getFieldInstanceByName() is declared to return string[]
      Open

              return $params ? Settings_Vtiger_Field_Model::init($moduleName, $params) : null;

      Remove the code after this "throw".
      Open

                          throw new \App\Exceptions\Security("ERR_ILLEGAL_FIELD_VALUE||{$field}", 406);

      Jump statements (return, break, continue, and goto) and throw expressions move control flow out of the current code block. Typically, any statements in a block that come after a jump or throw are simply wasted keystrokes lying in wait to confuse the unwary.

      Rarely, as illustrated below, code after a jump or throw is reachable. However, such code is difficult to understand, and should be refactored.

      Noncompliant Code Example

      function fun($a) {
        $i = 10;
        return $i + $a;
        $i++;             // this is never executed
      }
      
      function foo($a) {
        if ($a == 5) {
          goto error;
        } else {
          // do the job
        }
        return;
      
        error:
          printf("don't use 5"); // this is reachable but unreadable
      
      }
      

      Compliant Solution

      function fun($a) {
        $i = 10;
        return $i + $a;
      }
      
      function foo($a) {
        if ($a == 5) {
          handleError();
        } else {
          // do the job
        }
        return;
      }
      

      See

      • MISRA C:2004, 14.1 - There shall be no unreachable code
      • MISRA C++:2008, 0-1-1 - A project shall not contain unreachable code
      • MISRA C++:2008, 0-1-9 - There shall be no dead code
      • MISRA C:2012, 2.1 - A project shall not contain unreachable code
      • MISRA C:2012, 2.2 - There shall be no dead code
      • MITRE, CWE-561 - Dead Code
      • CERT, MSC56-J. - Detect and remove superfluous code and values
      • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
      • CERT, MSC07-CPP. - Detect and remove dead code

      Avoid excessively long class names like Settings_WebserviceUsers_WebservicePremium_Service. Keep class name length under 40.
      Open

      class Settings_WebserviceUsers_WebservicePremium_Service extends Settings_WebserviceUsers_WebserviceStandard_Service
      {
          /** {@inheritdoc} */
          public $baseTable = 'w_#__portal_user';
      
      

      LongClassName

      Since: 2.9

      Detects when classes or interfaces are declared with excessively long names.

      Example

      class ATooLongClassNameThatHintsAtADesignProblem {
      
      }
      
      interface ATooLongInterfaceNameThatHintsAtADesignProblem {
      
      }

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

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

      class Settings_WebserviceUsers_WebservicePremium_Service extends Settings_WebserviceUsers_WebserviceStandard_Service

      The class Settings_WebserviceUsers_WebservicePremium_Service is not named in CamelCase.
      Open

      class Settings_WebserviceUsers_WebservicePremium_Service extends Settings_WebserviceUsers_WebserviceStandard_Service
      {
          /** {@inheritdoc} */
          public $baseTable = 'w_#__portal_user';
      
      

      CamelCaseClassName

      Since: 0.2

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

      Example

      class class_name {
      }

      Source

      Terminating statement must be on a line by itself
      Open

                  default: break;

      Terminating statement must be indented to the same level as the CASE body
      Open

                          throw new \App\Exceptions\Security("ERR_ILLEGAL_FIELD_VALUE||{$field}", 406);

      The DEFAULT body must start on the line following the statement
      Open

                  default: break;

      Terminating statement must be on a line by itself
      Open

                  default: break;

      The DEFAULT body must start on the line following the statement
      Open

                  default: break;

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

              'crmid' => 'FL_RECORD_NAME',

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

              $fieldsLabel = $this->getEditFields();

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

                          'searchParams' => '[[["email","ny",""]]]',

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

                      $params['uitype'] = 10;

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

                      $params['referenceList'] = ['IStorages'];

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

          public $listFields = [

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

              'ip' => 'LBL_IP_ADDRESS',

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

                      $params['picklistValues'] = [];

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

          public $columnsToShow = [

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

              $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'label' => $fieldsLabel[$name], 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];

      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

                      $servers = Settings_WebserviceApps_Module_Model::getActiveServers($this->getModule()->typeApi);

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

              'password' => 'FL_PASSWORD',

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

              'user_id' => 'FL_USER',

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

              'istorage' => 'FL_STORAGE',

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

                      ];

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

              'user_name' => 'FL_LOGIN',

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

              'login_method' => 'FL_LOGIN_METHOD',

      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

                      $params['picklistValues'] = [1 => \App\Language::translate('FL_ACTIVE'), 0 => \App\Language::translate('FL_INACTIVE')];

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

          public $baseTable = 'w_#__portal_user';

      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

              'language' => 'FL_LANGUAGE',

      Line exceeds 120 characters; contains 193 characters
      Open

              $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'label' => $fieldsLabel[$name], 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];

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

                  case 'istorage':

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

                      $params['uitype'] = 16;

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

                      foreach ($servers as $key => $value) {

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

          public $editFields = [

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

              'status' => 'FL_STATUS',

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

                      $params['typeofdata'] = 'V~O';

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

                      $params['uitype'] = 16;

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

                      $params['uitype'] = 32;

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

          public function getFieldInstanceByName($name)

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

              'login_method' => 'FL_LOGIN_METHOD',

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

              'server_id' => 'FL_SERVER',

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

          {

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

              switch ($name) {

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

                  case 'crmid':

      Line exceeds 120 characters; contains 135 characters
      Open

                      $params['picklistValues'] = [1 => \App\Language::translate('FL_ACTIVE'), 0 => \App\Language::translate('FL_INACTIVE')];

      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 'language':

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

              'istorage' => 'FL_STORAGE',

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

          ];

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

                          $params['picklistValues'][$key] = $value['name'];

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

                      $params['picklistValues'] = [];

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

              'server_id' => 'FL_SERVER',

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

              'type' => 'FL_TYPE',

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

              'login_time' => 'FL_LOGIN_TIME',

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

          /** @var array Columns to show on the list session. */

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

                  case 'server_id':

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

                      $params['picklistValues'] = [

      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

          public function setDataFromRequest(App\Request $request)

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

                      switch ($field) {

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

                      $params['fieldparams'] = [

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

                      $params['typeofdata'] = 'V~O';

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

                  case 'user_id':

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

                      $params['picklistValues'] = [

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

                      $params['typeofdata'] = 'V~O';

      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 'language':

      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

                          throw new \App\Exceptions\Security("ERR_ILLEGAL_FIELD_VALUE||{$field}", 406);

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

                      }

      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

          {

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

              'user_id' => 'FL_USER',

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

              'custom_params' => 'FL_CUSTOM_PARAMS',

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

                      $params['referenceList'] = ['Contacts'];

      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 'type':

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

                      foreach ($this->getTypeValues() as $key => $value) {

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

                      $params['fieldparams'] = '{"validate":["pwned","config"],"auto-generate":true,"strengthMeter":true}';

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

                  case 'server_id':

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

                  case 'type':

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

              'status' => 'FL_STATUS',

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

              'time' => 'FL_LOGIN_TIME',

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

              'agent' => 'LBL_USER_AGENT',

      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

              $moduleName = $this->getModule()->getName(true);

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

                  case 'status':

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

                      $params['uitype'] = 16;

      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

                      break;

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

                      $params['uitype'] = 16;

      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

              'authy_methods' => 'FL_AUTHY_METHODS',

      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

                          $params['picklistValues'][$key] = \App\Language::translate($value, $moduleName);

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

                      }

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

                      $params['picklistValues'] = \App\Language::getAll();

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

                  default: break;

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

                  if ($request->has($field)) {

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

                          case 'status':

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

                          case 'user_name':

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

                                  throw new \App\Exceptions\Security("ERR_ILLEGAL_FIELD_VALUE||{$field}", 406);

      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

                      break;

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

              'crmid' => 'FL_RECORD_NAME',

      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

              'type' => 'FL_TYPE',

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

              'status' => 'FL_STATUS',

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

              'device_id' => 'LBL_DEVICE_ID',

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

                      $params['uitype'] = 10;

      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

                          'PLL_PASSWORD' => \App\Language::translate('PLL_PASSWORD', 'Users'),

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

                  case 'authy_methods':

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

                          case 'server_id':

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

                          case 'authy_methods':

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

                  case 'crmid':

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

                          'PLL_PASSWORD_2FA' => \App\Language::translate('PLL_PASSWORD_2FA', 'Users'),

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

                          '-' => \App\Language::translate('LBL_NONE'),

      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

                              $value = $request->isEmpty('crmid') ? '' : $request->getInteger('crmid');

      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

                              $value = $request->getByType($field, 'Text');

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

              switch ($key) {

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

                      $value = (int) $value;

      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

                      $params['picklistValues'] = \App\Fields\Owner::getInstance($moduleName)->getAccessibleUsers('', 'owner');

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

                      if ($this->has('id')) {

      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

                  case 'istorage':

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

                  case 'status':

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

                  case 'password':

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

          }

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

                      $params['typeofdata'] = 'V~O';

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

                      $params['uitype'] = 99;

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

                          $params = null;

      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 'crmid':

      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 'login_method':

      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 'password':

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

                          case 'user_id':

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

                          case 'password':

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

                              parent::set($field, $value);

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

                          default:

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

                      ];

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

                          'PLL_AUTHY_TOTP' => \App\Language::translate('PLL_AUTHY_TOTP', 'Users'),

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

                          case 'istorage':

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

                  default: break;

      Line exceeds 120 characters; contains 121 characters
      Open

                      $params['picklistValues'] = \App\Fields\Owner::getInstance($moduleName)->getAccessibleUsers('', 'owner');

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

                      ];

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

                      $params['uitype'] = 16;

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

              return $params ? Settings_Vtiger_Field_Model::init($moduleName, $params) : null;

      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

                          case 'type':

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

                              if (!$this->isNew()) {

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

                              }

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

                              $value = $request->getRaw($field, null);

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

          public function getValueToSave($key, $value)

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

                      $params['uitype'] = 16;

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

                      $params['typeApi'] = $this->getModule()->typeApi;

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

                      $params['maximumlength'] = '100';

      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 (array_keys($this->getEditFields()) as $field) {

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

                              $value = $request->getInteger($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

                              break;

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

                          case 'login_method':

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

                      $this->set($field, $this->getValueToSave($field, $value));

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

                  case 'user_id':

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

                      $value = App\Encryption::createPasswordHash($value, 'WebservicePremium');

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

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

      class Settings_WebserviceUsers_WebservicePremium_Service extends Settings_WebserviceUsers_WebserviceStandard_Service

      Closing brace must be on a line by itself
      Open

                  default: break;

      Closing brace must be on a line by itself
      Open

                  default: break;

      There are no issues that match your filters.

      Category
      Status