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 |
||
3 | class Jetpack_JSON_API_Translations_Modify_Endpoint extends Jetpack_JSON_API_Translations_Endpoint { |
||
4 | // POST /sites/%s/translations |
||
5 | // POST /sites/%s/translations/update |
||
6 | protected $action = 'default_action'; |
||
|
|||
7 | protected $new_version; |
||
8 | protected $log; |
||
9 | |||
10 | View Code Duplication | public function default_action() { |
|
19 | |||
20 | protected function update() { |
||
29 | } |
||
30 |
This check looks for improperly formatted assignments.
Every assignment must have exactly one space before and one space after the equals operator.
To illustrate:
will have no issues, while
will report issues in lines 1 and 2.