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:
1 | <?php |
||
15 | class MeasureManagerSpec extends ObjectBehavior |
||
16 | { |
||
17 | View Code Duplication | function let() |
|
28 | |||
29 | function it_throws_an_exception_when_try_to_get_symbols_of_unknown_family() |
||
37 | |||
38 | function it_returns_unit_symbols_list_from_a_family() |
||
50 | |||
51 | function it_returns_standard_unit_for_a_family() |
||
57 | } |
||
58 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.