Total Complexity | 3 |
Total Lines | 47 |
Duplicated Lines | 31.91 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 | # -*- coding: utf-8 -*- |
||
29 | class MySql(plumd.plugins.Reader): |
||
30 | """Plugin to measure various MySQL metrics.""" |
||
31 | defaults = { |
||
32 | 'poll.interval': 10, |
||
33 | 'mysql_hosts': { |
||
34 | 'local': { |
||
35 | 'host': '127.0.0.1', |
||
36 | 'port': 3306, |
||
37 | 'user': 'monitor', |
||
38 | 'pass': 'monitor', |
||
39 | 'dbs': ['mysql'] |
||
40 | } |
||
41 | }, |
||
42 | 'mysql_gauges': {}, |
||
43 | 'mysql_rates': {} |
||
44 | } |
||
45 | |||
46 | View Code Duplication | def __init__(self, log, config): |
|
1 ignored issue
–
show
|
|||
47 | """Plugin to measure various MySQL metrics. |
||
48 | |||
49 | :param log: A logger |
||
50 | :type log: logging.RootLogger |
||
51 | :param config: a plumd.config.Conf configuration helper instance. |
||
52 | :type config: plumd.config.Conf |
||
53 | """ |
||
54 | super(MySql, self).__init__(log, config) |
||
55 | self.config.defaults(MySql.defaults) |
||
56 | self.calc = Differential() |
||
57 | self.hosts = self.config.get('mysql_hosts') |
||
58 | self.filter = Filter() |
||
59 | self.gauges = self.config.get('mysql_gauges') |
||
60 | self.rates = self.config.get('mysql_rates') |
||
61 | |||
62 | |||
63 | def poll(self): |
||
64 | """Poll for MySQL metrics. |
||
65 | |||
66 | :rtype: ResultSet |
||
67 | """ |
||
68 | result = plumd.Result("mysql") |
||
69 | |||
70 | # iterate through each configured host |
||
71 | for hname, hconf in self.hosts.items(): |
||
72 | # show status for general metrics |
||
73 | pass |
||
74 | |||
75 | return [result] |
||
76 |