| Conditions | 2 |
| Total Lines | 98 |
| Lines | 98 |
| 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 |
||
| 280 | View Code Duplication | def test_div_with_title(): |
|
| 281 | init() |
||
| 282 | |||
| 283 | meta = { |
||
| 284 | 'pandoc-latex-environment': { |
||
| 285 | 'c': { |
||
| 286 | 'test': { |
||
| 287 | 'c': [ |
||
| 288 | { |
||
| 289 | 'c': [ |
||
| 290 | { |
||
| 291 | 'c': 'class1', |
||
| 292 | 't': 'Str' |
||
| 293 | } |
||
| 294 | ], |
||
| 295 | 't': 'MetaInlines' |
||
| 296 | }, |
||
| 297 | { |
||
| 298 | 'c': [ |
||
| 299 | { |
||
| 300 | 'c': 'class2', |
||
| 301 | 't': 'Str' |
||
| 302 | } |
||
| 303 | ], |
||
| 304 | 't': 'MetaInlines' |
||
| 305 | } |
||
| 306 | ], |
||
| 307 | 't': 'MetaList' |
||
| 308 | } |
||
| 309 | }, |
||
| 310 | 't': 'MetaMap' |
||
| 311 | } |
||
| 312 | } |
||
| 313 | |||
| 314 | src = json.loads(json.dumps(Div( |
||
| 315 | [ |
||
| 316 | '', |
||
| 317 | [ |
||
| 318 | 'class1', |
||
| 319 | 'class2' |
||
| 320 | ], |
||
| 321 | [ |
||
| 322 | ['title', 'theTitle'] |
||
| 323 | ] |
||
| 324 | ], |
||
| 325 | [ |
||
| 326 | { |
||
| 327 | 'c': [ |
||
| 328 | { |
||
| 329 | 'c': 'content', |
||
| 330 | 't': 'Str' |
||
| 331 | } |
||
| 332 | ], |
||
| 333 | 't': 'Plain' |
||
| 334 | } |
||
| 335 | ] |
||
| 336 | ))) |
||
| 337 | dest = json.loads(json.dumps(Div( |
||
| 338 | [ |
||
| 339 | '', |
||
| 340 | [ |
||
| 341 | 'class1', |
||
| 342 | 'class2' |
||
| 343 | ], |
||
| 344 | [ |
||
| 345 | ['title', 'theTitle'] |
||
| 346 | ] |
||
| 347 | ], |
||
| 348 | [ |
||
| 349 | { |
||
| 350 | 'c': [ |
||
| 351 | 'tex', |
||
| 352 | '\\begin{test}[theTitle]' |
||
| 353 | ], |
||
| 354 | 't': 'RawBlock' |
||
| 355 | }, |
||
| 356 | { |
||
| 357 | 'c': [ |
||
| 358 | { |
||
| 359 | 'c': 'content', |
||
| 360 | 't': 'Str' |
||
| 361 | } |
||
| 362 | ], |
||
| 363 | 't': 'Plain' |
||
| 364 | }, |
||
| 365 | { |
||
| 366 | 'c': [ |
||
| 367 | 'tex', |
||
| 368 | '\\end{test}' |
||
| 369 | ], |
||
| 370 | 't': 'RawBlock' |
||
| 371 | } |
||
| 372 | ] |
||
| 373 | ))) |
||
| 374 | |||
| 375 | pandoc_latex_environment.environment(src['t'], src['c'], 'latex', meta) |
||
| 376 | |||
| 377 | assert json.loads(json.dumps(src)) == dest |
||
| 378 |