Showing 96 of 96 total issues
Function map_contact_us_section
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function map_contact_us_section() {
if ( isset( $this->previous_theme_content['zerif_contactus_show'] ) && $this->previous_theme_content['zerif_contactus_show'] ) {
unset( $this->content[0] );
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
Method run_front_page_migration
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run_front_page_migration( WP_REST_Request $request ) {
$params = $request->get_body_params();
if ( ! isset( $params['template'] ) ) {
return new WP_REST_Response(
Method install_plugins
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function install_plugins( WP_REST_Request $request ) {
if ( ! current_user_can( 'install_plugins' ) ) {
return new WP_REST_Response(
array(
'success' => false,
Function process_attachment
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function process_attachment( $post, $meta, $remote_url ) {
// try to use _wp_attached file for upload folder placement to ensure the same location as the export site
// e.g. location is 2003/05/image.jpg but the attachment post_date is 2010/09, see media_handle_upload()
$post['upload_date'] = $post['post_date'];
foreach ( $meta as $meta_item ) {
- 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 process_menu_item_meta
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function process_menu_item_meta( $post_id, $data, $meta ) {
$item_type = get_post_meta( $post_id, '_menu_item_type', true );
$original_object_id = get_post_meta( $post_id, '_menu_item_object_id', true );
$object_id = null;
Method get_sidebar_content
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function get_sidebar_content( $widget_ids, $prefix ) {
if ( empty( $widget_ids ) ) {
return '';
}
$data_in_hestia_format = array();
Method process_term
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function process_term( $data, $meta ) {
/**
* Pre-process term data.
*
* @param array $data Term data. (Return empty to skip.)
Method map_about_us_section
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function map_about_us_section() {
if ( isset( $this->previous_theme_content['zerif_aboutus_show'] ) && $this->previous_theme_content['zerif_aboutus_show'] ) {
unset( $this->content[3] );
return;
Method post_process_posts
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function post_process_posts( $todo ) {
foreach ( $todo as $post_id => $_ ) {
$data = array();
$parent_id = get_post_meta( $post_id, '_wxr_import_parent', true );
Method map_contact_us_section
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function map_contact_us_section() {
if ( isset( $this->previous_theme_content['zerif_contactus_show'] ) && $this->previous_theme_content['zerif_contactus_show'] ) {
unset( $this->content[0] );
return;
Method process_attachment
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function process_attachment( $post, $meta, $remote_url ) {
// try to use _wp_attached file for upload folder placement to ensure the same location as the export site
// e.g. location is 2003/05/image.jpg but the attachment post_date is 2010/09, see media_handle_upload()
$post['upload_date'] = $post['post_date'];
foreach ( $meta as $meta_item ) {
Method insert_page
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function insert_page( $id ) {
$args = array(
'post_type' => 'elementor_library',
'nopaging' => true,
'posts_per_page' => '1',
Function map_about_us_section
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function map_about_us_section() {
if ( isset( $this->previous_theme_content['zerif_aboutus_show'] ) && $this->previous_theme_content['zerif_aboutus_show'] ) {
unset( $this->content[3] );
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
Method process_post_meta
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function process_post_meta( $meta, $post_id, $post ) {
if ( empty( $meta ) ) {
return true;
}
Function get_local_templates
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function get_local_templates() {
$returnable = array();
require_once( ABSPATH . '/wp-admin/includes/file.php' );
- 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 import_remote_xml
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function import_remote_xml( WP_REST_Request $request ) {
if ( ! current_user_can( 'manage_options' ) ) {
return new WP_REST_Response(
array(
'data' => 'ti__ob_permission_err_1',
- 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 2 locations. Consider refactoring. Open
if (state.importOptions.content === false) {
state.importSteps.content.done = 'skip'
importThemeMods({commit, state}, data)
return false
}
- 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 60.
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
Function map_latest_news_section
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function map_latest_news_section() {
if ( ! isset( $this->previous_theme_content['zerif_latest_news_show'] ) || ! $this->previous_theme_content['zerif_latest_news_show'] ) {
unset( $this->content[7] );
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (state.importOptions.customizer === false) {
state.importSteps.theme_mods.done = 'skip'
importWidgets({commit, state}, data)
return false
}
- 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 60.
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
Function parse_term_node
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function parse_term_node( $node, $type = 'term' ) {
$data = array();
$meta = array();
$tag_name = 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"