YetiForceCompany/YetiForceCRM

View on GitHub
modules/Users/actions/Password.php

Summary

Maintainability
C
1 day
Test Coverage
F
0%

Function change has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function change(App\Request $request): void
    {
        $moduleName = $request->getModule();
        $password = $request->getRaw('password');
        $userRecordModel = Users_Record_Model::getInstanceById($request->getInteger('record'), $moduleName);
Severity: Minor
Found in modules/Users/actions/Password.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 change has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function change(App\Request $request): void
    {
        $moduleName = $request->getModule();
        $password = $request->getRaw('password');
        $userRecordModel = Users_Record_Model::getInstanceById($request->getInteger('record'), $moduleName);
Severity: Minor
Found in modules/Users/actions/Password.php - About 1 hr to fix

    Function checkPermission has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function checkPermission(App\Request $request): bool
        {
            if ('demo' === App\Config::main('systemMode')) {
                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
            }
    Severity: Minor
    Found in modules/Users/actions/Password.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 massReset has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function massReset(App\Request $request): void
        {
            $moduleName = $request->getModule();
            $recordsList = Vtiger_Mass_Action::getRecordsListFromRequest($request);
            foreach ($recordsList as $userId) {
    Severity: Minor
    Found in modules/Users/actions/Password.php - About 1 hr to fix

      Method reset has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function reset(App\Request $request): void
          {
              $moduleName = $request->getModule();
              $password = \App\Encryption::generateUserPassword();
              $userRecordModel = Users_Record_Model::getInstanceById($request->getInteger('record'), $moduleName);
      Severity: Minor
      Found in modules/Users/actions/Password.php - About 1 hr to fix

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

            public function change(App\Request $request): void
            {
                $moduleName = $request->getModule();
                $password = $request->getRaw('password');
                $userRecordModel = Users_Record_Model::getInstanceById($request->getInteger('record'), $moduleName);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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 checkPermission() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
        Open

            public function checkPermission(App\Request $request): bool
            {
                if ('demo' === App\Config::main('systemMode')) {
                    throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
                }
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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 class Users_Password_Action has a coupling between objects value of 19. Consider to reduce the number of dependencies under 13.
        Open

        class Users_Password_Action extends \App\Controller\Action
        {
            use \App\Controller\ExposeMethod;
        
            /** {@inheritdoc} */
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        CouplingBetweenObjects

        Since: 1.1.0

        A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

        Example

        class Foo {
            /**
             * @var \foo\bar\X
             */
            private $x = null;
        
            /**
             * @var \foo\bar\Y
             */
            private $y = null;
        
            /**
             * @var \foo\bar\Z
             */
            private $z = null;
        
            public function setFoo(\Foo $foo) {}
            public function setBar(\Bar $bar) {}
            public function setBaz(\Baz $baz) {}
        
            /**
             * @return \SplObjectStorage
             * @throws \OutOfRangeException
             * @throws \InvalidArgumentException
             * @throws \ErrorException
             */
            public function process(\Iterator $it) {}
        
            // ...
        }

        Source https://phpmd.org/rules/design.html#couplingbetweenobjects

        Missing class import via use statement (line '98', column '19').
        Open

                $response = new Vtiger_Response();
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                $response = new Vtiger_Response();
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                    throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                $response = new Vtiger_Response();
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                    $eventHandler = new \App\EventHandler();
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                        $eventHandler = new \App\EventHandler();
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                $eventHandler = new \App\EventHandler();
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\Mailer' in method 'reset'.
        Open

                \App\Mailer::sendFromTemplate([
                    'template' => 'UsersResetPassword',
                    'moduleName' => 'Users',
                    'recordId' => $userRecordModel->getId(),
                    'to' => $userRecordModel->get('email1'),
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\Process' in method 'change'.
        Open

                            \App\Process::removeEvent('ShowUserPasswordChange');
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                        $response->setResult(['processStop' => true, 'notify' => ['text' => \App\Language::translateSingleMod($exc->getMessage(), 'Other.Exceptions'), 'type' => 'error']]);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                    $password = \App\Encryption::generateUserPassword();
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\Mailer' in method 'massReset'.
        Open

                    \App\Mailer::sendFromTemplate([
                        'template' => 'UsersResetPassword',
                        'moduleName' => 'Users',
                        'recordId' => $userRecordModel->getId(),
                        'to' => $userRecordModel->get('email1'),
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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 'Users_Record_Model' in method 'reset'.
        Open

                $userRecordModel = Users_Record_Model::getInstanceById($request->getInteger('record'), $moduleName);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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 'Users_Record_Model' in method 'change'.
        Open

                $userRecordModel = Users_Record_Model::getInstanceById($request->getInteger('record'), $moduleName);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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 'Users_Record_Model' in method 'massReset'.
        Open

                    $userRecordModel = Users_Record_Model::getInstanceById($userId, $moduleName);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\Utils\Tokens' in method 'massReset'.
        Open

                    $token = \App\Utils\Tokens::generate('Users_LoginForgotPassword_Action', [$userRecordModel->getId()], $expirationDate);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\User' in method 'checkPermission'.
        Open

                        if (\App\User::getCurrentUserId() === \App\User::getCurrentUserRealId() && (true === $currentUserModel->isAdminUser() || (int) $currentUserModel->get('id') === $request->getInteger('record'))) {
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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_Mass_Action' in method 'massReset'.
        Open

                $recordsList = Vtiger_Mass_Action::getRecordsListFromRequest($request);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\Utils\Tokens' in method 'reset'.
        Open

                $token = \App\Utils\Tokens::generate('Users_LoginForgotPassword_Action', [$userRecordModel->getId()], $expirationDate);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\Session' in method 'change'.
        Open

                if (!$isOtherUser && 'PASSWORD' !== \App\Session::get('UserAuthMethod')) {
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                } else {
                    $userRecordModel->set('changeUserPassword', true);
                    $userRecordModel->set('user_password', $password);
                    $userRecordModel->set('date_password_change', date('Y-m-d H:i:s'));
                    if ($userRecordModel->getId() === \App\User::getCurrentUserRealId()) {
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                    $response->setResult(['processStop' => true, 'notify' => ['text' => \App\Language::translate('LBL_INCORRECT_OLD_PASSWORD', $moduleName), 'type' => 'error']]);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                $response->setResult(['notify' => ['text' => \App\Language::translate('LBL_PASSWORD_WAS_RESET_AND_SENT_TO_USER', 'Users')]]);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\Config' in method 'checkPermission'.
        Open

                if ('demo' === App\Config::main('systemMode')) {
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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 'Users_Record_Model' in method 'checkPermission'.
        Open

                $currentUserModel = Users_Record_Model::getCurrentUserModel();
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                    $response->setResult(['processStop' => true, 'notify' => ['text' => \App\Language::translate('LBL_NOT_CHANGE_PASS_AUTH_EXTERNAL_SYSTEM', $moduleName), 'type' => 'error']]);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                        $response->setResult(['notify' => ['text' => \App\Language::translate('LBL_PASSWORD_SUCCESSFULLY_CHANGED', $moduleName)]]);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\Session' in method 'change'.
        Open

                            \App\Session::delete('ShowUserPasswordChange');
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\Fields\DateTime' in method 'massReset'.
        Open

                        'expirationDate' => \App\Fields\DateTime::formatToDisplay($expirationDate),
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\User' in method 'checkPermission'.
        Open

                        if (\App\User::getCurrentUserId() === \App\User::getCurrentUserRealId() && (true === $currentUserModel->isAdminUser() || (int) $currentUserModel->get('id') === $request->getInteger('record'))) {
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\User' in method 'change'.
        Open

                $isOtherUser = App\User::getCurrentUserId() !== $request->getInteger('record');
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\User' in method 'change'.
        Open

                    if ($userRecordModel->getId() === \App\User::getCurrentUserRealId()) {
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\Fields\DateTime' in method 'reset'.
        Open

                    'expirationDate' => \App\Fields\DateTime::formatToDisplay($expirationDate),
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                    $response->setResult(['processStop' => true, 'notify' => ['text' => \App\Language::translate('LBL_PASSWORD_SHOULD_BE_SAME', $moduleName), 'type' => 'error']]);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        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\Session' in method 'change'.
        Open

                        if (\App\Session::has('ShowUserPasswordChange')) {
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                $password = \App\Encryption::generateUserPassword();
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                $response->setResult(['notify' => ['text' => \App\Language::translate('LBL_PASSWORD_WAS_RESET_AND_SENT_TO_USERS', 'Users')]]);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

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

                    $response->setResult(['processStop' => true, 'notify' => ['text' => \App\Language::translate('LBL_NOT_CHANGE_PASS_AUTH_EXTERNAL_SYSTEM', $moduleName), 'type' => 'error']]);
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

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

                $eventHandler->trigger('UsersBeforePasswordChange');
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

        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 "Y-m-d H:i:s" 5 times.
        Open

                $userRecordModel->set('date_password_change', date('Y-m-d H:i:s'));
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

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

                $userRecordModel->set('date_password_change', date('Y-m-d H:i:s'));
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

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

                $this->exposeMethod('reset');
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

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

                $userRecordModel->set('user_password', $password);
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

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

                    $response->setResult(['processStop' => true, 'notify' => ['text' => \App\Language::translate('LBL_NOT_CHANGE_PASS_AUTH_EXTERNAL_SYSTEM', $moduleName), 'type' => 'error']]);
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

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

                $eventHandler->trigger('UsersAfterPasswordChange');
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

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

                $response->setResult(['notify' => ['text' => \App\Language::translate('LBL_PASSWORD_WAS_RESET_AND_SENT_TO_USER', 'Users')]]);
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

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

                        if (true === $currentUserModel->isAdminUser() || (int) $currentUserModel->get('id') === $request->getInteger('record')) {
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

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

                $eventHandler->setParams(['action' => 'reset']);
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

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

                        if (\App\Session::has('ShowUserPasswordChange')) {
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

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

                $userRecordModel->set('changeUserPassword', true);
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

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

                $this->exposeMethod('massReset');
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

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

                $eventHandler->setModuleName('Users');
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

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

                $this->exposeMethod('change');
        Severity: Critical
        Found in modules/Users/actions/Password.php by sonar-php

        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 static property site_URL from undeclared class \Config\Main
        Open

                        'url' => \Config\Main::$site_URL . 'index.php?module=Users&view=LoginPassChange&token=' . $token,
        Severity: Critical
        Found in modules/Users/actions/Password.php by phan

        Reference to static property site_URL from undeclared class \Config\Main
        Open

                    'url' => \Config\Main::$site_URL . 'index.php?module=Users&view=LoginPassChange&token=' . $token,
        Severity: Critical
        Found in modules/Users/actions/Password.php by phan

        Call to method getCurrentUserRealId from undeclared class \App\User (Did you mean class \Tests\App\User)
        Open

                        if (\App\User::getCurrentUserId() === \App\User::getCurrentUserRealId() && (true === $currentUserModel->isAdminUser() || (int) $currentUserModel->get('id') === $request->getInteger('record'))) {
        Severity: Critical
        Found in modules/Users/actions/Password.php by phan

        Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
        Open

                $isOtherUser = App\User::getCurrentUserId() !== $request->getInteger('record');
        Severity: Critical
        Found in modules/Users/actions/Password.php by phan

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

                $password = \App\Encryption::generateUserPassword();
        Severity: Critical
        Found in modules/Users/actions/Password.php by phan

        Argument 2 (value) is true but \Users_Record_Model::set() takes string defined at /code/modules/Users/models/Record.php:52
        Open

                    $userRecordModel->set('changeUserPassword', true);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phan

        Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
        Open

                        if (\App\User::getCurrentUserId() === \App\User::getCurrentUserRealId() && (true === $currentUserModel->isAdminUser() || (int) $currentUserModel->get('id') === $request->getInteger('record'))) {
        Severity: Critical
        Found in modules/Users/actions/Password.php by phan

        Call to method getCurrentUserRealId from undeclared class \App\User (Did you mean class \Tests\App\User)
        Open

                    if ($userRecordModel->getId() === \App\User::getCurrentUserRealId()) {
        Severity: Critical
        Found in modules/Users/actions/Password.php by phan

        Argument 2 (value) is 0 but \Users_Record_Model::set() takes string defined at /code/modules/Users/models/Record.php:52
        Open

                        $userRecordModel->set('force_password_change', 0);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phan

        Argument 2 (value) is true but \Users_Record_Model::set() takes string defined at /code/modules/Users/models/Record.php:52
        Open

                $userRecordModel->set('changeUserPassword', true);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phan

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

                    $password = \App\Encryption::generateUserPassword();
        Severity: Critical
        Found in modules/Users/actions/Password.php by phan

        Argument 2 (value) is true but \Users_Record_Model::set() takes string defined at /code/modules/Users/models/Record.php:52
        Open

                    $userRecordModel->set('changeUserPassword', true);
        Severity: Minor
        Found in modules/Users/actions/Password.php by phan

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

                switch ($request->getMode()) {
                    case 'reset':
                        if (true === $currentUserModel->isAdminUser() || (int) $currentUserModel->get('id') === $request->getInteger('record')) {
                            return true;
                        }
        Severity: Major
        Found in modules/Users/actions/Password.php and 1 other location - About 3 hrs to fix
        modules/Users/views/PasswordModal.php on lines 30..48

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 148.

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

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

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

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

        Refactorings

        Further Reading

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

        class Users_Password_Action extends \App\Controller\Action

        The class Users_Password_Action is not named in CamelCase.
        Open

        class Users_Password_Action extends \App\Controller\Action
        {
            use \App\Controller\ExposeMethod;
        
            /** {@inheritdoc} */
        Severity: Minor
        Found in modules/Users/actions/Password.php by phpmd

        CamelCaseClassName

        Since: 0.2

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

        Example

        class class_name {
        }

        Source

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

                $eventHandler->trigger('UsersBeforePasswordChange');

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

            {

        Line exceeds 120 characters; contains 137 characters
        Open

                        if (true === $currentUserModel->isAdminUser() || (int) $currentUserModel->get('id') === $request->getInteger('record')) {

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

                    case 'change':

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

                        }

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

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

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

            public function reset(App\Request $request): void

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

                $userRecordModel->set('changeUserPassword', true);

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

                    'recordId' => $userRecordModel->getId(),

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

                    'expirationDate' => \App\Fields\DateTime::formatToDisplay($expirationDate),

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

                if ('demo' === App\Config::main('systemMode')) {

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

                        if (true === $currentUserModel->isAdminUser()) {

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

             *

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

                $userRecordModel = Users_Record_Model::getInstanceById($request->getInteger('record'), $moduleName);

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

                    'url' => \Config\Main::$site_URL . 'index.php?module=Users&view=LoginPassChange&token=' . $token,

        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

                $eventHandler->trigger('UsersAfterPasswordChange');

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

                \App\Mailer::sendFromTemplate([

        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

                    throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

        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

                $eventHandler = new \App\EventHandler();

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

                $currentUserModel = Users_Record_Model::getCurrentUserModel();

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

             */

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

                $eventHandler->setParams(['action' => 'reset']);

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

                    case 'massReset':

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

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

                        }

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

                $moduleName = $request->getModule();

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

                $userRecordModel->set('user_password', $password);

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

                $expirationDate = date('Y-m-d H:i:s', strtotime('+24 hour'));

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

                    'moduleName' => 'Users',

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

                $this->exposeMethod('change');

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

             * @param \App\Request $request

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

                            return true;

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

                $userRecordModel->set('date_password_change', date('Y-m-d H:i:s'));

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

                $eventHandler->setRecordModel($userRecordModel);

        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 (true === $currentUserModel->isAdminUser() || (int) $currentUserModel->get('id') === $request->getInteger('record')) {

        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

                            return true;

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

                parent::__construct();

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

             * Reset user password.

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

                $eventHandler->setModuleName('Users');

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

                    'template' => 'UsersResetPassword',

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

                $response = new Vtiger_Response();

        Line exceeds 120 characters; contains 171 characters
        Open

                    $response->setResult(['processStop' => true, 'notify' => ['text' => \App\Language::translate('LBL_PASSWORD_SHOULD_BE_SAME', $moduleName), 'type' => 'error']]);

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

                } elseif (!$isOtherUser && !$userRecordModel->verifyPassword($request->getRaw('oldPassword'))) {

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

                    } catch (\App\Exceptions\SaveRecord $exc) {

        Line exceeds 120 characters; contains 125 characters
        Open

                        $response->setResult(['processStop' => true, 'notify' => ['text' => $exc->getMessage(), 'type' => 'error']]);

        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

             * Function to check permission.

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

                        if (\App\User::getCurrentUserId() === \App\User::getCurrentUserRealId() && (true === $currentUserModel->isAdminUser() || (int) $currentUserModel->get('id') === $request->getInteger('record'))) {

        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

                }

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

            /**

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

                    'token' => $token,

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

             */

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

                        'token' => $token,

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

                $response = new Vtiger_Response();

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

            public function __construct()

        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 checkPermission(App\Request $request): bool

        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

            {

        Line exceeds 120 characters; contains 127 characters
        Open

                $token = \App\Utils\Tokens::generate('Users_LoginForgotPassword_Action', [$userRecordModel->getId()], $expirationDate);

        Line exceeds 120 characters; contains 170 characters
        Open

                    $response->setResult(['processStop' => true, 'notify' => ['text' => \App\Language::translate('LBL_INCORRECT_OLD_PASSWORD', $moduleName), 'type' => 'error']]);

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

                    $userRecordModel = Users_Record_Model::getInstanceById($userId, $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

                $response->emit();

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

                $this->exposeMethod('reset');

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

                $this->exposeMethod('massReset');

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

                    case 'reset':

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

                $userRecordModel->save();

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

                    $password = \App\Encryption::generateUserPassword();

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

                    $eventHandler->setModuleName('Users');

        Line exceeds 120 characters; contains 131 characters
        Open

                    $token = \App\Utils\Tokens::generate('Users_LoginForgotPassword_Action', [$userRecordModel->getId()], $expirationDate);

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

                switch ($request->getMode()) {

        Line exceeds 120 characters; contains 210 characters
        Open

                        if (\App\User::getCurrentUserId() === \App\User::getCurrentUserRealId() && (true === $currentUserModel->isAdminUser() || (int) $currentUserModel->get('id') === $request->getInteger('record'))) {

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

             *

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

             * @param \App\Request $request

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

                $password = \App\Encryption::generateUserPassword();

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

                    'to' => $userRecordModel->get('email1'),

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

                $response->emit();

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

            }

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

             * @return void

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

                        $response->setResult(['notify' => ['text' => \App\Language::translate('LBL_PASSWORD_SUCCESSFULLY_CHANGED', $moduleName)]]);

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

                        if (\App\Session::has('ShowUserPasswordChange')) {

        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 massReset(App\Request $request): void

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

                    $token = \App\Utils\Tokens::generate('Users_LoginForgotPassword_Action', [$userRecordModel->getId()], $expirationDate);

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

                        'template' => 'UsersResetPassword',

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

            use \App\Controller\ExposeMethod;

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

             * @throws \App\Exceptions\NoPermittedToRecord

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

                }

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

             * @return void

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

                $token = \App\Utils\Tokens::generate('Users_LoginForgotPassword_Action', [$userRecordModel->getId()], $expirationDate);

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

             * Change user password.

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

                    $userRecordModel->set('user_password', $password);

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

                    try {

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

                        $eventHandler = new \App\EventHandler();

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

                        $userRecordModel->save();

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

                        $response->setResult(['processStop' => true, 'notify' => ['text' => $exc->getMessage(), 'type' => 'error']]);

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

             * @param \App\Request $request

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

                $moduleName = $request->getModule();

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

                            \App\Process::removeEvent('ShowUserPasswordChange');

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

                    $eventHandler->setParams(['action' => 'massReset']);

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

                        'recordId' => $userRecordModel->getId(),

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

            {

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

                    $response->setResult(['processStop' => true, 'notify' => ['text' => \App\Language::translate('LBL_INCORRECT_OLD_PASSWORD', $moduleName), 'type' => 'error']]);

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

                $response->emit();

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

            {

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

                    $userRecordModel->set('user_password', $password);

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

            public function change(App\Request $request): void

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

                $moduleName = $request->getModule();

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

                } elseif ($password !== $request->getRaw('confirm_password')) {

        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

                    }

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

                        'moduleName' => 'Users',

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

                ]);

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

                    $response->setResult(['processStop' => true, 'notify' => ['text' => \App\Language::translate('LBL_NOT_CHANGE_PASS_AUTH_EXTERNAL_SYSTEM', $moduleName), 'type' => 'error']]);

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

                    $userRecordModel->set('changeUserPassword', true);

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

                        $response->setResult(['processStop' => true, 'notify' => ['text' => \App\Language::translateSingleMod($exc->getMessage(), 'Other.Exceptions'), 'type' => 'error']]);

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

                foreach ($recordsList as $userId) {

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

                    $eventHandler->setRecordModel($userRecordModel);

        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

             * @param \App\Request $request

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

                $isOtherUser = App\User::getCurrentUserId() !== $request->getInteger('record');

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

                if (!$isOtherUser && 'PASSWORD' !== \App\Session::get('UserAuthMethod')) {

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

                    $userRecordModel->set('date_password_change', date('Y-m-d H:i:s'));

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

                        }

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

                    $userRecordModel->set('changeUserPassword', true);

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

                    $userRecordModel->save();

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

             *

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

                $response = new Vtiger_Response();

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

                    if ($userRecordModel->getId() === \App\User::getCurrentUserRealId()) {

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

                            \App\Session::delete('ShowUserPasswordChange');

        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

             * Mass reset user password.

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

                    $userRecordModel->set('date_password_change', date('Y-m-d H:i:s'));

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

                    $eventHandler->trigger('UsersAfterPasswordChange');

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

                        'to' => $userRecordModel->get('email1'),

        Line exceeds 120 characters; contains 134 characters
        Open

                $response->setResult(['notify' => ['text' => \App\Language::translate('LBL_PASSWORD_WAS_RESET_AND_SENT_TO_USERS', 'Users')]]);

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

                $password = $request->getRaw('password');

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

                $userRecordModel = Users_Record_Model::getInstanceById($request->getInteger('record'), $moduleName);

        Line exceeds 120 characters; contains 184 characters
        Open

                    $response->setResult(['processStop' => true, 'notify' => ['text' => \App\Language::translate('LBL_NOT_CHANGE_PASS_AUTH_EXTERNAL_SYSTEM', $moduleName), 'type' => 'error']]);

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

                        $eventHandler->setModuleName($moduleName);

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

                        $eventHandler->trigger('UsersBeforePasswordChange');

        Line exceeds 120 characters; contains 180 characters
        Open

                        $response->setResult(['processStop' => true, 'notify' => ['text' => \App\Language::translateSingleMod($exc->getMessage(), 'Other.Exceptions'), 'type' => 'error']]);

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

                    } catch (\App\Exceptions\Security $exc) {

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

            /**

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

                $response->setResult(['notify' => ['text' => \App\Language::translate('LBL_PASSWORD_WAS_RESET_AND_SENT_TO_USERS', 'Users')]]);

        Line exceeds 120 characters; contains 133 characters
        Open

                $response->setResult(['notify' => ['text' => \App\Language::translate('LBL_PASSWORD_WAS_RESET_AND_SENT_TO_USER', 'Users')]]);

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

                        $userRecordModel->set('force_password_change', 0);

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

                        $eventHandler->setParams(['action' => 'change']);

        Line exceeds 120 characters; contains 139 characters
        Open

                        $response->setResult(['notify' => ['text' => \App\Language::translate('LBL_PASSWORD_SUCCESSFULLY_CHANGED', $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

                    $eventHandler = new \App\EventHandler();

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

                    \App\Mailer::sendFromTemplate([

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

                        'expirationDate' => \App\Fields\DateTime::formatToDisplay($expirationDate),

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

                        $eventHandler->trigger('UsersAfterPasswordChange');

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

                    $expirationDate = date('Y-m-d H:i:s', strtotime('+24 hour'));

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

                $response->setResult(['notify' => ['text' => \App\Language::translate('LBL_PASSWORD_WAS_RESET_AND_SENT_TO_USER', 'Users')]]);

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

                    $response->setResult(['processStop' => true, 'notify' => ['text' => \App\Language::translate('LBL_PASSWORD_SHOULD_BE_SAME', $moduleName), 'type' => 'error']]);

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

                        $eventHandler->setRecordModel($userRecordModel);

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

                $recordsList = Vtiger_Mass_Action::getRecordsListFromRequest($request);

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

                    $eventHandler->trigger('UsersBeforePasswordChange');

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

                        'url' => \Config\Main::$site_URL . 'index.php?module=Users&view=LoginPassChange&token=' . $token,

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

        class Users_Password_Action extends \App\Controller\Action

        There are no issues that match your filters.

        Category
        Status