| Total Complexity | 1 |
| Total Lines | 30 |
| Duplicated Lines | 80 % |
| 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 | from backuppc_clone.DataLayer import DataLayer |
||
| 2 | from backuppc_clone.command.BaseCommand import BaseCommand |
||
| 3 | from backuppc_clone.helper.BackupClone import BackupClone |
||
| 4 | |||
| 5 | |||
| 6 | View Code Duplication | class BackupCloneCommand(BaseCommand): |
|
|
|
|||
| 7 | """ |
||
| 8 | Clones a single host backup |
||
| 9 | |||
| 10 | backup-clone |
||
| 11 | {clone.cfg : The configuration file of the clone} |
||
| 12 | {host : The name of the host} |
||
| 13 | {backup# : The backup number} |
||
| 14 | """ |
||
| 15 | |||
| 16 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 17 | def _handle_command(self) -> None: |
||
| 18 | """ |
||
| 19 | Executes the command. |
||
| 20 | """ |
||
| 21 | host = self.argument('host') |
||
| 22 | backup_no = int(self.argument('backup#')) |
||
| 23 | |||
| 24 | self._io.title('Cloning Backup {}/{}'.format(host, backup_no)) |
||
| 25 | |||
| 26 | helper = BackupClone(self._io) |
||
| 27 | helper.clone_backup(host, backup_no) |
||
| 28 | |||
| 29 | DataLayer.instance.commit() |
||
| 30 | |||
| 32 |