Showing 43 of 43 total issues
Identical blocks of code found in 2 locations. Consider refactoring. Open
$cache_modes = array(
array( 'value' => 'none', 'label' => esc_html__( 'No Caching', 'maera' ) ),
array( 'value' => 'object', 'label' => esc_html__( 'WP Object Caching', 'maera' ) ),
array( 'value' => 'transient', 'label' => esc_html__( 'Transients', 'maera' ) ),
array( 'value' => 'default', 'label' => esc_html__( 'Default', 'maera' ) ),
- 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 104.
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
Method colorposts_build_css
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function colorposts_build_css( $styles ) {
$src = $this->custom_header_url();
if ( $src && get_template_directory_uri() . '/core-shell/assets/images/grid-back.png' != $src ) {
Method grab_points
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function grab_points( $type = 'index' ) {
$img = $this->image_obj;
if ( ! $img )
return false;
Method add_settings
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function add_settings( $wp_customize ) {
$wp_customize->add_setting( 'maera_admin_options[shell]', array(
'default' => 'core',
'type' => 'option',
Method get_context
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_context() {
global $content_width;
if ( class_exists( 'Easy_Digital_Downloads' ) ) {
Method purchase_variable_pricing
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function purchase_variable_pricing( $download_id ) {
$variable_pricing = edd_has_variable_prices( $download_id );
if ( ! $variable_pricing ) {
Function form
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function form( $instance ) {
$defaults = array(
'title' => 'Latest Articles',
'post_type' => '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 colorposts_build_css
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function colorposts_build_css( $styles ) {
$src = $this->custom_header_url();
if ( $src && get_template_directory_uri() . '/core-shell/assets/images/grid-back.png' != $src ) {
- 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 context
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function context() {
global $wp_query;
$context = Maera()->cache->get_context();
Function colors
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function colors() {
$thumb_id = get_post_thumbnail_id( $this->post_id );
$thumb_url = wp_get_attachment_image_src( $thumb_id );
$thumb_url = $thumb_url[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 cache_mode
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function cache_mode() {
$options = get_option( 'maera_admin_options', array() );
$cache_mode = isset( $options['cache_mode'] ) ? $options['cache_mode'] : 'default';
- 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 widget_areas
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function widget_areas() {
$areas = $this->extra_widget_areas_array();
$class = apply_filters( 'maera/widgets/class', '' );
- 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 admin_page
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function admin_page() {
global $pagenow;
$tabs = $this->tabs();
- 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 context
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function context() {
global $wp_query;
$context = Maera()->cache->get_context();
- 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
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function validate( $settings ) {
// Import the imported options
if ( isset( $settings['import_data'] ) && ! empty( $settings['import_data'] ) ) {
- 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
Consider simplifying this complex logical expression. Open
if (isset($params[2])
&& !is_int($params[2])
&& !is_float($params[2])
&& !is_string($params[2])
&& !(is_object($params[2]) && method_exists($params[2], '__toString'))
Consider simplifying this complex logical expression. Open
if (!is_int($params[1])
&& !is_float($params[1])
&& !is_string($params[1])
&& $params[1] !== null
&& !(is_object($params[1]) && method_exists($params[1], '__toString'))
Function extra_widget_areas_wrapper
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function extra_widget_areas_wrapper( $area = null, $class = '' ) {
// Do not proceed if we have not specified an area
if ( is_null( $area ) ) {
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
Avoid too many return
statements within this method. Open
return $resultArray;
Function custom_css_cached
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function custom_css_cached() {
if ( Maera()->dev->dev_mode() ) {
// Get our styles using the maera/styles filter
$data = apply_filters( 'maera/styles', null );
- 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"