Conditions | 2 |
Total Lines | 94 |
Lines | 94 |
Ratio | 100 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 | # This Python file uses the following encoding: utf-8 |
||
184 | View Code Duplication | def test_div_with_id(): |
|
185 | init() |
||
186 | |||
187 | meta = { |
||
188 | 'pandoc-latex-environment': { |
||
189 | 'c': { |
||
190 | 'test': { |
||
191 | 'c': [ |
||
192 | { |
||
193 | 'c': [ |
||
194 | { |
||
195 | 'c': 'class1', |
||
196 | 't': 'Str' |
||
197 | } |
||
198 | ], |
||
199 | 't': 'MetaInlines' |
||
200 | }, |
||
201 | { |
||
202 | 'c': [ |
||
203 | { |
||
204 | 'c': 'class2', |
||
205 | 't': 'Str' |
||
206 | } |
||
207 | ], |
||
208 | 't': 'MetaInlines' |
||
209 | } |
||
210 | ], |
||
211 | 't': 'MetaList' |
||
212 | } |
||
213 | }, |
||
214 | 't': 'MetaMap' |
||
215 | } |
||
216 | } |
||
217 | |||
218 | src = json.loads(json.dumps(Div( |
||
219 | [ |
||
220 | 'identifier', |
||
221 | [ |
||
222 | 'class1', |
||
223 | 'class2' |
||
224 | ], |
||
225 | [] |
||
226 | ], |
||
227 | [ |
||
228 | { |
||
229 | 'c': [ |
||
230 | { |
||
231 | 'c': 'content', |
||
232 | 't': 'Str' |
||
233 | } |
||
234 | ], |
||
235 | 't': 'Plain' |
||
236 | } |
||
237 | ] |
||
238 | ))) |
||
239 | dest = json.loads(json.dumps(Div( |
||
240 | [ |
||
241 | 'identifier', |
||
242 | [ |
||
243 | 'class1', |
||
244 | 'class2' |
||
245 | ], |
||
246 | [] |
||
247 | ], |
||
248 | [ |
||
249 | { |
||
250 | 'c': [ |
||
251 | 'tex', |
||
252 | '\\begin{test} \\label{identifier}' |
||
253 | ], |
||
254 | 't': 'RawBlock' |
||
255 | }, |
||
256 | { |
||
257 | 'c': [ |
||
258 | { |
||
259 | 'c': 'content', |
||
260 | 't': 'Str' |
||
261 | } |
||
262 | ], |
||
263 | 't': 'Plain' |
||
264 | }, |
||
265 | { |
||
266 | 'c': [ |
||
267 | 'tex', |
||
268 | '\\end{test}' |
||
269 | ], |
||
270 | 't': 'RawBlock' |
||
271 | } |
||
272 | ] |
||
273 | ))) |
||
274 | |||
275 | pandoc_latex_environment.environment(src['t'], src['c'], 'latex', meta) |
||
276 | |||
277 | assert json.loads(json.dumps(src)) == dest |
||
278 | |||
378 |