Conditions | 1 |
Total Lines | 66 |
Code Lines | 51 |
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 | """ |
||
91 | def workers(): |
||
92 | """ |
||
93 | Return a generated list of worker data. |
||
94 | |||
95 | Returns: |
||
96 | list: The worker data |
||
97 | """ |
||
98 | global IMPORT_TIME # pylint: disable=global-statement,global-variable-not-assigned |
||
99 | return [ |
||
100 | { |
||
101 | "apps": [ |
||
102 | { |
||
103 | "id": 0, |
||
104 | "modifier1": 0, |
||
105 | "mountpoint": "/", |
||
106 | "startup_time": 0, |
||
107 | "interpreter": 36657355585954, |
||
108 | "callable": 427548492337761, |
||
109 | "requests": 0, |
||
110 | "exceptions": 0, |
||
111 | "chdir": "", |
||
112 | } |
||
113 | ], |
||
114 | "avg_rt": 0, |
||
115 | "delta_requests": 0, |
||
116 | "exceptions": 0, |
||
117 | "id": worker_id(), |
||
118 | "last_spawn": IMPORT_TIME, |
||
119 | "pid": 42744, |
||
120 | "requests": total_requests() / 2, |
||
121 | "respawn_count": 0, |
||
122 | "rss": 0, |
||
123 | "running_time": time.time() - IMPORT_TIME, |
||
124 | "signals": 0, |
||
125 | "status": "idle", |
||
126 | "tx": 0, |
||
127 | "vsz": 0, |
||
128 | }, |
||
129 | { |
||
130 | "apps": [ |
||
131 | { |
||
132 | "id": 0, |
||
133 | "modifier1": 0, |
||
134 | "mountpoint": "/", |
||
135 | "startup_time": 0, |
||
136 | "interpreter": 95994467934864, |
||
137 | "callable": 684895773596472, |
||
138 | "requests": 0, |
||
139 | "exceptions": 0, |
||
140 | "chdir": "", |
||
141 | } |
||
142 | ], |
||
143 | "avg_rt": 0, |
||
144 | "delta_requests": 0, |
||
145 | "exceptions": 0, |
||
146 | "id": worker_id(), |
||
147 | "last_spawn": IMPORT_TIME + 1, |
||
148 | "pid": 42745, |
||
149 | "requests": total_requests() / 2, |
||
150 | "respawn_count": 0, |
||
151 | "rss": 0, |
||
152 | "running_time": time.time() - IMPORT_TIME + 1, |
||
153 | "signals": 0, |
||
154 | "status": "busy", |
||
155 | "tx": 0, |
||
156 | "vsz": 0, |
||
157 | }, |
||
171 |