File post.php
has 3830 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Core Post API
*
* @package WordPress
Function wp_insert_post
has a Cognitive Complexity of 191 (exceeds 5 allowed). Consider refactoring. Open
function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true ) {
global $wpdb;
// Capture original pre-sanitized array for passing into filters.
$unsanitized_postarr = $postarr;
- Read upRead up
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 create_initial_post_types
has 703 lines of code (exceeds 25 allowed). Consider refactoring. Open
function create_initial_post_types() {
WP_Post_Type::reset_default_labels();
register_post_type(
'post',
Method wp_insert_post
has 392 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true ) {
global $wpdb;
// Capture original pre-sanitized array for passing into filters.
$unsanitized_postarr = $postarr;
Function wp_mime_type_icon
has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring. Open
function wp_mime_type_icon( $mime = 0, $preferred_ext = '.png' ) {
if ( ! is_numeric( $mime ) ) {
$icon = wp_cache_get( "mime_type_icon_$mime" );
}
- Read upRead up
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 get_pages
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
function get_pages( $args = array() ) {
$defaults = array(
'child_of' => 0,
'sort_order' => 'ASC',
'sort_column' => 'post_title',
- Read upRead up
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 wp_delete_attachment_files
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
function wp_delete_attachment_files( $post_id, $meta, $backup_sizes, $file ) {
global $wpdb;
$uploadpath = wp_get_upload_dir();
$deleted = true;
- Read upRead up
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 get_pages
has 132 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_pages( $args = array() ) {
$defaults = array(
'child_of' => 0,
'sort_order' => 'ASC',
'sort_column' => 'post_title',
Function wp_unique_post_slug
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_parent ) {
if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ), true )
|| ( 'inherit' === $post_status && 'revision' === $post_type ) || 'user_request' === $post_type
) {
return $slug;
- Read upRead up
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 get_page_by_path
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) {
global $wpdb;
$last_changed = wp_cache_get_last_changed( 'posts' );
- Read upRead up
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 wp_queue_posts_for_term_meta_lazyload
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
function wp_queue_posts_for_term_meta_lazyload( $posts ) {
$post_type_taxonomies = array();
$prime_post_terms = array();
foreach ( $posts as $post ) {
if ( ! ( $post instanceof WP_Post ) ) {
- Read upRead up
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 sanitize_post_field
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) {
$int_fields = array( 'ID', 'post_parent', 'menu_order' );
if ( in_array( $field, $int_fields, true ) ) {
$value = (int) $value;
}
- Read upRead up
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 wp_mime_type_icon
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_mime_type_icon( $mime = 0, $preferred_ext = '.png' ) {
if ( ! is_numeric( $mime ) ) {
$icon = wp_cache_get( "mime_type_icon_$mime" );
}
Method wp_unique_post_slug
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_parent ) {
if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ), true )
|| ( 'inherit' === $post_status && 'revision' === $post_type ) || 'user_request' === $post_type
) {
return $slug;
Function get_posts_by_author_sql
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
function get_posts_by_author_sql( $post_type, $full = true, $post_author = null, $public_only = false ) {
global $wpdb;
if ( is_array( $post_type ) ) {
$post_types = $post_type;
- Read upRead up
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 get_post_mime_types
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_post_mime_types() {
$post_mime_types = array( // array( adj, noun )
'image' => array(
__( 'Images' ),
__( 'Manage Images' ),
Method wp_delete_post
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_delete_post( $post_id = 0, $force_delete = false ) {
global $wpdb;
$post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id ) );
Function wp_match_mime_types
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function wp_match_mime_types( $wildcard_mime_types, $real_mime_types ) {
$matches = array();
if ( is_string( $wildcard_mime_types ) ) {
$wildcard_mime_types = array_map( 'trim', explode( ',', $wildcard_mime_types ) );
}
- Read upRead up
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 wp_post_mime_type_where
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
function wp_post_mime_type_where( $post_mime_types, $table_alias = '' ) {
$where = '';
$wildcards = array( '', '%', '%/%' );
if ( is_string( $post_mime_types ) ) {
$post_mime_types = array_map( 'trim', explode( ',', $post_mime_types ) );
- Read upRead up
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 register_post_status
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
function register_post_status( $post_status, $args = array() ) {
global $wp_post_statuses;
if ( ! is_array( $wp_post_statuses ) ) {
$wp_post_statuses = array();
Method get_page_by_path
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) {
global $wpdb;
$last_changed = wp_cache_get_last_changed( 'posts' );
Method sanitize_post_field
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) {
$int_fields = array( 'ID', 'post_parent', 'menu_order' );
if ( in_array( $field, $int_fields, true ) ) {
$value = (int) $value;
}
Function wp_delete_post
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function wp_delete_post( $post_id = 0, $force_delete = false ) {
global $wpdb;
$post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id ) );
- Read upRead up
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 get_post_status
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function get_post_status( $post = null ) {
// Normalize the post object if necessary, skip normalization if called from get_sample_permalink().
if ( ! $post instanceof WP_Post || ! isset( $post->filter ) || 'sample' !== $post->filter ) {
$post = get_post( $post );
}
- Read upRead up
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 get_children
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function get_children( $args = '', $output = OBJECT ) {
$kids = array();
if ( empty( $args ) ) {
if ( isset( $GLOBALS['post'] ) ) {
$args = array( 'post_parent' => (int) $GLOBALS['post']->post_parent );
- Read upRead up
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 get_post_mime_types
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function get_post_mime_types() {
$post_mime_types = array( // array( adj, noun )
'image' => array(
__( 'Images' ),
__( 'Manage Images' ),
- Read upRead up
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 wp_delete_attachment_files
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_delete_attachment_files( $post_id, $meta, $backup_sizes, $file ) {
global $wpdb;
$uploadpath = wp_get_upload_dir();
$deleted = true;
Function wp_publish_post
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function wp_publish_post( $post ) {
global $wpdb;
$post = get_post( $post );
- Read upRead up
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 wp_update_post
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function wp_update_post( $postarr = array(), $wp_error = false, $fire_after_hooks = true ) {
if ( is_object( $postarr ) ) {
// Non-escaped post was passed.
$postarr = get_object_vars( $postarr );
$postarr = wp_slash( $postarr );
- Read upRead up
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 sanitize_post
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function sanitize_post( $post, $context = 'display' ) {
if ( is_object( $post ) ) {
// Check if post already filtered for this context.
if ( isset( $post->filter ) && $context == $post->filter ) {
return $post;
- Read upRead up
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 wp_update_post
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_update_post( $postarr = array(), $wp_error = false, $fire_after_hooks = true ) {
if ( is_object( $postarr ) ) {
// Non-escaped post was passed.
$postarr = get_object_vars( $postarr );
$postarr = wp_slash( $postarr );
Method get_children
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_children( $args = '', $output = OBJECT ) {
$kids = array();
if ( empty( $args ) ) {
if ( isset( $GLOBALS['post'] ) ) {
$args = array( 'post_parent' => (int) $GLOBALS['post']->post_parent );
Method wp_delete_attachment
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_delete_attachment( $post_id, $force_delete = false ) {
global $wpdb;
$post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id ) );
Function wp_get_attachment_url
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function wp_get_attachment_url( $attachment_id = 0 ) {
global $pagenow;
$attachment_id = (int) $attachment_id;
- Read upRead up
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 update_post_caches
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function update_post_caches( &$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true ) {
// No point in doing all this work if we didn't match any posts.
if ( ! $posts ) {
return;
}
- Read upRead up
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 register_post_status
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function register_post_status( $post_status, $args = array() ) {
global $wp_post_statuses;
if ( ! is_array( $wp_post_statuses ) ) {
$wp_post_statuses = array();
- Read upRead up
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 get_posts_by_author_sql
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_posts_by_author_sql( $post_type, $full = true, $post_author = null, $public_only = false ) {
global $wpdb;
if ( is_array( $post_type ) ) {
$post_types = $post_type;
Method wp_publish_post
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_publish_post( $post ) {
global $wpdb;
$post = get_post( $post );
Method wp_post_mime_type_where
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_post_mime_type_where( $post_mime_types, $table_alias = '' ) {
$where = '';
$wildcards = array( '', '%', '%/%' );
if ( is_string( $post_mime_types ) ) {
$post_mime_types = array_map( 'trim', explode( ',', $post_mime_types ) );
Method _get_last_post_time
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _get_last_post_time( $timezone, $field, $post_type = 'any' ) {
global $wpdb;
if ( ! in_array( $field, array( 'date', 'modified' ), true ) ) {
return false;
Function wp_count_posts
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function wp_count_posts( $type = 'post', $perm = '' ) {
global $wpdb;
if ( ! post_type_exists( $type ) ) {
return new stdClass();
- Read upRead up
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 get_post
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) {
if ( empty( $post ) && isset( $GLOBALS['post'] ) ) {
$post = $GLOBALS['post'];
}
- Read upRead up
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 wp_get_attachment_url
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_get_attachment_url( $attachment_id = 0 ) {
global $pagenow;
$attachment_id = (int) $attachment_id;
Method wp_match_mime_types
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_match_mime_types( $wildcard_mime_types, $real_mime_types ) {
$matches = array();
if ( is_string( $wildcard_mime_types ) ) {
$wildcard_mime_types = array_map( 'trim', explode( ',', $wildcard_mime_types ) );
}
Method get_posts
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_posts( $args = null ) {
$defaults = array(
'numberposts' => 5,
'category' => 0,
'orderby' => 'date',
Method wp_count_posts
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_count_posts( $type = 'post', $perm = '' ) {
global $wpdb;
if ( ! post_type_exists( $type ) ) {
return new stdClass();
Method get_post_type_capabilities
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_post_type_capabilities( $args ) {
if ( ! is_array( $args->capability_type ) ) {
$args->capability_type = array( $args->capability_type, $args->capability_type . 's' );
}
Method wp_queue_posts_for_term_meta_lazyload
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_queue_posts_for_term_meta_lazyload( $posts ) {
$post_type_taxonomies = array();
$prime_post_terms = array();
foreach ( $posts as $post ) {
if ( ! ( $post instanceof WP_Post ) ) {
Method get_post_status
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_post_status( $post = null ) {
// Normalize the post object if necessary, skip normalization if called from get_sample_permalink().
if ( ! $post instanceof WP_Post || ! isset( $post->filter ) || 'sample' !== $post->filter ) {
$post = get_post( $post );
}
Function _prime_post_parent_id_caches
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function _prime_post_parent_id_caches( array $ids ) {
global $wpdb;
$ids = array_filter( $ids, '_validate_cache_id' );
$ids = array_unique( array_map( 'intval', $ids ), SORT_NUMERIC );
- Read upRead up
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 get_page_children
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function get_page_children( $page_id, $pages ) {
// Build a hash of ID -> children.
$children = array();
foreach ( (array) $pages as $page ) {
$children[ (int) $page->post_parent ][] = $page;
- Read upRead up
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 wp_trash_post
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_trash_post( $post_id = 0 ) {
if ( ! EMPTY_TRASH_DAYS ) {
return wp_delete_post( $post_id, true );
}
Method wp_untrash_post
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_untrash_post( $post_id = 0 ) {
$post = get_post( $post_id );
if ( ! $post ) {
return $post;
Method wp_attachment_is
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_attachment_is( $type, $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
Method update_post_caches
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function update_post_caches( &$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true ) {
// No point in doing all this work if we didn't match any posts.
if ( ! $posts ) {
return;
}
Method _get_custom_object_labels
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _get_custom_object_labels( $data_object, $nohier_vs_hier_defaults ) {
$data_object->labels = (array) $data_object->labels;
if ( isset( $data_object->label ) && empty( $data_object->labels['name'] ) ) {
$data_object->labels['name'] = $data_object->label;
Function _get_last_post_time
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function _get_last_post_time( $timezone, $field, $post_type = 'any' ) {
global $wpdb;
if ( ! in_array( $field, array( 'date', 'modified' ), true ) ) {
return false;
- Read upRead up
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 get_post
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) {
if ( empty( $post ) && isset( $GLOBALS['post'] ) ) {
$post = $GLOBALS['post'];
}
Method wp_get_recent_posts
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {
if ( is_numeric( $args ) ) {
_deprecated_argument( __FUNCTION__, '3.1.0', __( 'Passing an integer number of posts is deprecated. Pass an array of arguments instead.' ) );
$args = array( 'numberposts' => absint( $args ) );
Method _prime_post_parent_id_caches
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _prime_post_parent_id_caches( array $ids ) {
global $wpdb;
$ids = array_filter( $ids, '_validate_cache_id' );
$ids = array_unique( array_map( 'intval', $ids ), SORT_NUMERIC );
Consider simplifying this complex logical expression. Open
if ( 0 === $postname_index ||
( $postname_index && '%year%' === $permastructs[ $postname_index - 1 ] && 13 > $slug_num ) ||
( $postname_index && '%monthnum%' === $permastructs[ $postname_index - 1 ] && 32 > $slug_num )
) {
$conflicts_with_date_archive = true;
Function wp_delete_attachment
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function wp_delete_attachment( $post_id, $force_delete = false ) {
global $wpdb;
$post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id ) );
- Read upRead up
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 _transition_post_status
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function _transition_post_status( $new_status, $old_status, $post ) {
global $wpdb;
if ( 'publish' !== $old_status && 'publish' === $new_status ) {
// Reset GUID if transitioning to publish and it is empty.
- Read upRead up
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 wp_check_for_changed_dates
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function wp_check_for_changed_dates( $post_id, $post, $post_before ) {
$previous_date = gmdate( 'Y-m-d', strtotime( $post_before->post_date ) );
$new_date = gmdate( 'Y-m-d', strtotime( $post->post_date ) );
// Don't bother if it hasn't changed.
- Read upRead up
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 wp_check_for_changed_slugs
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function wp_check_for_changed_slugs( $post_id, $post, $post_before ) {
// Don't bother if it hasn't changed.
if ( $post->post_name == $post_before->post_name ) {
return;
}
- Read upRead up
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 get_enclosed
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function get_enclosed( $post_id ) {
$custom_fields = get_post_custom( $post_id );
$pung = array();
if ( ! is_array( $custom_fields ) ) {
return $pung;
- Read upRead up
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 _get_custom_object_labels
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function _get_custom_object_labels( $data_object, $nohier_vs_hier_defaults ) {
$data_object->labels = (array) $data_object->labels;
if ( isset( $data_object->label ) && empty( $data_object->labels['name'] ) ) {
$data_object->labels['name'] = $data_object->label;
- Read upRead up
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
Avoid deeply nested control flow statements. Open
while ( false !== $file = readdir( $dh ) ) {
$file = wp_basename( $file );
if ( str_starts_with( $file, '.' ) ) {
continue;
}
Method wp_insert_attachment
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function wp_insert_attachment( $args, $file = false, $parent_post_id = 0, $wp_error = false, $fire_after_hooks = true ) {
Method wp_unique_post_slug
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_parent ) {
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $post;
Avoid too many return
statements within this method. Open
return 0;
Avoid too many return
statements within this method. Open
return $weeuns;
Avoid too many return
statements within this method. Open
return 0;
Avoid too many return
statements within this method. Open
return $post_parent;
Avoid too many return
statements within this method. Open
return new WP_Error( 'invalid_date', __( 'Invalid date.' ) );
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $type === $ext;
Avoid too many return
statements within this method. Open
return 0;
Avoid too many return
statements within this method. Open
return new WP_Error( 'db_update_error', $message, $wpdb->last_error );
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $post;
Avoid too many return
statements within this method. Open
return $kids;
Avoid too many return
statements within this method. Open
return $type === $ext;
Avoid too many return
statements within this method. Open
return $post_id;
Avoid too many return
statements within this method. Open
return in_array( $ext, $image_exts, true );
Avoid too many return
statements within this method. Open
return $babes;
Avoid too many return
statements within this method. Open
return $post;
Avoid too many return
statements within this method. Open
return 0;
Avoid too many return
statements within this method. Open
return in_array( $ext, wp_get_video_extensions(), true );
Avoid too many return
statements within this method. Open
return new WP_Error( 'db_insert_error', $message, $wpdb->last_error );
Avoid too many return
statements within this method. Open
return $post;
Avoid too many return
statements within this method. Open
return $post_id;
Avoid too many return
statements within this method. Open
return new WP_Error( 'invalid_page_template', __( 'Invalid page template.' ) );
Avoid too many return
statements within this method. Open
return in_array( $ext, wp_get_audio_extensions(), true );
Function wp_set_post_terms
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function wp_set_post_terms( $post_id = 0, $terms = '', $taxonomy = 'post_tag', $append = false ) {
$post_id = (int) $post_id;
if ( ! $post_id ) {
return false;
- Read upRead up
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 get_page_uri
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function get_page_uri( $page = 0 ) {
if ( ! $page instanceof WP_Post ) {
$page = get_post( $page );
}
- Read upRead up
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 wp_untrash_post_comments
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function wp_untrash_post_comments( $post = null ) {
global $wpdb;
$post = get_post( $post );
- Read upRead up
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 wp_set_post_categories
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function wp_set_post_categories( $post_id = 0, $post_categories = array(), $append = false ) {
$post_id = (int) $post_id;
$post_type = get_post_type( $post_id );
$post_status = get_post_status( $post_id );
- Read upRead up
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_post_status_viewable
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function is_post_status_viewable( $post_status ) {
if ( is_scalar( $post_status ) ) {
$post_status = get_post_status_object( $post_status );
if ( ! $post_status ) {
- Read upRead up
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 get_post_ancestors
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function get_post_ancestors( $post ) {
$post = get_post( $post );
if ( ! $post || empty( $post->post_parent ) || $post->post_parent == $post->ID ) {
return array();
- Read upRead up
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 wp_attachment_is
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function wp_attachment_is( $type, $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
- Read upRead up
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 wp_check_post_hierarchy_for_loops
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function wp_check_post_hierarchy_for_loops( $post_parent, $post_id ) {
// Nothing fancy here - bail.
if ( ! $post_parent ) {
return 0;
}
- Read upRead up
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 get_posts
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function get_posts( $args = null ) {
$defaults = array(
'numberposts' => 5,
'category' => 0,
'orderby' => 'date',
- Read upRead up
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_post_type_viewable
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function is_post_type_viewable( $post_type ) {
if ( is_scalar( $post_type ) ) {
$post_type = get_post_type_object( $post_type );
if ( ! $post_type ) {
- Read upRead up
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 wp_resolve_post_date
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function wp_resolve_post_date( $post_date = '', $post_date_gmt = '' ) {
// If the date is empty, set the date to now.
if ( empty( $post_date ) || '0000-00-00 00:00:00' === $post_date ) {
if ( empty( $post_date_gmt ) || '0000-00-00 00:00:00' === $post_date_gmt ) {
$post_date = current_time( 'mysql' );
- Read upRead up
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 3 locations. Consider refactoring. Open
'labels' => array(
'name' => _x( 'Template Parts', 'post type general name' ),
'singular_name' => _x( 'Template Part', 'post type singular name' ),
'add_new' => __( 'Add New Template Part' ),
'add_new_item' => __( 'Add New Template Part' ),
- Read upRead up
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 240.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
'labels' => array(
'name' => _x( 'Templates', 'post type general name' ),
'singular_name' => _x( 'Template', 'post type singular name' ),
'add_new' => __( 'Add New Template' ),
'add_new_item' => __( 'Add New Template' ),
- Read upRead up
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 240.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
register_post_type(
'wp_font_family',
array(
'labels' => array(
'name' => __( 'Font Families' ),
- Read upRead up
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 175.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
register_post_type(
'wp_font_face',
array(
'labels' => array(
'name' => __( 'Font Faces' ),
- Read upRead up
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 175.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
register_post_type(
'oembed_cache',
array(
'labels' => array(
'name' => __( 'oEmbed Responses' ),
- Read upRead up
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 106.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
register_post_type(
'user_request',
array(
'labels' => array(
'name' => __( 'User Requests' ),
- Read upRead up
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 106.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76