Showing 187 of 187 total issues
Avoid deeply nested control flow statements. Open
if ( wpptd_supports_termmeta() ) {
$taxonomy->enqueue_assets();
}
Method get_related_objects
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function get_related_objects( $mode, $id, $objects_mode, $meta_key = '', $object_type = '', $single = false ) {
Avoid deeply nested control flow statements. Open
if ( isset( $labels['insert_into_item'] ) && $labels['insert_into_item'] ) {
$strings['insertIntoPost'] = $labels['insert_into_item'];
}
Avoid deeply nested control flow statements. Open
if ( isset( $labels['uploaded_to_this_item'] ) && $labels['uploaded_to_this_item'] ) {
$strings['uploadedToThisPost'] = $labels['uploaded_to_this_item'];
}
Avoid deeply nested control flow statements. Open
if ( 'category' === $taxonomy_slug ) {
$column_key = 'categories';
} elseif ( 'post_tag' === $taxonomy_slug || 'tag' === $taxonomy_slug ) {
$column_key = 'tags';
}
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ( doing_action( 'wpptd' ) || ! did_action( 'wpptd' ) ) {
if ( $single ) {
foreach ( $_meta_values as $key => $_mv ) {
if ( count( $_mv ) > 0 ) {
$meta_values[ $key ] = $_mv[0];
- 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 95.
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 ( doing_action( 'wpptd' ) || ! did_action( 'wpptd' ) ) {
if ( $single ) {
foreach ( $_meta_values as $key => $_mv ) {
if ( count( $_mv ) > 0 ) {
$meta_values[ $key ] = $_mv[0];
- 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 95.
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
Consider simplifying this complex logical expression. Open
if ( ! class_exists( 'WPPTD\PostTypeTableHandler' ) ) {
/**
* This class handles the post list table for a post type registered with WPPTD.
*
* @internal
Consider simplifying this complex logical expression. Open
if ( ( 0 <= version_compare( get_bloginfo( 'version' ), '4.5' ) && 'term' === $screen->base ) || ( 0 > version_compare( get_bloginfo( 'version' ), '4.5' ) && 'edit-tags' === $screen->base && isset( $_GET['tag_ID'] ) && is_numeric( $_GET['tag_ID'] ) ) ) {
if ( wpptd_supports_termmeta() ) {
$taxonomy->enqueue_assets();
}
Function add_menus
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function add_menus( $menus ) {
foreach ( $menus as $menu_slug => $menu_args ) {
$menu = $this->add( new Menu( $menu_slug, $menu_args ) );
if ( is_wp_error( $menu ) ) {
self::doing_it_wrong( __METHOD__, $menu->get_error_message(), '0.5.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 generate_labels
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function generate_labels( $plural_name, $singular_name, $type = 'labels', $gender = 'neuter' ) {
$gender_map = array( 'm' => 'masculine', 'f' => 'feminine', 'n' => 'neuter' );
if ( isset( $gender_map[ $gender ] ) ) {
$gender = $gender_map[ $gender ];
}
- 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 filter_by_meta
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function filter_by_meta( $value, $column_slug, $meta_key ) {
$meta_value = stripslashes( $value);
if ( $meta_value ) {
$this->active_filters[ $column_slug ] = $meta_value;
if ( 'bool:true' === $meta_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
Function add_term_or_term_list_help
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function add_term_or_term_list_help() {
global $taxnow;
$taxonomy = ComponentManager::get( '*.*.' . $taxnow, 'WPDLib\Components\Menu.WPPTD\Components\PostType.WPPTD\Components\Taxonomy', true );
if ( $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 generate_labels
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function generate_labels( $plural_name, $singular_name, $type = 'labels', $gender = 'neuter' ) {
$gender_map = array( 'm' => 'masculine', 'f' => 'feminine', 'n' => 'neuter' );
if ( isset( $gender_map[ $gender ] ) ) {
$gender = $gender_map[ $gender ];
}
- 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 add_metaboxes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function add_metaboxes( $metaboxes, $post_type ) {
foreach ( $metaboxes as $metabox_slug => $metabox_args ) {
$metabox = $post_type->add( new Metabox( $metabox_slug, $metabox_args ) );
if ( is_wp_error( $metabox ) ) {
self::doing_it_wrong( __METHOD__, $metabox->get_error_message(), '0.5.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 validate_meta_value
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function validate_meta_value( $meta_value = null, $skip_required = false ) {
if ( $this->args['required'] && ! $skip_required ) {
if ( $meta_value === null || $this->_field->is_empty( $meta_value ) ) {
return new WPError( 'invalid_empty_value', __( 'No value was provided for the required field.', 'post-types-definitely' ) );
}
- 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 too many return
statements within this method. Open
return $_meta_value;
Avoid too many return
statements within this method. Open
return array();
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return array();