db_sync_tool.sync.Sync.__init__()   B
last analyzed

Complexity

Conditions 2

Size

Total Lines 64
Code Lines 43

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 43
dl 0
loc 64
rs 8.8478
c 0
b 0
f 0
cc 2
nop 17

How to fix   Long Method    Many Parameters   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
#!/usr/bin/env python3
2
# -*- coding: future_fstrings -*-
3
"""
4
Sync script
5
"""
6
7
from db_sync_tool.utility import system, helper, info
8
from db_sync_tool.database import process
9
from db_sync_tool.remote import transfer, client as remote_client
10
11
12
class Sync:
13
    """
14
    Synchronize a target database from an origin system
15
    """
16
17
    def __init__(self,
0 ignored issues
show
best-practice introduced by
Too many arguments (17/5)
Loading history...
Comprehensibility introduced by
This function exceeds the maximum number of variables (17/15).
Loading history...
18
                 config_file=None,
19
                 verbose=False,
20
                 yes=False,
21
                 mute=False,
22
                 dry_run=False,
23
                 import_file=None,
24
                 dump_name=None,
25
                 keep_dump=None,
26
                 host_file=None,
27
                 clear=False,
28
                 force_password=False,
29
                 use_rsync=False,
30
                 use_rsync_options=None,
31
                 reverse=False,
32
                 config=None,
33
                 args=None):
34
        """
35
        Initialization
36
        :param config_file:
37
        :param verbose:
38
        :param yes:
39
        :param mute:
40
        :param dry_run:
41
        :param import_file:
42
        :param dump_name:
43
        :param keep_dump:
44
        :param host_file:
45
        :param clear:
46
        :param force_password:
47
        :param use_rsync:
48
        :param use_rsync_options:
49
        :param reverse:
50
        :param config:
51
        :param args:
52
        """
53
        if config is None:
54
            config = {}
55
56
        info.print_header(mute)
57
        system.check_args_options(
58
            config_file,
59
            verbose,
60
            yes,
61
            mute,
62
            dry_run,
63
            import_file,
64
            dump_name,
65
            keep_dump,
66
            host_file,
67
            clear,
68
            force_password,
69
            use_rsync,
70
            use_rsync_options,
71
            reverse
72
        )
73
        system.get_configuration(config, args)
74
        system.check_authorizations()
75
        process.create_origin_database_dump()
76
        transfer.transfer_origin_database_dump()
77
        process.import_database_dump()
78
        helper.clean_up()
79
        remote_client.close_ssh_clients()
80
        info.print_footer()
81