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 |
||
41 | View Code Duplication | class IG19286Test extends BaseGraphTest { |
|
|
|||
42 | |||
43 | public $expected = <<<EOT |
||
44 | strict digraph G { |
||
45 | subgraph cluster_c1_id { |
||
46 | label=c1_title; |
||
47 | } /* /subgraph cluster_c1_id */ |
||
48 | subgraph s1_id { |
||
49 | label=s1_title; |
||
50 | } /* /subgraph s1_id */ |
||
51 | } /* /digraph G */ |
||
52 | |||
53 | EOT; |
||
54 | |||
55 | public function setUp() : void { |
||
68 | |||
69 | /** |
||
70 | * Tests Graph->build() |
||
71 | */ |
||
72 | public function testBuild() { |
||
75 | } |
||
76 |
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.