wpsmith/MuPluginManager

View on GitHub

Showing 9 of 9 total issues

Function init_wp_filesystem has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

        public function init_wp_filesystem() {
            // Make sure we have access to WP_Filesystem.
            if ( ! function_exists( 'WP_Filesystem' ) ) {
                require_once( ABSPATH . '/wp-admin/includes/file.php' );
            }
Severity: Minor
Found in src/MuPluginManager.php - About 2 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 init_wp_filesystem has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function init_wp_filesystem() {
            // Make sure we have access to WP_Filesystem.
            if ( ! function_exists( 'WP_Filesystem' ) ) {
                require_once( ABSPATH . '/wp-admin/includes/file.php' );
            }
Severity: Minor
Found in src/MuPluginManager.php - About 1 hr to fix

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

            public function copy_muplugin() {
                if ( null === $this->filesystem ) {
                    $this->init_wp_filesystem();
                }
    
    
    Severity: Minor
    Found in src/MuPluginManager.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 is_muplugin_update_required has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            protected function is_muplugin_update_required() {
                // Return true if the mu-plugin is not installed.
                if ( ! $this->is_muplugin_installed() ) {
                    return true;
                }
    Severity: Minor
    Found in src/MuPluginManager.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

    Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            public function __construct( $src, $dest_filename, $version, $settings_name = null, $throw_errs = false ) {
    Severity: Minor
    Found in src/MuPluginManager.php - About 35 mins to fix

      Function is_muplugin_writable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              public function is_muplugin_writable() {
                  //Assumes by default we can create the mu-plugins folder and compatibility plugin if they don't exist
                  $mu_folder_writable = true;
                  $mu_plugin_writable = true;
      
      
      Severity: Minor
      Found in src/MuPluginManager.php - About 35 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 write_log has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function write_log( $log ) {
                  if ( true === WP_DEBUG ) {
                      if ( is_array( $log ) || is_object( $log ) ) {
                          error_log( print_r( $log, true ) );
                      } else {
      Severity: Minor
      Found in src/MuPluginManager.php - About 35 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 on_deactivation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function on_deactivation( MuPluginManager $instance ) {
                  self::$activation_result  = $instance->remove_muplugin();
      
                  // If successfully removed, let's do some DB cleanup.
                  if ( true === self::$activation_result && null !== $instance->settings ) {
      Severity: Minor
      Found in src/MuPluginManager.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 muplugin_version_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              public function muplugin_version_check() {
                  if (
                      self::is_plugins_page() &&
                      true === $this->is_muplugin_update_required()
                  ) {
      Severity: Minor
      Found in src/MuPluginManager.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

      Severity
      Category
      Status
      Source
      Language