lesterchan/wp-sweep

View on GitHub

Showing 326 of 326 total issues

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

    Avoid excessively long variable names like $orphan_term_relationships_sql. Keep variable name length under 20.
    Open

                    $orphan_term_relationships_sql = implode( "','", array_map( 'esc_sql', $this->get_excluded_taxonomies() ) );
    Severity: Minor
    Found in inc/class-wpsweep.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    Avoid excessively long variable names like $wp_remove_object_terms. Keep variable name length under 20.
    Open

                            $wp_remove_object_terms = wp_remove_object_terms( (int) $tax->object_id, (int) $tax->term_id, $tax->taxonomy );
    Severity: Minor
    Found in inc/class-wpsweep.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    Avoid excessively long variable names like $orphan_term_relationships_sql. Keep variable name length under 20.
    Open

                    $orphan_term_relationships_sql = implode( "','", array_map( 'esc_sql', $this->get_excluded_taxonomies() ) );
    Severity: Minor
    Found in inc/class-wpsweep.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    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

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

                    case 'auto_drafts':
                        $query = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_status = %s", 'auto-draft' ) );
                        if ( $query ) {
                            foreach ( $query as $id ) {
                                wp_delete_post( (int) $id, true );
        Severity: Major
        Found in inc/class-wpsweep.php and 2 other locations - About 1 hr to fix
        inc/class-wpsweep.php on lines 538..548
        inc/class-wpsweep.php on lines 549..559

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

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

                    case 'unapproved_comments':
                        $query = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = %s", '0' ) );
                        if ( $query ) {
                            foreach ( $query as $id ) {
                                wp_delete_comment( (int) $id, true );
        Severity: Major
        Found in inc/class-wpsweep.php and 2 other locations - About 1 hr to fix
        inc/class-wpsweep.php on lines 516..526
        inc/class-wpsweep.php on lines 549..559

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

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

                    case 'spam_comments':
                        $query = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = %s", 'spam' ) );
                        if ( $query ) {
                            foreach ( $query as $id ) {
                                wp_delete_comment( (int) $id, true );
        Severity: Major
        Found in inc/class-wpsweep.php and 2 other locations - About 1 hr to fix
        inc/class-wpsweep.php on lines 516..526
        inc/class-wpsweep.php on lines 538..548

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

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

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

                    $.get(ajaxurl, { action: $node.data( 'action' ), sweep_name: $node.data( 'sweep_name' ), sweep_type: $node.data( 'sweep_type' ), '_wpnonce': $node.data( 'nonce' ) }, function(data) {
        Severity: Minor
        Found in js/wp-sweep.js and 1 other location - About 55 mins to fix
        js/wp-sweep.js on lines 14..14

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

        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

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

                        return $.get(ajaxurl, { action: $node.data( 'action' ), sweep_name: $node.data( 'sweep_name' ), sweep_type: $node.data( 'sweep_type' ), '_wpnonce': $node.data( 'nonce' ) }, function(data) {
        Severity: Minor
        Found in js/wp-sweep.js and 1 other location - About 55 mins to fix
        js/wp-sweep.js on lines 50..50

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

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

        The class WPSweep_Api is not named in CamelCase.
        Open

        class WPSweep_Api {
            /**
             * WP-Sweep WP Rest API namespace
             *
             * @var string
        Severity: Minor
        Found in inc/class-wpsweep-api.php by phpmd

        CamelCaseClassName

        Since: 0.2

        It is considered best practice to use the CamelCase notation to name classes.

        Example

        class class_name {
        }

        Source

        The parameter $assoc_args is not named in camelCase.
        Open

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

        CamelCaseParameterName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name parameters.

        Example

        class ClassName {
            public function doSomething($user_name) {
            }
        }

        Source

        The property $limit_details is not named in camelCase.
        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

        CamelCasePropertyName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name attributes.

        Example

        class ClassName {
            protected $property_name;
        }

        Source

        The class WPSweep_Command is not named in CamelCase.
        Open

        class WPSweep_Command extends WP_CLI_Command {
            /**
             * Clean up unused, orphaned and duplicated data in your WordPress
             *
             * ## OPTIONS
        Severity: Minor
        Found in inc/class-wpsweep-command.php by phpmd

        CamelCaseClassName

        Since: 0.2

        It is considered best practice to use the CamelCase notation to name classes.

        Example

        class class_name {
        }

        Source

        The parameter $network_wide is not named in camelCase.
        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 by phpmd

        CamelCaseParameterName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name parameters.

        Example

        class ClassName {
            public function doSomething($user_name) {
            }
        }

        Source

        The parameter $network_wide is not named in camelCase.
        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 by phpmd

        CamelCaseParameterName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name parameters.

        Example

        class ClassName {
            public function doSomething($user_name) {
            }
        }

        Source

        Severity
        Category
        Status
        Source
        Language