CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php

Summary

Maintainability
F
5 days
Test Coverage

WP_Filesystem_SSH2 has 29 functions (exceeds 20 allowed). Consider refactoring.
Open

class WP_Filesystem_SSH2 extends WP_Filesystem_Base {

    var $link = false;
    var $sftp_link = false;
    var $keys = false;

    Function dirlist has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        function dirlist($path, $include_hidden = true, $recursive = false) {
            if ( $this->is_file($path) ) {
                $limit_file = basename($path);
                $path = dirname($path);
            } else {

    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

    File class-wp-filesystem-ssh2.php has 275 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * WordPress SSH2 Filesystem.
     *
     * @package WordPress

      Function WP_Filesystem_SSH2 has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          function WP_Filesystem_SSH2($opt='') {
              $this->method = 'ssh2';
              $this->errors = new WP_Error();
      
              //Check if possible to use ssh2 functions.

      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 dirlist has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function dirlist($path, $include_hidden = true, $recursive = false) {
              if ( $this->is_file($path) ) {
                  $limit_file = basename($path);
                  $path = dirname($path);
              } else {

        Method WP_Filesystem_SSH2 has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function WP_Filesystem_SSH2($opt='') {
                $this->method = 'ssh2';
                $this->errors = new WP_Error();
        
                //Check if possible to use ssh2 functions.

          Function connect has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              function connect() {
                  if ( ! $this->keys ) {
                      $this->link = @ssh2_connect($this->options['hostname'], $this->options['port']);
                  } else {
                      $this->link = @ssh2_connect($this->options['hostname'], $this->options['port'], $this->options['hostkey']);
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php - About 55 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 chmod has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              function chmod($file, $mode = false, $recursive = false) {
                  if ( ! $this->exists($file) )
                      return false;
          
                  if ( ! $mode ) {
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php - About 45 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 run_command has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              function run_command( $command, $returnbool = false) {
          
                  if ( ! $this->link )
                      return false;
          
          
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.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

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

                  while (false !== ($entry = $dir->read()) ) {
                      $struc = array();
                      $struc['name'] = $entry;
          
                      if ( '.' == $struc['name'] || '..' == $struc['name'] )
          Web.Admin/2014/wordpress/wp-admin/includes/class-wp-filesystem-direct.php on lines 327..359

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

          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

              function chown($file, $owner, $recursive = false ) {
                  if ( ! $this->exists($file) )
                      return false;
                  if ( ! $recursive || ! $this->is_dir($file) )
                      return $this->run_command(sprintf('chown %o %s', $mode, escapeshellarg($file)), true);
          Web.Admin/2014/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php on lines 179..185

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

          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

              function chgrp($file, $group, $recursive = false ) {
                  if ( ! $this->exists($file) )
                      return false;
                  if ( ! $recursive || ! $this->is_dir($file) )
                      return $this->run_command(sprintf('chgrp %o %s', $mode, escapeshellarg($file)), true);
          Web.Admin/2014/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php on lines 205..211

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

          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

              function group($file) {
                  $gid = @filegroup('ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/'));
                  if ( ! $gid )
                      return false;
                  if ( ! function_exists('posix_getgrgid') )
          Web.Admin/2014/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php on lines 213..221

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

          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

              function owner($file) {
                  $owneruid = @fileowner('ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/'));
                  if ( ! $owneruid )
                      return false;
                  if ( ! function_exists('posix_getpwuid') )
          Web.Admin/2014/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php on lines 227..235

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

          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

          There are no issues that match your filters.

          Category
          Status