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 |
||
2 | class AutoCompleteOption extends DataObject { |
||
3 | private static $db = array( |
||
4 | 'Name' => 'Varchar', |
||
5 | 'Slug' => 'Varchar', |
||
6 | 'Description' => 'Text', |
||
7 | 'Locale' => 'DBLocale' |
||
8 | ); |
||
9 | |||
10 | private static $belongs_to = array( |
||
1 ignored issue
–
show
|
|||
11 | 'ElasticSearchPage' => 'ElasticSearchPage' |
||
12 | ); |
||
13 | |||
14 | public function can_create($member = null) { |
||
17 | |||
18 | public function can_edit($member = null) { |
||
21 | |||
22 | public function can_delete($member = null) { |
||
25 | |||
26 | public function requireDefaultRecords() { |
||
59 | } |
||
60 |
This check marks private properties in classes that are never used. Those properties can be removed.