hnhdigital-os/mysql-helper

View on GitHub

Showing 85 of 103 total issues

Avoid too many return statements within this method.
Open

            return 1;
Severity: Major
Found in app/Commands/CloneCommand.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return $this->cloneLocalDatabases($profile, $local_connection, $source_database, $destination_database);
    Severity: Major
    Found in app/Commands/CloneCommand.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return 1;
      Severity: Major
      Found in app/Commands/CloneCommand.php - About 30 mins to fix

        Function selectLocalDatabase has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function selectLocalDatabase($profile, $connection, $type)
            {
                switch ($type) {
                    case self::DATABASE_TYPE_DESTINATION:
                        $title = 'Select destination database';
        Severity: Minor
        Found in app/Commands/CloneCommand.php - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function updateRemoteProfile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function updateRemoteProfile($profile, $name)
            {
                $data = array_get($this->profiles, $profile.'.remote.'.$name, []);
        
                $public_key = array_get($data, 'public_key', $this->getUserHome('.ssh/id_rsa.pub'));
        Severity: Minor
        Found in app/Commands/ConfigureCommand.php - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function listDatabases has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function listDatabases()
            {
                // Select profile.
                if (empty($profile = $this->option('profile'))) {
                    $profile = $this->selectProfile();
        Severity: Minor
        Found in app/Commands/DisplayCommand.php - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        The method createRemoteProfile() has 101 lines of code. Current threshold is set to 100. Avoid really long methods.
        Open

            private function createRemoteProfile($profile)
            {
                // Profile name.
                while (true) {
                    $name = $this->ask('Set the name of this new remote');
        Severity: Minor
        Found in app/Commands/ConfigureCommand.php by phpmd

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

                $method = $this->askConnectionMethod($methods);
        Severity: Minor
        Found in app/Commands/ConfigureCommand.php by phpmd

        UnusedLocalVariable

        Since: 0.2

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

        Example

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

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

        Avoid unused parameters such as '$destination_database'.
        Open

            private function cloneRemoteDatabases($profile, $remote, $remote_profile, $remote_connection, $local_connection, $source_database, $destination_database)
        Severity: Minor
        Found in app/Commands/CloneCommand.php by phpmd

        UnusedFormalParameter

        Since: 0.2

        Avoid passing parameters to methods or constructors and then not using those parameters.

        Example

        class Foo
        {
            private function bar($howdy)
            {
                // $howdy is not used
            }
        }

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

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

            public function handle()
            {
                if (!$this->checkInstalledPackages()) {
                    return;
                }
        Severity: Minor
        Found in app/Commands/CloneCommand.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

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

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

            private function sshAcceptedMethods($host, $port, $username)
            {
                try {
                    $session = ssh2_connect($host, $port);
                } catch (\Exception $e) {
        Severity: Minor
        Found in app/Commands/ConfigureCommand.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

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

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

            public function handle()
            {
                if (!$this->checkInstalledPackages()) {
                    return;
                }
        Severity: Minor
        Found in app/Commands/BackupCommand.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

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

        The method createRemoteProfile() has an NPath complexity of 2250. The configured NPath complexity threshold is 200.
        Open

            private function createRemoteProfile($profile)
            {
                // Profile name.
                while (true) {
                    $name = $this->ask('Set the name of this new remote');
        Severity: Minor
        Found in app/Commands/ConfigureCommand.php by phpmd

        NPathComplexity

        Since: 0.1

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

        Example

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

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

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

            private function listConnections()
            {
                // Select profile.
                if (empty($profile = $this->option('profile'))) {
                    $profile = $this->selectProfile();
        Severity: Minor
        Found in app/Commands/DisplayCommand.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

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

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

            public function handle()
            {
                if (!$this->checkInstalledPackages()) {
                    return;
                }
        Severity: Minor
        Found in app/Commands/RestoreCommand.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

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

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

            public function handle()
            {
                if (!$this->checkInstalledPackages()) {
                    return;
                }
        Severity: Minor
        Found in app/Commands/CloneCommand.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

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

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

            public function handle()
            {
                if (!$this->checkInstalledPackages()) {
                    return;
                }
        Severity: Minor
        Found in app/Commands/CloneCommand.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

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

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

            public function handle()
            {
                if (!$this->checkInstalledPackages()) {
                    return;
                }
        Severity: Minor
        Found in app/Commands/CloneCommand.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

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

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

            public function handle()
            {
                if (!$this->checkInstalledPackages()) {
                    return;
                }
        Severity: Minor
        Found in app/Commands/CloneCommand.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

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

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

            public function handle()
            {
                if (!$this->checkInstalledPackages()) {
                    return;
                }
        Severity: Minor
        Found in app/Commands/RestoreCommand.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

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

        Severity
        Category
        Status
        Source
        Language