Completed
Push — fix/add-small-delay-to-regular... ( 94b9ea...f03336 )
by
unknown
33:06 queued 12:57
created

Jetpack_Landing_Page   B

Complexity

Total Complexity 41

Size/Duplication

Total Lines 294
Duplicated Lines 8.84 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 26
loc 294
rs 8.2769
c 0
b 0
f 0
wmc 41
lcom 1
cbo 5

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_Landing_Page 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_Landing_Page, and based on these observations, apply Extract Interface, too.

1
<?php
2
// This is intentionally left empty as a stub because some sites were caching the require()
3
// @see https://github.com/Automattic/jetpack/issues/5091
4