Conditions | 1 |
Total Lines | 62 |
Code Lines | 49 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | from unittest import TestCase |
||
7 | def setUp(self) -> None: |
||
8 | self.metrics_dict = { |
||
9 | 'last_updated': '2019-04-02T03:56:41.078Z', |
||
10 | 'collection_interval_in_millis': 15000, |
||
11 | 'process': { |
||
12 | 'memory': { |
||
13 | 'heap': { |
||
14 | 'total_in_bytes': 175874048, |
||
15 | 'used_in_bytes': 157139288, |
||
16 | 'size_limit': 1526909922 |
||
17 | }, |
||
18 | 'resident_set_size_in_bytes': 285655040 |
||
19 | }, |
||
20 | 'event_loop_delay': 0.08109402656555176, |
||
21 | 'pid': 18595, |
||
22 | 'uptime_in_millis': 2494490 |
||
23 | }, |
||
24 | 'os': { |
||
25 | 'load': { |
||
26 | '1m': 0.16357421875, |
||
27 | '5m': 0.13720703125, |
||
28 | '15m': 0.13037109375 |
||
29 | }, |
||
30 | 'memory': { |
||
31 | 'total_in_bytes': 8257908736, |
||
32 | 'free_in_bytes': 193777664, |
||
33 | 'used_in_bytes': 8064131072 |
||
34 | }, |
||
35 | 'uptime_in_millis': 1212738000, |
||
36 | 'platform': 'linux', |
||
37 | 'platformRelease': 'linux-4.15.0-1034-aws', |
||
38 | 'distro': 'Ubuntu Linux', |
||
39 | 'distroRelease': 'Ubuntu Linux-18.04', |
||
40 | 'cgroup': { |
||
41 | 'cpuacct': { |
||
42 | 'control_group': '/system.slice/kibana.service', |
||
43 | 'usage_nanos': 24967412414 |
||
44 | }, |
||
45 | 'cpu': { |
||
46 | 'control_group': '/system.slice/kibana.service', |
||
47 | 'cfs_period_micros': 100000, |
||
48 | 'cfs_quota_micros': -1, |
||
49 | 'stat': { |
||
50 | 'number_of_elapsed_periods': 0, |
||
51 | 'number_of_times_throttled': 0, |
||
52 | 'time_throttled_nanos': 0 |
||
53 | } |
||
54 | } |
||
55 | } |
||
56 | }, |
||
57 | 'response_times': { |
||
58 | 'avg_in_millis': 2.3333333333333335, 'max_in_millis': 3 |
||
59 | }, |
||
60 | 'requests': { |
||
61 | 'disconnects': 0, |
||
62 | 'statusCodes': {}, |
||
63 | 'total': 3, |
||
64 | 'status_codes': { |
||
65 | '302': 3 |
||
66 | } |
||
67 | }, |
||
68 | 'concurrent_connections': 0 |
||
69 | } |
||
76 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.