backuppc_clone.command.BackupDeleteCommand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 80 %

Importance

Changes 0
Metric Value
eloc 12
dl 24
loc 30
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A BackupDeleteCommand._handle_command() 13 13 1

How to fix   Duplicated Code   

Duplicated Code

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.BackupDelete import BackupDelete
4
5
6 View Code Duplication
class BackupDeleteCommand(BaseCommand):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7
    """
8
    Deletes a host backup
9
10
    backup-delete
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('Deleting Backup {}/{}'.format(host, backup_no))
25
26
        helper = BackupDelete(self._io)
27
        helper.delete_backup(host, backup_no)
28
29
        DataLayer.instance.commit()
30
31
# ----------------------------------------------------------------------------------------------------------------------
32