Showing 427 of 427 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
"description_format" => __( "This controls the format of Meta Descriptions.The following macros are supported:", 'all-in-one-seo-pack' ) .
'<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' .
__( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' .
__( '%description% - The original description as determined by the plugin, e.g. the excerpt if one is set or an auto-generated one if that option is set', 'all-in-one-seo-pack' ) . '</li><li>' .
__( '%post_title% - The original title of the post', 'all-in-one-seo-pack' ) . '</li><li>' .
- 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 109.
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 oauth_connect
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function oauth_connect( $count = 0 ) {
global $aiosp_activation;
if ( !class_exists( 'OAuthConsumer' ) ) require_once( 'OAuth.php' );
$url = '';
$callback_url = 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 get_main_keywords
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function get_main_keywords() {
global $aioseop_options;
global $aioseop_keywords;
global $post;
$opts = $this->meta_opts;
- 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 build_http_query
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function build_http_query($params) {
if (!$params) return '';
// Urlencode both keys and values
$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
- 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 to_header
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function to_header($realm=null) {
$first = true;
if($realm) {
$out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
$first = 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 aioseop_ajax_init
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function aioseop_ajax_init() {
if ( !empty( $_POST ) && !empty( $_POST['settings'] ) && (!empty( $_POST['nonce-aioseop'])||(!empty( $_POST['nonce-aioseop-edit']))) && !empty( $_POST['options'] ) ) {
$_POST = stripslashes_deep( $_POST );
$settings = esc_attr( $_POST['settings'] );
if ( ! defined( 'AIOSEOP_AJAX_MSG_TMPL' ) )
- 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_build_sitemap
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function do_build_sitemap( $sitemap_type, $page = 0, $filename = '', $comment = '' ) {
if ( empty( $filename ) ) {
if ( $sitemap_type == 'root' ) {
$filename = $this->options["{$this->prefix}filename"];
} 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 load_module
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function load_module( $mod ) {
static $feature_options = null;
static $feature_prefix = null;
if ( !is_array( $this->modules ) ) return false;
$v = $this->modules[ $mod ];
Method filter_settings
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function filter_settings( $settings, $location, $current ) {
if ( $location == 'opengraph' || $location == 'settings' ) {
$prefix = $this->get_prefix( $location ) . $location . '_';
if ( $location == 'opengraph' ) return $settings;
if ( $location == 'settings' ) {
Method add_attributes
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function add_attributes( $output ) { // avoid having duplicate meta tags
$type = $this->type;
if ( empty( $type ) ) $type = 'website';
$schema_types = Array(
Consider simplifying this complex logical expression. Open
if ( ( ( is_front_page() && $aioseop_options['aiosp_home_keywords'] && !$this->is_static_posts_page() ) || $this->is_static_front_page() ) ) {
if ( !empty( $aioseop_options['aiosp_use_static_home_info'] ) ) {
$keywords = $this->get_all_keywords();
} else {
$keywords = trim( $this->internationalize( $aioseop_options['aiosp_home_keywords'] ) );
Method All_in_One_SEO_Pack_Importer_Exporter
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function All_in_One_SEO_Pack_Importer_Exporter( ) {
$this->name = __( 'Importer & Exporter', 'all-in-one-seo-pack' ); // Human-readable name of the module
$this->prefix = 'aiosp_importer_exporter_'; // option prefix
$this->file = __FILE__;
parent::__construct();
Method is_page_included
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function is_page_included() {
global $aioseop_options;
if ( is_feed() ) return false;
if ( aioseop_mrt_exclude_this_page() ) return false;
$post = $this->get_queried_object();
Method aioseop_mrt_exclude_this_page
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function aioseop_mrt_exclude_this_page( $url = null ) {
static $excluded = false;
if ( $excluded === false ) {
global $aioseop_options;
$ex_pages = '';
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;
Method generate_htaccess_blocklist
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function generate_htaccess_blocklist() {
if ( !$this->option_isset( 'htaccess_rules' ) ) return;
if ( function_exists( 'apache_get_modules' ) ) {
$modules = apache_get_modules();
foreach( Array( 'mod_authz_host', 'mod_setenvif' ) as $m ) {
Function aioseop_eval_condshow_logic
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function aioseop_eval_condshow_logic( statement ) {
var lhs, rhs;
if ( ( typeof statement ) == 'object' ) {
lhs = statement['lhs'];
rhs = statement['rhs'];
- 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_post_description
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function get_post_description( $post ) {
global $aioseop_options;
$description = '';
if ( !$this->show_page_description() ) {
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
Function get_current_options
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function get_current_options( $opts = Array(), $location = null, $defaults = null, $post = null ) {
if ( ( $location === 'aiosp' ) && ( $this->locations[$location]['type'] == 'metabox' ) ) {
if ( $post == null ) {
global $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 add_page_hooks
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function add_page_hooks() {
$memory_usage = memory_get_peak_usage() / 1024 / 1024;
if ( $memory_usage > 32 ) {
unset( $this->default_options['memory_limit']['initial_options']['32M'] );
if ( $memory_usage > 64 ) unset( $this->default_options['memory_limit']['initial_options']['64M'] );
- 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"