File option.php
has 553 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Option API
*
* @package WordPress
Function get_option
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
function get_option( $option, $default = false ) {
global $wpdb;
$option = trim( $option );
if ( empty( $option ) )
- 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 set_transient
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function set_transient( $transient, $value, $expiration = 0 ) {
/**
* Filter a specific transient before its value is set.
*
- 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
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_option( $option, $default = false ) {
global $wpdb;
$option = trim( $option );
if ( empty( $option ) )
Function get_transient
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function get_transient( $transient ) {
/**
* Filter the value of an existing transient.
*
- 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_option
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
global $wpdb;
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '2.3' );
- 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_site_option
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function add_site_option( $option, $value ) {
global $wpdb;
wp_protect_special_option( $option );
- 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_site_option
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function get_site_option( $option, $default = false, $use_cache = true ) {
global $wpdb;
/**
* Filter an existing site option before it is retrieved.
- 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_option
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
global $wpdb;
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '2.3' );
Method update_option
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function update_option( $option, $value ) {
global $wpdb;
$option = trim($option);
if ( empty($option) )
Method set_transient
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function set_transient( $transient, $value, $expiration = 0 ) {
/**
* Filter a specific transient before its value is set.
*
Function set_site_transient
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function set_site_transient( $transient, $value, $expiration = 0 ) {
/**
* Filter the value of a specific site transient before it is set.
*
- 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_site_transient
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function get_site_transient( $transient ) {
/**
* Filter the value of an existing site transient.
*
- 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 delete_option
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function delete_option( $option ) {
global $wpdb;
$option = trim( $option );
if ( empty( $option ) )
- 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_option
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function update_option( $option, $value ) {
global $wpdb;
$option = trim($option);
if ( empty($option) )
- 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 update_site_option
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function update_site_option( $option, $value ) {
global $wpdb;
wp_protect_special_option( $option );
Method add_site_option
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function add_site_option( $option, $value ) {
global $wpdb;
wp_protect_special_option( $option );
Method get_site_option
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_site_option( $option, $default = false, $use_cache = true ) {
global $wpdb;
/**
* Filter an existing site option before it is retrieved.
Function wp_user_settings
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function wp_user_settings() {
if ( ! is_admin() )
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 wp_load_alloptions
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function wp_load_alloptions() {
global $wpdb;
if ( !defined( 'WP_INSTALLING' ) || !is_multisite() )
$alloptions = wp_cache_get( 'alloptions', '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
Method delete_option
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function delete_option( $option ) {
global $wpdb;
$option = trim( $option );
if ( empty( $option ) )
Function get_all_user_settings
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function get_all_user_settings() {
global $_updated_user_settings;
if ( ! $user_id = get_current_user_id() )
return 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 update_site_option
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function update_site_option( $option, $value ) {
global $wpdb;
wp_protect_special_option( $option );
- 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 get_option( 'siteurl' );
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return apply_filters( 'default_option_' . $option, $default );
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return apply_filters( 'option_' . $option, maybe_unserialize( $value ) );
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return apply_filters( 'default_option_' . $option, $default );
Function delete_site_option
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function delete_site_option( $option ) {
global $wpdb;
// ms_protect_special_option( $option ); @todo
- 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_set_all_user_settings
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function wp_set_all_user_settings( $user_settings ) {
global $_updated_user_settings;
if ( ! $user_id = get_current_user_id() )
return 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
function delete_site_transient( $transient ) {
/**
* Fires immediately before a specific site transient is deleted.
*
- 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 126.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
function delete_transient( $transient ) {
/**
* Fires immediately before a specific transient is deleted.
*
- 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 126.
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