Showing 247 of 247 total issues
Function openImageMediaModal
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function openImageMediaModal() {
var field = document.getElementById( this.dataset.target );
var preview = document.getElementById( this.dataset.target + '-preview' );
var selectButton = this;
var deleteButton = document.getElementById( this.dataset.target + '-delete-button' );
Function openImageMediaModal
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function openImageMediaModal() {
var field = document.getElementById( this.dataset.target );
var preview = document.getElementById( this.dataset.target + '-preview' );
var selectButton = this;
var deleteButton = document.getElementById( this.dataset.target + '-delete-button' );
Method render_site_identity_data_widget
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function render_site_identity_data_widget( $instance ) {
$owner_data = $this->plugin->owner_data();
$output = '';
Function set_default_default_for_type
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function set_default_default_for_type( array $args ) {
$type = isset( $args['type'] ) ? $args['type'] : '';
$min = isset( $args['min'] ) ? $args['min'] : false;
switch ( $type ) {
- 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_owner_data_content
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function add_owner_data_content( $wp_customize, $setting_registry, $panel_slug ) {
$registry = $setting_registry->get_setting( 'owner_data' );
$data = $this->plugin->owner_data();
$section_slug = 'owner_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
Method __construct
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( WP_Site_Identity_Setting $setting, array $args = array(), WP_Site_Identity_Settings_Field_Registry $registry = null ) {
$this->slug = $setting->get_name();
$this->setting = $setting;
if ( ! empty( $args['title'] ) ) {
Method render_number_control
has 32 lines of code (exceeds 25 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 );
Function __construct
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function __construct( WP_Site_Identity_Setting $setting, array $args = array(), WP_Site_Identity_Settings_Field_Registry $registry = null ) {
$this->slug = $setting->get_name();
$this->setting = $setting;
if ( ! empty( $args['title'] ) ) {
- 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 11 (exceeds 5 allowed). Consider refactoring. Open
public function validate( $data ) {
if ( $data instanceof stdClass ) {
$data = (array) $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
Function add_brand_data_content
has a Cognitive Complexity of 11 (exceeds 5 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';
- 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 action_render_settings_page
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function action_render_settings_page( $admin_page ) {
if ( ! is_a( $admin_page, 'WP_Site_Identity_Admin_Submenu_Page' ) || 'options-general.php' !== $admin_page->get_parent_slug() ) {
require ABSPATH . 'wp-admin/options-head.php';
}
Method validate
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validate( $data ) {
if ( $data instanceof stdClass ) {
$data = (array) $data;
}
Method get
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get( $name ) {
switch ( $name ) {
case 'primary_shade_color':
case 'secondary_shade_color':
case 'tertiary_shade_color':
Avoid using undefined variables such as '$meta' which will lead to PHP notices. Open
if ( ! empty( $meta['multiple'] ) ) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Method set_default_default_for_type
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function set_default_default_for_type( array $args ) {
$type = isset( $args['type'] ) ? $args['type'] : '';
$min = isset( $args['min'] ) ? $args['min'] : false;
switch ( $type ) {
Method build_rest_schema_for_wp
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function build_rest_schema_for_wp( WP_Site_Identity_Setting $setting ) {
$default_schema = array(
'type' => $setting->get_type(),
'description' => $setting->get_description(),
'default' => $setting->get_default(),
Function initializeImageField
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initializeImageField( field ) {
var selectButton = document.createElement( 'button' );
var deleteButton = document.createElement( 'button' );
var value = parseInt( field.value, 10 );
var attachment = document.getElementById( field.id + '-attachment-data' );
Method get_as_html
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_as_html( $name ) {
switch ( $name ) {
case 'phone_link':
case 'email_link':
case 'website_link':
Method wpsi_requirements_notice
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wpsi_requirements_notice() {
$plugin_file = plugin_basename( __FILE__ );
// WordPress before 4.9 didn't have a dedicated capability for this.
if ( version_compare( $GLOBALS['wp_version'], '4.9', '<' ) ) {
Function initializeImageField
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initializeImageField( field ) {
var selectButton = document.createElement( 'button' );
var deleteButton = document.createElement( 'button' );
var value = parseInt( field.value, 10 );
var attachment = document.getElementById( field.id + '-attachment-data' );