| 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 |
||
| 13 | View Code Duplication | def test_div(): |
|
|
|
|||
| 14 | init() |
||
| 15 | |||
| 16 | meta = { |
||
| 17 | 'pandoc-latex-environment': { |
||
| 18 | 'c': { |
||
| 19 | 'test': { |
||
| 20 | 'c': [ |
||
| 21 | { |
||
| 22 | 'c': [ |
||
| 23 | { |
||
| 24 | 'c': 'class1', |
||
| 25 | 't': 'Str' |
||
| 26 | } |
||
| 27 | ], |
||
| 28 | 't': 'MetaInlines' |
||
| 29 | }, |
||
| 30 | { |
||
| 31 | 'c': [ |
||
| 32 | { |
||
| 33 | 'c': 'class2', |
||
| 34 | 't': 'Str' |
||
| 35 | } |
||
| 36 | ], |
||
| 37 | 't': 'MetaInlines' |
||
| 38 | } |
||
| 39 | ], |
||
| 40 | 't': 'MetaList' |
||
| 41 | } |
||
| 42 | }, |
||
| 43 | 't': 'MetaMap' |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | src = json.loads(json.dumps(Div( |
||
| 48 | [ |
||
| 49 | '', |
||
| 50 | [ |
||
| 51 | 'class1', |
||
| 52 | 'class2' |
||
| 53 | ], |
||
| 54 | [] |
||
| 55 | ], |
||
| 56 | [ |
||
| 57 | { |
||
| 58 | 'c': [ |
||
| 59 | { |
||
| 60 | 'c': 'content', |
||
| 61 | 't': 'Str' |
||
| 62 | } |
||
| 63 | ], |
||
| 64 | 't': 'Plain' |
||
| 65 | } |
||
| 66 | ] |
||
| 67 | ))) |
||
| 68 | dest = json.loads(json.dumps(Div( |
||
| 69 | [ |
||
| 70 | '', |
||
| 71 | [ |
||
| 72 | 'class1', |
||
| 73 | 'class2' |
||
| 74 | ], |
||
| 75 | [] |
||
| 76 | ], |
||
| 77 | [ |
||
| 78 | { |
||
| 79 | 'c': [ |
||
| 80 | 'tex', |
||
| 81 | '\\begin{test}' |
||
| 82 | ], |
||
| 83 | 't': 'RawBlock' |
||
| 84 | }, |
||
| 85 | { |
||
| 86 | 'c': [ |
||
| 87 | { |
||
| 88 | 'c': 'content', |
||
| 89 | 't': 'Str' |
||
| 90 | } |
||
| 91 | ], |
||
| 92 | 't': 'Plain' |
||
| 93 | }, |
||
| 94 | { |
||
| 95 | 'c': [ |
||
| 96 | 'tex', |
||
| 97 | '\\end{test}' |
||
| 98 | ], |
||
| 99 | 't': 'RawBlock' |
||
| 100 | } |
||
| 101 | ] |
||
| 102 | ))) |
||
| 103 | |||
| 104 | pandoc_latex_environment.environment(src['t'], src['c'], 'latex', meta) |
||
| 105 | |||
| 106 | assert json.loads(json.dumps(src)) == dest |
||
| 107 | |||
| 378 |