File class-connector-settings.php
has 541 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Connector for Settings
*
* @package WP_Stream
Function action_links
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
public function action_links( $links, $record ) {
$context_labels = $this->get_context_labels();
$plugin = wp_stream_get_instance();
$rules = 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
Method action_links
has 111 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function action_links( $links, $record ) {
$context_labels = $this->get_context_labels();
$plugin = wp_stream_get_instance();
$rules = array(
Method register
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function register() {
parent::register();
$this->labels = array(
// General.
Connector_Settings
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class Connector_Settings extends Connector {
/**
* Prefix for the highlight URL hash
*
* @const string
Method callback_updated_option
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function callback_updated_option( $option, $old_value, $value ) {
global $whitelist_options, $new_whitelist_options;
if ( $this->is_option_ignored( $option ) ) {
return;
Method highlight_field
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function highlight_field() {
?>
<script>
(function ($) {
$(function () {
Function callback_updated_option
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function callback_updated_option( $option, $old_value, $value ) {
global $whitelist_options, $new_whitelist_options;
if ( $this->is_option_ignored( $option ) ) {
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 deeply nested control flow statements. Open
if ( '' === $field_name ) {
$field_name = $record->get_meta( 'option', true );
}
Avoid deeply nested control flow statements. Open
if ( '' !== $field_name ) {
$url = sprintf( '%s#%s%s', rtrim( preg_replace( '/#.*/', '', $url ), '/' ), self::HIGHLIGHT_FIELD_URL_HASH_PREFIX, $field_name );
}
Avoid too many return
statements within this method. Open
return call_user_func( $rule['applicable'], $submenu, $record );
Avoid too many return
statements within this method. Open
return $links;
Avoid too many return
statements within this method. Open
return sprintf( 'options-%s.php', $record->context );
Avoid too many return
statements within this method. Open
return ! empty( $submenu['options-general.php'] );
Avoid too many return
statements within this method. Open
return admin_url( $rule['submenu_slug']( $record ) );
Avoid too many return
statements within this method. Open
return network_admin_url( $rule['menu_slug'] );
Avoid too many return
statements within this method. Open
return ! empty( $submenu['settings.php'] );
Avoid too many return
statements within this method. Open
return in_array( $record->context, array( 'custom_header', 'custom_background' ), true );
Avoid too many return
statements within this method. Open
return 'settings.php';
Avoid too many return
statements within this method. Open
return false;
Function get_context_by_key
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function get_context_by_key( $option_name, $key ) {
$contexts = array(
'theme_mods' => array(
'custom_background' => array(
'background_image',
- 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"