lesterchan/wp-sweep

View on GitHub

Showing 326 of 326 total issues

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

                    <?php if ( ! empty( $orphan_postmeta ) ) : ?>
                        <button data-action="sweep" data-sweep_name="orphan_postmeta" data-sweep_type="postmeta" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wp_sweep_orphan_postmeta' ) ); ?>" class="button button-primary btn-sweep"><?php esc_html_e( 'Sweep', 'wp-sweep' ); ?></button>
                        <button data-action="sweep_details" data-sweep_name="orphan_postmeta" data-sweep_type="postmeta" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wp_sweep_details_orphan_postmeta' ) ); ?>" class="button btn-sweep-details"><?php esc_html_e( 'Details', 'wp-sweep' ); ?></button>
                    <?php else : ?>
                        <?php esc_html_e( 'N/A', 'wp-sweep' ); ?>
Severity: Major
Found in admin.php and 18 other locations - About 35 mins to fix
admin.php on lines 112..117
admin.php on lines 132..137
admin.php on lines 152..157
admin.php on lines 192..197
admin.php on lines 212..217
admin.php on lines 250..255
admin.php on lines 270..275
admin.php on lines 290..295
admin.php on lines 310..315
admin.php on lines 330..335
admin.php on lines 368..373
admin.php on lines 388..393
admin.php on lines 426..431
admin.php on lines 446..451
admin.php on lines 466..471
admin.php on lines 487..492
admin.php on lines 525..530
admin.php on lines 563..568

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

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

                    <?php if ( ! empty( $total_tables ) ) : ?>
                        <button data-action="sweep" data-sweep_name="optimize_database" data-sweep_type="tables" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wp_sweep_optimize_database' ) ); ?>" class="button button-primary btn-sweep"><?php esc_html_e( 'Sweep', 'wp-sweep' ); ?></button>
                        <button data-action="sweep_details" data-sweep_name="optimize_database" data-sweep_type="tables" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wp_sweep_details_optimize_database' ) ); ?>" class="button btn-sweep-details"><?php esc_html_e( 'Details', 'wp-sweep' ); ?></button>
                    <?php else : ?>
                        <?php esc_html_e( 'N/A', 'wp-sweep' ); ?>
Severity: Major
Found in admin.php and 18 other locations - About 35 mins to fix
admin.php on lines 112..117
admin.php on lines 132..137
admin.php on lines 152..157
admin.php on lines 172..177
admin.php on lines 192..197
admin.php on lines 212..217
admin.php on lines 250..255
admin.php on lines 270..275
admin.php on lines 290..295
admin.php on lines 310..315
admin.php on lines 330..335
admin.php on lines 368..373
admin.php on lines 388..393
admin.php on lines 426..431
admin.php on lines 446..451
admin.php on lines 466..471
admin.php on lines 487..492
admin.php on lines 525..530

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

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

Inline PHP statement must end with a semicolon
Open

    <?php /* translators: %1 is the number of comments, %2 is the number of comment meta */ ?>
Severity: Minor
Found in admin.php by phpcodesniffer

Inline comments must end in full-stops, exclamation marks, or question marks
Open

                $query = $wpdb->get_results( $wpdb->prepare( "SELECT tt.term_taxonomy_id, t.term_id, tt.taxonomy FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.count = %d AND t.term_id NOT IN (" . implode( ',', $this->get_excluded_termids() ) . ')', 0 ) ); // phpcs:ignore
Severity: Minor
Found in inc/class-wpsweep.php by phpcodesniffer

