lesterchan/wp-sweep

View on GitHub

Showing 326 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

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

                    case 'duplicated_usermeta':
                        $query = $wpdb->get_results( $wpdb->prepare( "SELECT GROUP_CONCAT(umeta_id ORDER BY umeta_id DESC) AS ids, user_id, COUNT(*) AS count FROM $wpdb->usermeta GROUP BY user_id, meta_key, meta_value HAVING count > %d", 1 ) );
                        if ( $query ) {
                            foreach ( $query as $meta ) {
                                $ids = array_map( 'intval', explode( ',', $meta->ids ) );
        Severity: Major
        Found in inc/class-wpsweep.php and 3 other locations - About 4 hrs to fix
        inc/class-wpsweep.php on lines 685..697
        inc/class-wpsweep.php on lines 698..710
        inc/class-wpsweep.php on lines 724..736

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

        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 4 locations. Consider refactoring.
        Open

                    case 'duplicated_commentmeta':
                        $query = $wpdb->get_results( $wpdb->prepare( "SELECT GROUP_CONCAT(meta_id ORDER BY meta_id DESC) AS ids, comment_id, COUNT(*) AS count FROM $wpdb->commentmeta GROUP BY comment_id, meta_key, meta_value HAVING count > %d", 1 ) );
                        if ( $query ) {
                            foreach ( $query as $meta ) {
                                $ids = array_map( 'intval', explode( ',', $meta->ids ) );
        Severity: Major
        Found in inc/class-wpsweep.php and 3 other locations - About 4 hrs to fix
        inc/class-wpsweep.php on lines 685..697
        inc/class-wpsweep.php on lines 711..723
        inc/class-wpsweep.php on lines 724..736

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

        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 4 locations. Consider refactoring.
        Open

                    case 'duplicated_postmeta':
                        $query = $wpdb->get_results( $wpdb->prepare( "SELECT GROUP_CONCAT(meta_id ORDER BY meta_id DESC) AS ids, post_id, COUNT(*) AS count FROM $wpdb->postmeta GROUP BY post_id, meta_key, meta_value HAVING count > %d", 1 ) );
                        if ( $query ) {
                            foreach ( $query as $meta ) {
                                $ids = array_map( 'intval', explode( ',', $meta->ids ) );
        Severity: Major
        Found in inc/class-wpsweep.php and 3 other locations - About 4 hrs to fix
        inc/class-wpsweep.php on lines 698..710
        inc/class-wpsweep.php on lines 711..723
        inc/class-wpsweep.php on lines 724..736

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

        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 4 locations. Consider refactoring.
        Open

                    case 'duplicated_termmeta':
                        $query = $wpdb->get_results( $wpdb->prepare( "SELECT GROUP_CONCAT(meta_id ORDER BY meta_id DESC) AS ids, term_id, COUNT(*) AS count FROM $wpdb->termmeta GROUP BY term_id, meta_key, meta_value HAVING count > %d", 1 ) );
                        if ( $query ) {
                            foreach ( $query as $meta ) {
                                $ids = array_map( 'intval', explode( ',', $meta->ids ) );
        Severity: Major
        Found in inc/class-wpsweep.php and 3 other locations - About 4 hrs to fix
        inc/class-wpsweep.php on lines 685..697
        inc/class-wpsweep.php on lines 698..710
        inc/class-wpsweep.php on lines 711..723

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

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

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

                      case 'orphan_postmeta':
                          $query = $wpdb->get_results( "SELECT post_id, meta_key FROM $wpdb->postmeta WHERE post_id NOT IN (SELECT ID FROM $wpdb->posts)" );
                          if ( $query ) {
                              foreach ( $query as $meta ) {
                                  $post_id = (int) $meta->post_id;
          Severity: Major
          Found in inc/class-wpsweep.php and 3 other locations - About 3 hrs to fix
          inc/class-wpsweep.php on lines 602..617
          inc/class-wpsweep.php on lines 618..633
          inc/class-wpsweep.php on lines 634..649

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

          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 4 locations. Consider refactoring.
          Open

                      case 'orphan_termmeta':
                          $query = $wpdb->get_results( "SELECT term_id, meta_key FROM $wpdb->termmeta WHERE term_id NOT IN (SELECT term_id FROM $wpdb->terms)" );
                          if ( $query ) {
                              foreach ( $query as $meta ) {
                                  $term_id = (int) $meta->term_id;
          Severity: Major
          Found in inc/class-wpsweep.php and 3 other locations - About 3 hrs to fix
          inc/class-wpsweep.php on lines 586..601
          inc/class-wpsweep.php on lines 602..617
          inc/class-wpsweep.php on lines 618..633

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

          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 4 locations. Consider refactoring.
          Open

                      case 'orphan_usermeta':
                          $query = $wpdb->get_results( "SELECT user_id, meta_key FROM $wpdb->usermeta WHERE user_id NOT IN (SELECT ID FROM $wpdb->users)" );
                          if ( $query ) {
                              foreach ( $query as $meta ) {
                                  $user_id = (int) $meta->user_id;
          Severity: Major
          Found in inc/class-wpsweep.php and 3 other locations - About 3 hrs to fix
          inc/class-wpsweep.php on lines 586..601
          inc/class-wpsweep.php on lines 602..617
          inc/class-wpsweep.php on lines 634..649

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

          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 4 locations. Consider refactoring.
          Open

                      case 'orphan_commentmeta':
                          $query = $wpdb->get_results( "SELECT comment_id, meta_key FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_ID FROM $wpdb->comments)" );
                          if ( $query ) {
                              foreach ( $query as $meta ) {
                                  $comment_id = (int) $meta->comment_id;
          Severity: Major
          Found in inc/class-wpsweep.php and 3 other locations - About 3 hrs to fix
          inc/class-wpsweep.php on lines 586..601
          inc/class-wpsweep.php on lines 618..633
          inc/class-wpsweep.php on lines 634..649

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

          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 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
                Severity
                Category
                Status
                Source
                Language