File wp-signup.php
has 611 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/** Sets up the WordPress Environment. */
require __DIR__ . '/wp-load.php';
Method show_blog_form
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
if ( ! is_wp_error( $errors ) ) {
$errors = new WP_Error();
}
Function show_blog_form
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
if ( ! is_wp_error( $errors ) ) {
$errors = new WP_Error();
}
- 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 signup_another_blog
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
$current_user = wp_get_current_user();
if ( ! is_wp_error( $errors ) ) {
$errors = new WP_Error();
Method signup_user
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
global $active_signup;
if ( ! is_wp_error( $errors ) ) {
$errors = new WP_Error();
Method validate_another_blog_signup
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function validate_another_blog_signup() {
global $blogname, $blog_title, $errors, $domain, $path;
$current_user = wp_get_current_user();
if ( ! is_user_logged_in() ) {
die();
Method confirm_another_blog_signup
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array(), $blog_id = 0 ) {
if ( $blog_id ) {
switch_to_blog( $blog_id );
$home_url = home_url( '/' );
Method validate_blog_signup
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function validate_blog_signup() {
// Re-validate user info.
$user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
$user_name = $user_result['user_name'];
$user_email = $user_result['user_email'];
Method signup_blog
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function signup_blog( $user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '' ) {
if ( ! is_wp_error( $errors ) ) {
$errors = new WP_Error();
}
Method show_user_form
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function show_user_form( $user_name = '', $user_email = '', $errors = '' ) {
if ( ! is_wp_error( $errors ) ) {
$errors = new WP_Error();
}
Method wpmu_signup_stylesheet
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wpmu_signup_stylesheet() {
?>
<style type="text/css">
.mu_register { width: 90%; margin: 0 auto; }
.mu_register form { margin-top: 2em; }
Function validate_another_blog_signup
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function validate_another_blog_signup() {
global $blogname, $blog_title, $errors, $domain, $path;
$current_user = wp_get_current_user();
if ( ! is_user_logged_in() ) {
die();
- 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 confirm_another_blog_signup
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array(), $blog_id = 0 ) {
Function validate_blog_signup
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function validate_blog_signup() {
// Re-validate user info.
$user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
$user_name = $user_result['user_name'];
$user_email = $user_result['user_email'];
- 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 confirm_blog_signup
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) {
Consider simplifying this complex logical expression. Open
if ( is_user_logged_in() && ( 'all' === $active_signup || 'blog' === $active_signup ) ) {
signup_another_blog( $newblogname );
} elseif ( ! is_user_logged_in() && ( 'all' === $active_signup || 'user' === $active_signup ) ) {
signup_user( $newblogname, $user_email );
} elseif ( ! is_user_logged_in() && ( 'blog' === $active_signup ) ) {
Method signup_blog
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function signup_blog( $user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '' ) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( ! empty( $_POST['WPLANG'] ) ) {
$languages = signup_get_available_languages();
if ( in_array( $_POST['WPLANG'], $languages, true ) ) {
- 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 90.
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
if ( ! empty( $_POST['WPLANG'] ) ) {
$languages = signup_get_available_languages();
if ( in_array( $_POST['WPLANG'], $languages, true ) ) {
- 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 90.
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