Showing 427 of 427 total issues
All_in_One_SEO_Pack_Sitemap
has 81 functions (exceeds 20 allowed). Consider refactoring. Open
class All_in_One_SEO_Pack_Sitemap extends All_in_One_SEO_Pack_Module {
var $cache_struct = null;
var $cache_home = null;
var $comment_string;
var $start_memory_usage = 0;
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 get_prio_from_posts
has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring. Open
function get_prio_from_posts( $posts, $prio_override = false, $freq_override = false, $linkfunc = 'get_permalink' ) {
$prio = Array();
$args = Array( 'prio_override' => $prio_override, 'freq_override' => $freq_override, 'linkfunc' => $linkfunc );
if ( ( $prio_override ) && ( $freq_override ) )
$stats = 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 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 get_sitemap_index_filenames
has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring. Open
function get_sitemap_index_filenames() {
$files = Array();
$options = $this->options;
$prefix = $options["{$this->prefix}filename"];
$suffix = '.xml';
- 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 All_in_One_SEO_Pack_Opengraph
has 284 lines of code (exceeds 25 allowed). Consider refactoring. Open
function All_in_One_SEO_Pack_Opengraph( ) {
$this->name = __('Social Meta', 'all-in-one-seo-pack'); // Human-readable name of the plugin
$this->prefix = 'aiosp_opengraph_'; // option prefix
$this->file = __FILE__; // the current file
$this->fb_object_types = Array(
Method add_meta
has 265 lines of code (exceeds 25 allowed). Consider refactoring. Open
function add_meta( ) {
global $post, $aiosp, $aioseop_options, $wp_query;
$metabox = $this->get_current_options( Array(), 'settings' );
$key = $this->options['aiosp_opengraph_key'];
$dimg = $this->options['aiosp_opengraph_dimg'];
Function get_page_snippet_info
has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring. Open
function get_page_snippet_info() {
static $info = Array();
if ( !empty( $info ) )
return $info;
global $post, $aioseop_options, $wp_query;
- 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 wp_head
has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring. Open
function wp_head() {
if ( !$this->is_page_included() ) return;
$opts = $this->meta_opts;
global $wp_query, $aioseop_options, $posts;
static $aioseop_dup_counter = 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 universal_analytics
has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring. Open
function universal_analytics() {
global $aioseop_options;
$analytics = '';
if ( !empty( $aioseop_options['aiosp_ga_use_universal_analytics'] ) ) {
$allow_linker = $cookie_domain = $domain = $addl_domains = $domain_list = '';
- 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_keywords
has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring. Open
function get_all_keywords() {
global $posts;
global $aioseop_options;
if ( is_404() ) return null;
// if we are on synthetic pages
- 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 aioseop_ajax_get_menu_links
has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring. Open
function aioseop_ajax_get_menu_links() {
aioseop_ajax_init();
$options = Array();
parse_str( $_POST['options'], $options );
$_POST = $options;
- 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_indexed_sitemaps
has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring. Open
function do_indexed_sitemaps() {
$this->start_memory_usage = memory_get_peak_usage();
$options = $this->options;
$this->do_write_sitemap( 'root' );
- 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_prev_next_links
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Open
function get_prev_next_links( $post = null ) {
$prev = $next = '';
$page = $this->get_page_number();
if ( is_home() || is_archive() || is_paged() ) {
global $wp_query;
- 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_sitemap_scan
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Open
function do_sitemap_scan() {
$msg = '';
if ( !empty( $this->options["{$this->prefix}rewrite"] ) && ( get_option('permalink_structure') == '' ) ) {
$msg = '<p>' . __( 'Warning: dynamic sitemap generation must have permalinks enabled.', 'all-in-one-seo-pack' ) . '</p>';
}
- 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 OAuth.php
has 542 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/* OAuth PHP Library
* http://oauth.googlecode.com/svn/code/php/
*
* License: The MIT License
Function get_problem_files
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
function get_problem_files( $files, &$msg ) {
$problem_files = Array();
$use_wpfs = true;
$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
Function aioseop_mrt_exclude_this_page
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
function aioseop_mrt_exclude_this_page( $url = null ) {
static $excluded = false;
if ( $excluded === false ) {
global $aioseop_options;
$ex_pages = '';
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
foreach( $taxonomy_titles as $k => $v ) {
$key = 'prio_taxonomies_' . $k;
$this->default_options = aioseop_array_insert_after( $this->default_options, 'prio_taxonomies', Array( $key => Array( 'name' => $v . $tax_name, 'help_text' => $prio_help . $v . $tax_name, 'type' => 'select', 'initial_options' => $this->prio, 'default' => 'no', 'condshow' => Array( "{$this->prefix}prio_taxonomies" => 'sel' ) ) ) );
$this->layout['priorities']['options'][] = $key;
$key = 'freq_taxonomies_' . $k;
- 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 240.
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