File taxonomy.php
has 1144 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Taxonomy API
*
* @package WordPress
Function get_terms
has a Cognitive Complexity of 119 (exceeds 5 allowed). Consider refactoring. Open
function &get_terms($taxonomies, $args = '') {
global $wpdb;
$empty_array = array();
$single_taxonomy = 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_get_object_terms
has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring. Open
function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
global $wpdb;
if ( !is_array($taxonomies) )
$taxonomies = array($taxonomies);
- 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_terms
has 194 lines of code (exceeds 25 allowed). Consider refactoring. Open
function &get_terms($taxonomies, $args = '') {
global $wpdb;
$empty_array = array();
$single_taxonomy = false;
Function _get_term_children
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
function &_get_term_children($term_id, $terms, $taxonomy) {
$empty_array = array();
if ( empty($terms) )
return $empty_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_set_object_terms
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false) {
global $wpdb;
$object_id = (int) $object_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_object_term_cache
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
function update_object_term_cache($object_ids, $object_type) {
if ( empty($object_ids) )
return;
if ( !is_array($object_ids) )
- 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_term_field
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) {
if ( 'parent' == $field || 'term_id' == $field || 'count' == $field || 'term_group' == $field ) {
$value = (int) $value;
if ( $value < 0 )
$value = 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 is_object_in_term
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
function is_object_in_term( $object_id, $taxonomy, $terms = null ) {
if ( !$object_id = (int) $object_id )
return new WP_Error( 'invalid_object', __( 'Invalid object ID' ) );
$object_terms = get_object_term_cache( $object_id, $taxonomy );
- 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_object_terms
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
global $wpdb;
if ( !is_array($taxonomies) )
$taxonomies = array($taxonomies);
Function wp_insert_term
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function wp_insert_term( $term, $taxonomy, $args = array() ) {
global $wpdb;
if ( ! is_taxonomy($taxonomy) )
return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
- 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_term
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_update_term( $term_id, $taxonomy, $args = array() ) {
global $wpdb;
if ( ! is_taxonomy($taxonomy) )
return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
Method wp_insert_term
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_insert_term( $term, $taxonomy, $args = array() ) {
global $wpdb;
if ( ! is_taxonomy($taxonomy) )
return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
Function _pad_term_counts
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function _pad_term_counts(&$terms, $taxonomy) {
global $wpdb;
// This function only works for hierarchical taxonomies like post categories.
if ( !is_taxonomy_hierarchical( $taxonomy ) )
- 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_term
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function wp_delete_term( $term, $taxonomy, $args = array() ) {
global $wpdb;
$term = (int) $term;
- 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_the_taxonomies
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function get_the_taxonomies($post = 0) {
if ( is_int($post) )
$post =& get_post($post);
elseif ( !is_object($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
Function get_term
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
global $wpdb;
$null = null;
if ( empty($term) ) {
- 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_unique_term_slug
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function wp_unique_term_slug($slug, $term) {
global $wpdb;
// If the taxonomy supports hierarchy and the term has a parent, make the slug unique
// by incorporating parent slugs.
- 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_set_object_terms
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false) {
global $wpdb;
$object_id = (int) $object_id;
Function wp_update_term
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function wp_update_term( $term_id, $taxonomy, $args = array() ) {
global $wpdb;
if ( ! is_taxonomy($taxonomy) )
return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
- 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_term
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_delete_term( $term, $taxonomy, $args = array() ) {
global $wpdb;
$term = (int) $term;
Function sanitize_term
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function sanitize_term($term, $taxonomy, $context = 'display') {
if ( 'raw' == $context )
return $term;
- 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_term
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function is_term($term, $taxonomy = '', $parent = 0) {
global $wpdb;
$select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
$tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
- 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_term_by
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw') {
global $wpdb;
if ( ! is_taxonomy($taxonomy) )
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_term
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
global $wpdb;
$null = null;
if ( empty($term) ) {
Method is_term
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function is_term($term, $taxonomy = '', $parent = 0) {
global $wpdb;
$select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
$tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
Function get_term_link
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function get_term_link( $term, $taxonomy ) {
global $wp_rewrite;
if ( !is_object($term) ) {
if ( is_int($term) ) {
- 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 update_object_term_cache
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function update_object_term_cache($object_ids, $object_type) {
if ( empty($object_ids) )
return;
if ( !is_array($object_ids) )
Function clean_term_cache
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function clean_term_cache($ids, $taxonomy = '') {
global $wpdb;
static $cleaned = array();
if ( !is_array($ids) )
- 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_taxonomy
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
global $wp_taxonomies, $wp_rewrite, $wp;
if (!is_array($wp_taxonomies))
$wp_taxonomies = 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 sanitize_term_field
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) {
if ( 'parent' == $field || 'term_id' == $field || 'count' == $field || 'term_group' == $field ) {
$value = (int) $value;
if ( $value < 0 )
$value = 0;
Method _get_term_children
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function &_get_term_children($term_id, $terms, $taxonomy) {
$empty_array = array();
if ( empty($terms) )
return $empty_array;
Method get_term_by
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw') {
global $wpdb;
if ( ! is_taxonomy($taxonomy) )
return false;
Method _pad_term_counts
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _pad_term_counts(&$terms, $taxonomy) {
global $wpdb;
// This function only works for hierarchical taxonomies like post categories.
if ( !is_taxonomy_hierarchical( $taxonomy ) )
Method clean_term_cache
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function clean_term_cache($ids, $taxonomy = '') {
global $wpdb;
static $cleaned = array();
if ( !is_array($ids) )
Method get_term_link
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_term_link( $term, $taxonomy ) {
global $wp_rewrite;
if ( !is_object($term) ) {
if ( is_int($term) ) {
Method wp_unique_term_slug
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_unique_term_slug($slug, $term) {
global $wpdb;
// If the taxonomy supports hierarchy and the term has a parent, make the slug unique
// by incorporating parent slugs.
Method get_the_taxonomies
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_the_taxonomies($post = 0) {
if ( is_int($post) )
$post =& get_post($post);
elseif ( !is_object($post) )
$post =& $GLOBALS['post'];
Function wp_update_term_count
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function wp_update_term_count( $terms, $taxonomy, $do_deferred=false ) {
static $_deferred = array();
if ( $do_deferred ) {
foreach ( (array) array_keys($_deferred) as $tax ) {
- 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_term_by
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw') {
Method sanitize_term_field
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) {
Avoid too many return
statements within this method. Open
return $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s", $else_where_fields), ARRAY_A);
Avoid too many return
statements within this method. Open
return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
Avoid too many return
statements within this method. Open
return $__term;
Avoid too many return
statements within this method. Open
return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
Avoid too many return
statements within this method. Open
return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
Avoid too many return
statements within this method. Open
return get_object_vars($term);
Avoid too many return
statements within this method. Open
return $terms;
Avoid too many return
statements within this method. Open
if ( $ints && in_array( $object_term->term_id, $ints ) ) return true; // If int, check against term_id
Avoid too many return
statements within this method. Open
return array_values(get_object_vars($term));
Avoid too many return
statements within this method. Open
if ( in_array( $object_term->term_id, $strs ) ) return true;
Avoid too many return
statements within this method. Open
if ( in_array( $object_term->slug, $strs ) ) return true;
Avoid too many return
statements within this method. Open
if ( in_array( $object_term->name, $strs ) ) return true;
Avoid too many return
statements within this method. Open
return $result;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $_term;
Avoid too many return
statements within this method. Open
return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where", $else_where_fields) );
Avoid too many return
statements within this method. Open
return $__term;
Avoid too many return
statements within this method. Open
return $term;
Avoid too many return
statements within this method. Open
return $terms;
Avoid too many return
statements within this method. Open
return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
Avoid too many return
statements within this method. Open
return $result;
Function get_objects_in_term
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function get_objects_in_term( $terms, $taxonomies, $args = array() ) {
global $wpdb;
if ( !is_array( $terms) )
$terms = array($terms);
- 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_object_taxonomies
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function get_object_taxonomies($object) {
global $wp_taxonomies;
if ( is_object($object) ) {
if ( $object->post_type == 'attachment' )
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ( $alias_of ) {
$alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) );
if ( $alias->term_group ) {
// The alias we want is already in a group, so let's use that one.
$term_group = $alias->term_group;
- 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 136.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ( $alias_of ) {
$alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) );
if ( $alias->term_group ) {
// The alias we want is already in a group, so let's use that one.
$term_group = $alias->term_group;
- 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 136.
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