Completed
Push — add/testing-info ( be1095...03b7e9 )
by
unknown
09:20
created

Jetpack_IDC   F

Complexity

Total Complexity 60

Size/Duplication

Total Lines 709
Duplicated Lines 19.75 %

Coupling/Cohesion

Components 3
Dependencies 6

Importance

Changes 0
Metric Value
dl 140
loc 709
rs 3.491
c 0
b 0
f 0
wmc 60
lcom 3
cbo 6

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like Jetpack_IDC often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Jetpack_IDC, and based on these observations, apply Extract Interface, too.

1
<?php // phpcs:disable Squiz.Commenting.FileComment.SpacingAfterComment
2
/**
3
 * Identity Crisis handler.
4
 *
5
 * @deprecated 9.8.0. Functionality moved to the automattic/identity-crisis package.
6
 * @package automattic/jetpack
7
 */
8
9
 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
10
_deprecated_file( basename( __FILE__ ), 'jetpack-9.8' );
11