Inline comments must end in full-stops, exclamation marks, or question marks
Open

                        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_id IN (" . implode( ',', $ids ) . ') AND post_id = %d', (int) $meta->post_id ) ); // phpcs:ignore
Severity: Minor
Found in inc/class-wpsweep.php by phpcodesniffer

Inline PHP statement must end with a semicolon
Open

    <?php /* translators: %1 is the number of options */ ?>
Severity: Minor
Found in admin.php by phpcodesniffer

Inline comments must end in full-stops, exclamation marks, or question marks
Open

                $count                         = $wpdb->get_var( "SELECT COUNT(object_id) FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy NOT IN ('$orphan_term_relationships_sql') AND tr.object_id NOT IN (SELECT ID FROM $wpdb->posts)" ); // phpcs:ignore
Severity: Minor
Found in inc/class-wpsweep.php by phpcodesniffer

Use placeholders and $wpdb->prepare(); found get_excluded_termids
Open

                $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(t.term_id) FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.count = %d AND t.term_id NOT IN (" . implode( ',', $this->get_excluded_termids() ) . ')', 0 ) ); // phpcs:ignore
Severity: Minor
Found in inc/class-wpsweep.php by phpcodesniffer

Use placeholders and $wpdb->prepare(); found $ids
Open

                        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE umeta_id IN (" . implode( ',', $ids ) . ') AND user_id = %d', (int) $meta->user_id ) ); // phpcs:ignore
Severity: Minor
Found in inc/class-wpsweep.php by phpcodesniffer

Use placeholders and $wpdb->prepare(); found $ids
Open

                        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_id IN (" . implode( ',', $ids ) . ') AND post_id = %d', (int) $meta->post_id ) ); // phpcs:ignore
Severity: Minor
Found in inc/class-wpsweep.php by phpcodesniffer

Inline PHP statement must end with a semicolon
Open

            <?php /* translators: %1 WP-DBManager Plugin URL, %2 _blank to open new window */ ?>
Severity: Minor
Found in admin.php by phpcodesniffer

Inline PHP statement must end with a semicolon
Open

        <?php /* translators: %s maximum number of results */ ?>
Severity: Minor
Found in admin.php by phpcodesniffer

Use placeholders and $wpdb->prepare(); found get_excluded_termids
Open

                $query = $wpdb->get_results( $wpdb->prepare( "SELECT tt.term_taxonomy_id, t.term_id, tt.taxonomy FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.count = %d AND t.term_id NOT IN (" . implode( ',', $this->get_excluded_termids() ) . ')', 0 ) ); // phpcs:ignore
Severity: Minor
Found in inc/class-wpsweep.php by phpcodesniffer

Use placeholders and $wpdb->prepare(); found interpolated variable $tables at "OPTIMIZE TABLE $tables"
Open

                    $wpdb->query( "OPTIMIZE TABLE $tables" ); // phpcs:ignore
Severity: Minor
Found in inc/class-wpsweep.php by phpcodesniffer

Inline comments must end in full-stops, exclamation marks, or question marks
Open

                $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(t.term_id) FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.count = %d AND t.term_id NOT IN (" . implode( ',', $this->get_excluded_termids() ) . ')', 0 ) ); // phpcs:ignore
Severity: Minor
Found in inc/class-wpsweep.php by phpcodesniffer

Use placeholders and $wpdb->prepare(); found $ids
Open

                        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->termmeta WHERE meta_id IN (" . implode( ',', $ids ) . ') AND term_id = %d', (int) $meta->term_id ) ); // phpcs:ignore
Severity: Minor
Found in inc/class-wpsweep.php by phpcodesniffer

Use placeholders and $wpdb->prepare(); found $this
Open

                $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(t.term_id) FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.count = %d AND t.term_id NOT IN (" . implode( ',', $this->get_excluded_termids() ) . ')', 0 ) ); // phpcs:ignore
Severity: Minor
Found in inc/class-wpsweep.php by phpcodesniffer

Use placeholders and $wpdb->prepare(); found get_excluded_termids
Open

                $details = $wpdb->get_col( $wpdb->prepare( "SELECT t.name FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.count = %d AND t.term_id NOT IN (" . implode( ',', $this->get_excluded_termids() ) . ') LIMIT %d', 0, $this->limit_details ) ); // phpcs:ignore
Severity: Minor
Found in inc/class-wpsweep.php by phpcodesniffer

Inline comments must end in full-stops, exclamation marks, or question marks
Open

                $details = $wpdb->get_col( $wpdb->prepare( "SELECT t.name FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.count = %d AND t.term_id NOT IN (" . implode( ',', $this->get_excluded_termids() ) . ') LIMIT %d', 0, $this->limit_details ) ); // phpcs:ignore
Severity: Minor
Found in inc/class-wpsweep.php by phpcodesniffer

Use placeholders and $wpdb->prepare(); found get_excluded_taxonomies
Open

                $query = $wpdb->get_results( "SELECT tr.object_id, tr.term_taxonomy_id, tt.term_id, tt.taxonomy FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy NOT IN ('" . implode( '\',\'', $this->get_excluded_taxonomies() ) . "') AND tr.object_id NOT IN (SELECT ID FROM $wpdb->posts)" ); // phpcs:ignore
Severity: Minor
Found in inc/class-wpsweep.php by phpcodesniffer
Severity
Category
Status
Source
Language