File aioseop_module_class.php
has 1640 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @package All-in-One-SEO-Pack
*/
/**
Function setting_options
has a Cognitive Complexity of 129 (exceeds 5 allowed). Consider refactoring. Open
function setting_options( $location = null, $defaults = null ) {
if ( $defaults === null )
$defaults = $this->default_options;
$prefix = $this->get_prefix( $location );
$opts = 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 get_all_images_by_type
has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring. Open
function get_all_images_by_type( $options = null, $p = null ) {
$img = Array();
if ( empty( $img ) ) {
$size = apply_filters( 'post_thumbnail_size', 'large' );
- 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
All_in_One_SEO_Pack_Module
has 91 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class All_in_One_SEO_Pack_Module {
public static $instance = null;
protected $plugin_name;
protected $name;
protected $menu_name;
Function add_menu
has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring. Open
function add_menu( $parent_slug ) {
if ( !empty( $this->menu_name ) )
$name = $this->menu_name;
else
$name = $this->name;
- 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 display_options
has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring. Open
function display_options( $location = null, $meta_args = null ) {
static $location_settings = Array();
$defaults = null;
$prefix = $this->get_prefix( $location );
$help_link = '';
- 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 do_multi_input
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
function do_multi_input( $args ) {
extract( $args );
$buf1 = '';
$type = $options['type'];
if ( ( $type == 'radio' ) || ( $type == 'checkbox' ) ) {
- 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 display_settings_page
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
function display_settings_page( $location = null ) {
if ( $location != null ) $location_info = $this->locations[$location];
$name = null;
if ( ( $location ) && ( isset( $location_info['name'] ) ) ) $name = $location_info['name'];
if ( !$name ) $name = $this->name;
- 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 default_bad_bots
has 144 lines of code (exceeds 25 allowed). Consider refactoring. Open
function default_bad_bots() {
$botlist = Array(
"Abonti",
"aggregator",
"AhrefsBot",
Function settings_export
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
function settings_export( $buf ) {
global $aiosp;
$post_types = null;
$has_data = null;
$general_settings = 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"
Further reading
Function domnode_to_array
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
function domnode_to_array( $node ) {
switch ( $node->nodeType ) {
case XML_CDATA_SECTION_NODE:
case XML_TEXT_NODE:
return trim( $node->textContent );
- 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 convert_case
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
function convert_case( $str, $mode = 'upper' ) {
static $charset = null;
if ( $charset == null ) $charset = get_bloginfo( 'charset' );
$str = (string)$str;
if ( $mode == '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 help_text_helper
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
function help_text_helper( &$default_options, $options, $help_link = '' ) {
foreach( $options as $o ) {
$ht = '';
if ( !empty( $this->help_text[$o] ) )
$ht = $this->help_text[$o];
- 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_option_html
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
function get_option_html( $args ) {
static $n = 0;
extract( $args );
if ( $options['type'] == 'custom' )
return apply_filters( "{$prefix}output_option", '', $args );
- 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_admin_links
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
function get_admin_links() {
if ( !empty( $this->menu_name ) )
$name = $this->menu_name;
else
$name = $this->name;
- 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 save_post_data
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
function save_post_data( $post_id ) {
static $update = false;
if ( $update ) return;
if ( $this->locations !== null ) {
foreach( $this->locations as $k => $v ) {
- 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 handle_settings_updates
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
function handle_settings_updates( $location = null ) {
$message = '';
if ( (isset($_POST['action']) && $_POST['action'] == 'aiosp_update_module' &&
( isset( $_POST['Submit_Default'] ) || isset( $_POST['Submit_All_Default'] ) || !empty( $_POST['Submit'] ) ) ) ) {
$nonce = $_POST['nonce-aioseop'];
- 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 enqueue_metabox_scripts
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
function enqueue_metabox_scripts( ) {
$screen = '';
if ( function_exists( 'get_current_screen' ) )
$screen = get_current_screen();
$bail = false;
- 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 load_file
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
function load_file( $filename, $use_include_path = false, $context = null, $offset = -1, $maxlen = -1 ) {
$wpfs = $this->get_filesystem_object();
if ( is_object( $wpfs ) ) {
if ( !$wpfs->exists( $filename ) ) return false;
if ( ( $offset > 0 ) || ( $maxlen >= 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 post_data_export
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
function post_data_export( $prefix = '_aioseop', $query = Array( 'posts_per_page' => -1 ) ) {
$buf = '';
$posts_query = new WP_Query( $query );
while ($posts_query->have_posts() ) {
$posts_query->the_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 cf_field_replace
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
function cf_field_replace( $matches ) {
$result = '';
if ( !empty( $matches ) ) {
if ( !empty( $matches[1] ) ) {
if ( function_exists( 'get_field' ) ) $result = get_field( $matches[1] );
- 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 get_all_images_by_type
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_all_images_by_type( $options = null, $p = null ) {
$img = Array();
if ( empty( $img ) ) {
$size = apply_filters( 'post_thumbnail_size', 'large' );
Method display_settings_page
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function display_settings_page( $location = null ) {
if ( $location != null ) $location_info = $this->locations[$location];
$name = null;
if ( ( $location ) && ( isset( $location_info['name'] ) ) ) $name = $location_info['name'];
if ( !$name ) $name = $this->name;
Function is_good_bot
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function is_good_bot() {
$botlist = Array(
"Yahoo! Slurp" => "crawl.yahoo.net",
"googlebot" => ".googlebot.com",
"msnbot" => "search.msn.com"
- 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_the_image
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function get_the_image( $options = null, $p = null ) {
if ( $p === null ) {
global $post;
} else {
- 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 display_options
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
function display_options( $location = null, $meta_args = null ) {
static $location_settings = Array();
$defaults = null;
$prefix = $this->get_prefix( $location );
$help_link = '';
Function sanitize_options
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
function sanitize_options( $location = null ) {
foreach ( $this->setting_options( $location ) as $k => $v ) {
if ( isset( $this->options[$k] ) ) {
if ( !empty( $v['sanitize'] ) )
$type = $v['sanitize'];
- 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_help_text_links
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
function add_help_text_links() {
if ( !empty( $this->help_text ) ) {
foreach( $this->layout as $k => $v ) {
$this->help_text_helper( $this->default_options, $v['options'], $v['help_link'] );
}
- 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_the_image_by_attachment
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function get_the_image_by_attachment( $p = null ) {
if ( $p === null ) {
global $post;
} else {
- 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 rename_file
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function rename_file( $filename, $newname ) {
$wpfs = $this->get_filesystem_object();
if ( is_object( $wpfs ) ) {
$file_exists = $wpfs->exists( $filename );
$newfile_exists = $wpfs->exists( $newname );
- 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_menu
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function add_menu( $parent_slug ) {
if ( !empty( $this->menu_name ) )
$name = $this->menu_name;
else
$name = $this->name;
Method setting_options
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setting_options( $location = null, $defaults = null ) {
if ( $defaults === null )
$defaults = $this->default_options;
$prefix = $this->get_prefix( $location );
$opts = Array();
Method do_multi_input
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function do_multi_input( $args ) {
extract( $args );
$buf1 = '';
$type = $options['type'];
if ( ( $type == 'radio' ) || ( $type == 'checkbox' ) ) {
Function get_current_options
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function get_current_options( $opts = Array(), $location = null, $defaults = null, $post = null ) {
$prefix = $this->get_prefix( $location );
$get_opts = '';
if ( empty( $location ) )
$type = 'settings';
- 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_filesystem_object
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function get_filesystem_object( ) {
$cred = get_transient( 'aioseop_fs_credentials' );
if ( !empty( $cred ) ) $this->credentials = $cred;
if ( function_exists( 'WP_Filesystem' ) && ( WP_Filesystem( $this->credentials ) ) ) {
- 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 get_option_html
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_option_html( $args ) {
static $n = 0;
extract( $args );
if ( $options['type'] == 'custom' )
return apply_filters( "{$prefix}output_option", '', $args );
Function get_option_row
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function get_option_row( $name, $opts, $args ) {
$label_text = $input_attr = $help_text_2 = $id_attr = '';
if ( $opts['label'] == 'top' )
$align = 'left';
else
- 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 display_tabs
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function display_tabs( $location ) {
if ( ( $location != null ) && isset( $locations[$location]['tabs'] ) )
$tabs = $locations['location']['tabs'];
else
$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
Method domnode_to_array
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function domnode_to_array( $node ) {
switch ( $node->nodeType ) {
case XML_CDATA_SECTION_NODE:
case XML_TEXT_NODE:
return trim( $node->textContent );
Method settings_export
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function settings_export( $buf ) {
global $aiosp;
$post_types = null;
$has_data = null;
$general_settings = null;
Function delete_file
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function delete_file( $filename ) {
$wpfs = $this->get_filesystem_object();
if ( is_object( $wpfs ) ) {
if ( $wpfs->exists( $filename ) ) {
if ( $wpfs->delete( $filename ) === FALSE)
- 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 save_file
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function save_file( $filename, $contents ) {
$failed_str = __( sprintf( "Failed to write file %s!\n", $filename ), 'all-in-one-seo-pack' );
$readonly_str = __( sprintf( "File %s isn't writable!\n", $filename ), 'all-in-one-seo-pack' );
$wpfs = $this->get_filesystem_object();
if ( is_object( $wpfs ) ) {
- 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 handle_settings_updates
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function handle_settings_updates( $location = null ) {
$message = '';
if ( (isset($_POST['action']) && $_POST['action'] == 'aiosp_update_module' &&
( isset( $_POST['Submit_Default'] ) || isset( $_POST['Submit_All_Default'] ) || !empty( $_POST['Submit'] ) ) ) ) {
$nonce = $_POST['nonce-aioseop'];
Method convert_case
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function convert_case( $str, $mode = 'upper' ) {
static $charset = null;
if ( $charset == null ) $charset = get_bloginfo( 'charset' );
$str = (string)$str;
if ( $mode == 'title' ) {
Method post_data_export
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function post_data_export( $prefix = '_aioseop', $query = Array( 'posts_per_page' => -1 ) ) {
$buf = '';
$posts_query = new WP_Query( $query );
while ($posts_query->have_posts() ) {
$posts_query->the_post();
Method get_admin_links
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_admin_links() {
if ( !empty( $this->menu_name ) )
$name = $this->menu_name;
else
$name = $this->name;
Method default_bad_referers
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function default_bad_referers() {
$referlist = Array(
'semalt.com',
'kambasoft.com',
'savetubevideo.com',
Function localize_script_data
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function localize_script_data( $data ) {
if ( !is_array( $data ) ) {
$data = Array( 0 => $data );
}
if ( empty( $this->script_data ) ) $this->script_data = 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 enqueue_metabox_scripts
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function enqueue_metabox_scripts( ) {
$screen = '';
if ( function_exists( 'get_current_screen' ) )
$screen = get_current_screen();
$bail = false;
Method get_the_image_by_attachment
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_the_image_by_attachment( $p = null ) {
if ( $p === null ) {
global $post;
} else {
Function add_admin_bar_submenu
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function add_admin_bar_submenu() {
global $aioseop_admin_menu, $wp_admin_bar;
if ( $aioseop_admin_menu ) {
$links = $this->get_admin_links();
- 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 update_class_option
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function update_class_option( $option_data, $option_name = false ) {
if ( $option_name == false )
$option_name = $this->get_option_name();
if ( $this->store_option || $option_name == $this->parent_option ) {
return update_option( $option_name, $option_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 csv_to_array
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function csv_to_array( $csv ) {
$args = Array();
if ( !function_exists( 'str_getcsv' ) )
$v = $this->str_getcsv( $csv );
else
- 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 filter_pointers
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function filter_pointers() {
if ( !empty( $this->pointers ) ) {
$dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
foreach( $dismissed as $d )
if ( isset( $this->pointers[$d] ) )
- 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 ( is_array($output) )
$output[$t][] = $v;
Avoid deeply nested control flow statements. Open
if ( !empty( $image ) ) {
$img[] = Array( 'type' => 'meta_key', 'id' => $meta_key, 'link' => $image );
}
Avoid deeply nested control flow statements. Open
if ( preg_match( '/' . $hosts . '/i', $hostname ) )
return true;
Function update_options
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function update_options( $opts = Array(), $location = null, $defaults = null ) {
if ($location === null )
$type = 'settings';
else
$type = $this->locations[$location][$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
Avoid deeply nested control flow statements. Open
if ( isset( $options['meta_key'] ) ) {
$meta_key = $options['meta_key'];
}
Function get_class_option
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function get_class_option( ) {
$option_name = $this->get_option_name();
if ( $this->store_option || $option_name == $this->parent_option ) {
return get_option( $option_name );
} else {
- 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 ( !empty( $post_thumbnail_id ) ) {
$image = wp_get_attachment_image_src( $post_thumbnail_id, $size );
if ( is_array( $image ) ) {
$img[] = Array( 'type' => 'featured', 'id' => $post_thumbnail_id, 'link' => $image[0] );
}
Avoid deeply nested control flow statements. Open
if ( is_array( $image ) ) {
$img[] = Array( 'type' => 'attachment', 'id' => $id, 'link' => $image[0] );
}
Function delete_class_option
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function delete_class_option( $delete = false ) {
$option_name = $this->get_option_name();
if ( $this->store_option || $delete ) {
delete_option( $option_name );
} else {
- 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 ( $post->ID == get_option( 'page_for_posts' ) )
$wp_query->is_home = true;
Avoid deeply nested control flow statements. Open
if(!isset($output[$t]))
$output[$t] = array();
Method load_file
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function load_file( $filename, $use_include_path = false, $context = null, $offset = -1, $maxlen = -1 ) {
Function get_the_image_by_meta_key
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function get_the_image_by_meta_key( $args = array() ) {
/* If $meta_key is not an array. */
if ( !is_array( $args['meta_key'] ) )
$args['meta_key'] = array( $args['meta_key'] );
- 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 is_aioseop_active_on_blog
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function is_aioseop_active_on_blog( $bid = false ) {
global $blog_id;
if ( empty( $bid ) || ( $bid == $blog_id ) || !is_multisite() ) return true;
if ( ! function_exists( 'is_plugin_active_for_network' ) )
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
- 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_the_image_by_post_thumbnail
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function get_the_image_by_post_thumbnail( $p = null ) {
if ( $p === null ) {
global $post;
} else {
- 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 $str;
Avoid too many return
statements within this method. Open
return mb_strtoupper( $str, $charset );
Avoid too many return
statements within this method. Open
return $wpfs->get_contents( $filename );
Avoid too many return
statements within this method. Open
return $this->substr( $file, $offset, $maxlen );
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return strtoupper( $str );
Avoid too many return
statements within this method. Open
return mb_strtolower( $str, $charset );
Avoid too many return
statements within this method. Open
return strtolower( $str );
Function get_the_image_by_scan
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function get_the_image_by_scan( $p = null ) {
if ( $p === null ) {
global $post;
} else {
- 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 is_bad_referer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function is_bad_referer() {
$referlist = $this->default_bad_referers();
$referlist = apply_filters( $this->prefix . "badreferlist", $referlist );
if ( !empty( $referlist ) && !empty( $_SERVER ) && !empty( $_SERVER['HTTP_REFERER'] ) ) {
- 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_object_labels
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function get_object_labels( $post_objs ) {
$pt = array_keys( $post_objs );
$post_types = Array();
foreach ( $pt as $p )
if ( !empty( $post_objs[$p]->label ) )
- 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_all_images
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function get_all_images( $options = null, $p = null ) {
$img = $this->get_all_images_by_type( $options, $p );
$legacy = Array();
foreach( $img as $k => $v ) {
if ( $v['type'] == 'featured' ) {
- 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
function reset_options( $location = null, $delete = false ) {
if ( $delete === true ) {
$this->delete_class_option( $delete );
$this->options = Array();
}
- 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 98.
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