Showing 247 of 247 total issues
Method form
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, $this->get_defaults() );
foreach ( $this->fields as $attr => $field ) {
$meta = $this->attrs( $field['meta'] );
Function set_default_args_for_setting
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
protected function set_default_args_for_setting( array $args, WP_Site_Identity_Setting $setting ) {
$type = isset( $args['type'] ) ? $args['type'] : $setting->get_type();
switch ( $type ) {
case 'boolean':
- 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 add_brand_data_content
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function add_brand_data_content( $wp_customize, $setting_registry, $panel_slug ) {
$registry = $setting_registry->get_setting( 'brand_data' );
$data = $this->plugin->brand_data();
$section_slug = 'brand_data';
WP_Site_Identity_Settings_Field
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class WP_Site_Identity_Settings_Field {
/**
* Slug of the settings field.
*
Function render_site_identity_data_widget
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function render_site_identity_data_widget( $instance ) {
$owner_data = $this->plugin->owner_data();
$output = '';
- 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 set_default_control_args_for_setting
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function set_default_control_args_for_setting( array $control_args, WP_Site_Identity_Setting $setting ) {
$type = $setting->get_type();
switch ( $type ) {
case 'boolean':
Method wpsi_load
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wpsi_load() {
$classes_dir = plugin_dir_path( __FILE__ ) . 'src/';
// Main.
require_once $classes_dir . 'class-wp-site-identity.php';
Method update
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
foreach ( $this->fields as $attr => $field ) {
switch ( $field['type'] ) {
Method action_init
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function action_init() {
$registry = $this->plugin->services()->get( 'shortcode_registry' );
$factory = $registry->factory();
foreach ( $this->plugin->services()->get( 'setting_registry' )->get_all_settings() as $aggregate_setting ) {
File class-wp-site-identity-settings-field-control-callbacks.php
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WP_Site_Identity_Settings_Field_Control_Callbacks class
*
* @package WPSiteIdentity
Function attrs
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected function attrs( $attrs ) {
$output = '';
foreach ( $attrs as $attr => $value ) {
if ( is_bool( $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
File class-wp-site-identity-widget.php
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WP_Site_Identity_Widget class
*
* @package WPSiteIdentity
Method action_handle_settings_page
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function action_handle_settings_page() {
$setting_registry = $this->plugin->services()->get( 'setting_registry' );
$factory = $this->plugin->services()->get( 'settings_form_registry' )->factory();
Method set_default_args_for_setting
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function set_default_args_for_setting( array $args, WP_Site_Identity_Setting $setting ) {
$type = isset( $args['type'] ) ? $args['type'] : $setting->get_type();
switch ( $type ) {
case 'boolean':
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected function validate_value( $value, $args ) {
if ( empty( $args['type'] ) ) {
return $value;
}
- 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 118.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected function sanitize_value( $value, $args ) {
if ( empty( $args['type'] ) ) {
return $value;
}
- 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 118.
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 render_number_control
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function render_number_control( $value, WP_Site_Identity_Settings_Field $field ) {
$attrs = $this->make_base_attrs( $field, array(
'check_description' => true,
) );
$props = $this->make_base_props( $field );
- 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_url_to_admin_page
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function get_url_to_admin_page( WP_Site_Identity_Admin_Page $admin_page ) {
$slug = $admin_page->get_slug();
$query_args = 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 action_init
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function action_init() {
$registry = $this->plugin->services()->get( 'shortcode_registry' );
$factory = $registry->factory();
foreach ( $this->plugin->services()->get( 'setting_registry' )->get_all_settings() as $aggregate_setting ) {
- 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 excessively long class names like WP_Site_Identity_Settings_Form_Not_Found_Exception. Keep class name length under 40. Open
class WP_Site_Identity_Settings_Form_Not_Found_Exception extends Exception {
}
- Read upRead up
- Exclude checks
LongClassName
Since: 2.9
Detects when classes or interfaces are declared with excessively long names.
Example
class ATooLongClassNameThatHintsAtADesignProblem {
}
interface ATooLongInterfaceNameThatHintsAtADesignProblem {
}