lesterchan/wp-sweep

View on GitHub

Showing 27 of 326 total issues

Function sweep has a Cognitive Complexity of 108 (exceeds 5 allowed). Consider refactoring.
Open

    public function sweep( $name ) {
        global $wpdb;

        $message = '';

Severity: Minor
Found in inc/class-wpsweep.php - About 2 days 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

File class-wpsweep.php has 632 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WP-Sweep class-wpsweep.php
 *
 * @package wp-sweep
Severity: Major
Found in inc/class-wpsweep.php - About 1 day to fix

    File admin.php has 554 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * WP-Sweep admin.php
     *
     * @package wp-sweep
    Severity: Major
    Found in admin.php - About 1 day to fix

      Method sweep has 224 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function sweep( $name ) {
              global $wpdb;
      
              $message = '';
      
      
      Severity: Major
      Found in inc/class-wpsweep.php - About 1 day to fix

        Function details has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

            public function details( $name ) {
                global $wpdb;
        
                $details = array();
        
        
        Severity: Minor
        Found in inc/class-wpsweep.php - About 4 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

        Function count has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            public function count( $name ) {
                global $wpdb;
        
                $count = 0;
        
        
        Severity: Minor
        Found in inc/class-wpsweep.php - About 3 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 details has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function details( $name ) {
                global $wpdb;
        
                $details = array();
        
        
        Severity: Major
        Found in inc/class-wpsweep.php - About 3 hrs to fix

          The class WPSweep has 14 public methods. Consider refactoring WPSweep to keep number of public methods under 10.
          Open

          class WPSweep {
              /**
               * Limit the number of items to show for sweep details
               *
               * @since 1.0.3
          Severity: Minor
          Found in inc/class-wpsweep.php by phpmd

          TooManyPublicMethods

          Since: 0.1

          A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

          By default it ignores methods starting with 'get' or 'set'.

          Example

          Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

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

          class WPSweep {
              /**
               * Limit the number of items to show for sweep details
               *
               * @since 1.0.3
          Severity: Minor
          Found in inc/class-wpsweep.php by phpmd

          Method count has 75 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function count( $name ) {
                  global $wpdb;
          
                  $count = 0;
          
          
          Severity: Major
          Found in inc/class-wpsweep.php - About 3 hrs to fix

            Method ajax_sweep has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function ajax_sweep() {
                    // Verify referer and check permissions.
                    if (
                        empty( $_GET['sweep_name'] )
                        || empty( $_GET['sweep_type'] )
            Severity: Major
            Found in inc/class-wpsweep.php - About 2 hrs to fix

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

              class WPSweep {
                  /**
                   * Limit the number of items to show for sweep details
                   *
                   * @since 1.0.3
              Severity: Minor
              Found in inc/class-wpsweep.php - About 2 hrs to fix

                Method __construct has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function __construct() {
                        add_action(
                            'rest_api_init', function() {
                                register_rest_route(
                                    $this->namespace, 'count/(?P<name>\w+)', array(
                Severity: Minor
                Found in inc/class-wpsweep-api.php - About 1 hr to fix

                  Method total_count has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function total_count( $name ) {
                          global $wpdb;
                  
                          $count = 0;
                  
                  
                  Severity: Minor
                  Found in inc/class-wpsweep.php - About 1 hr to fix

                    Function total_count has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function total_count( $name ) {
                            global $wpdb;
                    
                            $count = 0;
                    
                    
                    Severity: Minor
                    Found in inc/class-wpsweep.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 __invoke has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function __invoke( $args, $assoc_args ) {
                    
                            $items = array();
                    
                            $default_items = array(
                    Severity: Minor
                    Found in inc/class-wpsweep-command.php - About 1 hr to fix

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

                          private function get_default_taxonomy_termids() {
                              $taxonomies       = get_taxonomies();
                              $default_term_ids = array();
                              if ( $taxonomies ) {
                                  $tax = array_keys( $taxonomies );
                      Severity: Minor
                      Found in inc/class-wpsweep.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

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

                          public function ajax_sweep() {
                              // Verify referer and check permissions.
                              if (
                                  empty( $_GET['sweep_name'] )
                                  || empty( $_GET['sweep_type'] )
                      Severity: Minor
                      Found in inc/class-wpsweep.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 plugin_activation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function plugin_activation( $network_wide ) {
                              if ( is_multisite() && $network_wide ) {
                                  $ms_sites = (array) get_sites();
                      
                                  if ( 0 < count( $ms_sites ) ) {
                      Severity: Minor
                      Found in inc/class-wpsweep.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 plugin_deactivation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function plugin_deactivation( $network_wide ) {
                              if ( is_multisite() && $network_wide ) {
                                  $ms_sites = (array) get_sites();
                      
                                  if ( 0 < count( $ms_sites ) ) {
                      Severity: Minor
                      Found in inc/class-wpsweep.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

                      Severity
                      Category
                      Status
                      Source
                      Language