CaffGeek/MBACNationals

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

Summary

Maintainability
F
1 wk
Test Coverage

Function parselisting has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    function parselisting($line) {
        static $is_windows;
        if ( is_null($is_windows) )
            $is_windows = strpos( strtolower(ftp_systype($this->link)), 'win') !== false;

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 dirlist has a Cognitive Complexity of 26 (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

WP_Filesystem_FTPext has 30 functions (exceeds 20 allowed). Consider refactoring.
Open

class WP_Filesystem_FTPext extends WP_Filesystem_Base {
    var $link;
    var $errors = null;
    var $options = array();

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

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

      Method parselisting has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function parselisting($line) {
              static $is_windows;
              if ( is_null($is_windows) )
                  $is_windows = strpos( strtolower(ftp_systype($this->link)), 'win') !== false;
      
      

        Function WP_Filesystem_FTPext has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            function WP_Filesystem_FTPext($opt='') {
                $this->method = 'ftpext';
                $this->errors = new WP_Error();
        
                //Check if possible to use ftp 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

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

            function chmod($file, $mode = false, $recursive = false) {
                if ( ! $this->exists($file) && ! $this->is_dir($file) )
                    return false;
        
                if ( ! $mode ) {

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

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

            Avoid too many return statements within this method.
            Open

                    return true;

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

                  function connect() {
                      if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') )
                          $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
                      else
                          $this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);

              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 delete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  function delete($file, $recursive = false ) {
                      if ( empty($file) )
                          return false;
                      if ( $this->is_file($file) )
                          return @ftp_delete($this->link, $file);

              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

                      if ( $is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/", $line, $lucifer) ) {
                          $b = array();
                          if ( $lucifer[3] < 70 ) { $lucifer[3] +=2000; } else { $lucifer[3] += 1900; } // 4digit year fix
                          $b['isdir'] = ($lucifer[7]=="<DIR>");
                          if ( $b['isdir'] )
              Web.Admin/2014/wordpress/wp-admin/includes/class-ftp.php on lines 166..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 935.

              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