hnhdigital-os/mysql-helper

View on GitHub
app/Commands/CloneCommand.php

Summary

Maintainability
D
2 days
Test Coverage

Function handle has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    public function handle()
    {
        if (!$this->checkInstalledPackages()) {
            return;
        }
Severity: Minor
Found in app/Commands/CloneCommand.php - About 6 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Method handle has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function handle()
    {
        if (!$this->checkInstalledPackages()) {
            return;
        }
Severity: Major
Found in app/Commands/CloneCommand.php - About 3 hrs to fix

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

    class CloneCommand extends Command
    {
        use CommandInternalsTrait, FileSystemTrait, SharedTrait;
    
        /**
    Severity: Minor
    Found in app/Commands/CloneCommand.php by phpmd

    File CloneCommand.php has 296 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace App\Commands;
    
    use App\Traits\SharedTrait;
    Severity: Minor
    Found in app/Commands/CloneCommand.php - About 3 hrs to fix

      Method cloneLocalDatabases has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function cloneLocalDatabases($profile, $connection, $source_database, $destination_database)
          {
              // Check we want to proceed.
              if (intval($this->option('no-interaction')) < 1
                  && !$this->confirm('Did you want to proceed?')) {
      Severity: Minor
      Found in app/Commands/CloneCommand.php - About 1 hr to fix

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

            private function cloneRemoteDatabases($profile, $remote, $remote_profile, $remote_connection, $local_connection, $source_database, $destination_database)
            {
                // Check we want to proceed.
                if (intval($this->option('no-interaction')) < 1
                    && !$this->confirm('Did you want to proceed?')) {
        Severity: Minor
        Found in app/Commands/CloneCommand.php - About 1 hr to fix

          Method cloneRemoteDatabases has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              private function cloneRemoteDatabases($profile, $remote, $remote_profile, $remote_connection, $local_connection, $source_database, $destination_database)
          Severity: Major
          Found in app/Commands/CloneCommand.php - About 50 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

              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->cloneRemoteDatabases(
                                $profile,
                                $remote,
                                $remote_profile,
                                $remote_connection,
                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

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

                          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

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

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

                              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 unused parameters such as '$local_connection'.
                              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 '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 '96', 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 '114', 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 '77', 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 '157', 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 '125', 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 '104', 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 '95', 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 '113', 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

                              Line exceeds 120 characters; contains 157 characters
                              Open

                                  private function cloneRemoteDatabases($profile, $remote, $remote_profile, $remote_connection, $local_connection, $source_database, $destination_database)

                              There are no issues that match your filters.

                              Category
                              Status