| Total Complexity | 5 |
| Total Lines | 20 |
| Duplicated Lines | 100 % |
| Changes | 0 | ||
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 | View Code Duplication | class Dance: |
|
|
|
|||
| 2 | def __init__(self, events=None, printer_handle=None, bot=None, say=None): |
||
| 3 | self.events = events |
||
| 4 | self.printer = printer_handle |
||
| 5 | self.interests = ['__.dance__'] |
||
| 6 | self.bot = bot |
||
| 7 | |||
| 8 | self.help = ".dance" |
||
| 9 | |||
| 10 | for event in events: |
||
| 11 | if event._type in self.interests: |
||
| 12 | event.subscribe(self) |
||
| 13 | |||
| 14 | def handle(self, event): |
||
| 15 | try: |
||
| 16 | self.printer("PRIVMSG " + event.channel + " : :D-\-< " + '\n') |
||
| 17 | self.printer("PRIVMSG " + event.channel + " : :D-|-< " + '\n') |
||
| 18 | self.printer("PRIVMSG " + event.channel + " : :D-/-< " + '\n') |
||
| 19 | except TypeError: |
||
| 20 | pass |
||
| 21 |