Showing 1,804 of 1,804 total issues
Function save
has a Cognitive Complexity of 102 (exceeds 25 allowed). Consider refactoring. Open
public function save() {
if ( ! function_exists( 'wc_get_var' ) ) {
return;
}
$nonce_value = wc_get_var( $_REQUEST['lsx-bd-add-listing-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine.
- 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
<?php
/**
* The template for the business directory post type archive.
*
* @package LSX_Business_Directory
- 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 216.
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
<?php
/**
* The template for the business directory post type archive.
*
* @package LSX_Business_Directory
- 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 216.
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 get_listing_form_field_values
has a Cognitive Complexity of 47 (exceeds 25 allowed). Consider refactoring. Open
function get_listing_form_field_values( $sections = array(), $listing_id = false ) {
$values = array();
$defaults = \lsx\business_directory\includes\get_listing_form_field_defaults();
$nonce_value = wc_get_var( $_REQUEST['lsx-bd-add-listing-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine.
if ( ! wp_verify_nonce( $nonce_value, 'lsx_bd_add_listing' ) || empty( $_POST['action'] ) || 'save_listing_details' !== $_POST['action'] ) {
- 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 body_class
has a Cognitive Complexity of 28 (exceeds 25 allowed). Consider refactoring. Open
public function body_class( $classes = array() ) {
if ( is_singular( 'business-directory' ) || is_post_type_archive( 'business-directory' ) || is_tax( array( 'industry', 'location' ) ) || is_search() || ( lsx_bd_is_preview() ) ) {
$classes[] = 'lsx-business-directory-page';
if ( is_singular( 'business-directory' ) || ( lsx_bd_is_preview() ) ) {
- 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 lsx_bd_get_term_thumbnail
has a Cognitive Complexity of 27 (exceeds 25 allowed). Consider refactoring. Open
function lsx_bd_get_term_thumbnail( $term_id = '', $size = 'lsx-thumbnail-wide', $echo = false, $src = false, $hover = false ) {
$image = '';
if ( '' !== $term_id ) {
$meta_key = 'lsx_bd_thumbnail_id';
if ( false !== $hover ) {
- 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 lsx_bd_form_field
has a Cognitive Complexity of 27 (exceeds 25 allowed). Consider refactoring. Open
function lsx_bd_form_field( $key, $args, $value = null ) {
$defaults = array(
'type' => 'text',
'label' => '',
'description' => '',
- 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
Rule doesn't have all its properties in alphabetical order. Open
.wp-admin.business-directory_page_lsx-business-directory-settings .wp-filter .filter-links .current { border-bottom: none; font-weight: 600; color: #23282d; }
- Exclude checks
The property -ms-box-orient is compatible with -webkit-box-orient and should be included as well. Open
.wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: horizontal; -webkit-box-direction: normal; -ms-flex-direction: row; flex-direction: row; }
- Exclude checks
Adjoining classes: .wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row.cmb-type-colorpicker .cmb-td Open
@media only screen and (min-width: 1000px) { .wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row.cmb-type-colorpicker .cmb-td { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: horizontal; -webkit-box-direction: normal; -ms-flex-direction: row; flex-direction: row; } }
- Exclude checks
Adjoining classes: .wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row h3.cmb2-metabox-title Open
.wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row h3.cmb2-metabox-title { color: #23282d; font-size: 17px; margin: 1em 0; font-weight: 600; -webkit-font-smoothing: subpixel-antialiased; line-height: 1.4em; margin-bottom: 0px; }
- Exclude checks
Adjoining classes: .wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row div.cmb-th Open
.wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row div.cmb-th { text-align: right; padding: 20px 0 20px 10px; width: 200px; font-size: 14px; line-height: 1.3; font-weight: 600; color: #23282d; text-shadow: none; vertical-align: baseline; min-width: 210px !important; }
- Exclude checks
Rule doesn't have all its properties in alphabetical order. Open
.wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row div.cmb-th { text-align: right; padding: 20px 0 20px 10px; width: 200px; font-size: 14px; line-height: 1.3; font-weight: 600; color: #23282d; text-shadow: none; vertical-align: baseline; min-width: 210px !important; }
- Exclude checks
Adjoining classes: .wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row div.cmb-th Open
.wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row div.cmb-th { text-align: right; padding: 20px 0 20px 10px; width: 200px; font-size: 14px; line-height: 1.3; font-weight: 600; color: #23282d; text-shadow: none; vertical-align: baseline; min-width: 210px !important; }
- Exclude checks
Heading (h3) should not be qualified. Open
.wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row h3.cmb2-metabox-title { color: #23282d; font-size: 17px; margin: 1em 0; font-weight: 600; -webkit-font-smoothing: subpixel-antialiased; line-height: 1.4em; margin-bottom: 0px; }
- Exclude checks
Values of 0 shouldn't have units specified. Open
.wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row div.cmb-td:nth-of-type(1) { padding-top: 0px !important; }
- Exclude checks
Adjoining classes: .wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row h3.cmb2-metabox-title Open
.wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row h3.cmb2-metabox-title { color: #23282d; font-size: 17px; margin: 1em 0; font-weight: 600; -webkit-font-smoothing: subpixel-antialiased; line-height: 1.4em; margin-bottom: 0px; }
- Exclude checks
Values of 0 shouldn't have units specified. Open
.wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row div.cmb-td .cmb2-metabox-title { margin-top: 0px; }
- Exclude checks
Adjoining classes: .wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row div.cmb-td .cmb2-metabox-title Open
.wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row div.cmb-td .cmb2-metabox-title { margin-top: 0px; }
- Exclude checks
Use of !important Open
.wp-admin.business-directory_page_lsx-business-directory-settings .cmb2-wrap.form-table .tab.tab-nav .cmb-row div.cmb-td { text-align: right !important; padding: 20px 0 20px 10px !important; margin-left: 15px; }
- Exclude checks