hnhdigital-os/mysql-helper

View on GitHub

Showing 85 of 103 total issues

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

    private function updateLocalProfileName($profile, $name, $new_name)
    {
        // Profile name.
        while (true) {
            $new_name = $this->ask(sprintf('Profile name [%s]', $name));
Severity: Major
Found in app/Commands/ConfigureCommand.php and 1 other location - About 7 hrs to fix
app/Commands/ConfigureCommand.php on lines 433..469

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 236.

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

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

    private function updateRemoteProfileName($profile, $name, $new_name)
    {
        // Profile name.
        while (true) {
            $new_name = $this->ask(sprintf('Profile name [%s]', $name));
Severity: Major
Found in app/Commands/ConfigureCommand.php and 1 other location - About 7 hrs to fix
app/Commands/ConfigureCommand.php on lines 763..795

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 236.

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

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

    private function configureLocalProfile($profile)
    {
        $menu = [];

        foreach (array_get($this->profiles, $profile.'.local', []) as $name => $local_details) {
Severity: Major
Found in app/Commands/ConfigureCommand.php and 1 other location - About 7 hrs to fix
app/Commands/ConfigureCommand.php on lines 152..181

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 225.

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

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

    private function configureRemoteProfile($profile)
    {
        $menu = [];

        foreach (array_get($this->profiles, $profile.'.remote', []) as $name => $remote_details) {
Severity: Major
Found in app/Commands/ConfigureCommand.php and 1 other location - About 7 hrs to fix
app/Commands/ConfigureCommand.php on lines 690..719

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 225.

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

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 updateRemoteProfile has 58 lines of code (exceeds 25 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: Major
      Found in app/Commands/ConfigureCommand.php - About 2 hrs to fix

        ConfigureCommand has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ConfigureCommand extends Command
        {
            use CommandInternalsTrait, FileSystemTrait, SharedTrait;
        
            /**
        Severity: Minor
        Found in app/Commands/ConfigureCommand.php - About 2 hrs to fix

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

              private function updateRemoteProfileKey($profile, $name, $key)
              {
                  $default_value = '';
          
                  switch ($key) {
          Severity: Minor
          Found in app/Commands/ConfigureCommand.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 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

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

                    while (true) {
                        $name = $this->ask('Set the name of this new local');
            
                        $name = preg_replace('/[^a-z0-9_-]/', '', strtolower($name));
            
            
            Severity: Major
            Found in app/Commands/ConfigureCommand.php and 1 other location - About 1 hr to fix
            app/Commands/ConfigureCommand.php on lines 538..553

            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 109.

            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

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

                    while (true) {
                        $name = $this->ask('Set the name of this new remote');
            
                        $name = preg_replace('/[^a-z0-9_-]/', '', strtolower($name));
            
            
            Severity: Major
            Found in app/Commands/ConfigureCommand.php and 1 other location - About 1 hr to fix
            app/Commands/ConfigureCommand.php on lines 865..880

            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 109.

            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

            Method execRemoteConnection has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function execRemoteConnection($profile, $name, $command)
                {
                    if (!array_get($this->profiles, $profile.'.remote.'.$name.'.working', false)) {
                        $this->error('Remote profile has not been tested. Use configure command to fix.');
            
            
            Severity: Minor
            Found in app/Traits/SharedTrait.php - About 1 hr to fix

              Method updateRemoteProfileKey has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function updateRemoteProfileKey($profile, $name, $key)
                  {
                      $default_value = '';
              
                      switch ($key) {
              Severity: Minor
              Found in app/Commands/ConfigureCommand.php - About 1 hr to fix

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

                        switch ($connection) {
                Severity: Minor
                Found in app/Commands/ConfigureCommand.php by phpmd

                UndefinedVariable

                Since: 2.8.0

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

                Example

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

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

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

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

                UndefinedVariable

                Since: 2.8.0

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

                Example

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

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

                Function testRemoteProfile has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function testRemoteProfile($profile, $name)
                    {
                        $connection_works = false;
                
                        $data = array_get($this->profiles, $profile.'.remote.'.$name, []);
                Severity: Minor
                Found in app/Commands/ConfigureCommand.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 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
                  Severity
                  Category
                  Status
                  Source
                  Language