| Conditions | 2 |
| Total Lines | 74 |
| Lines | 74 |
| 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 |
||
| 108 | View Code Duplication | def test_empty(): |
|
| 109 | init() |
||
| 110 | |||
| 111 | meta = { |
||
| 112 | 'pandoc-latex-environment': { |
||
| 113 | 'c': { |
||
| 114 | 'test': { |
||
| 115 | 'c': [ |
||
| 116 | { |
||
| 117 | 'c': [ |
||
| 118 | { |
||
| 119 | 'c': 'class1', |
||
| 120 | 't': 'Str' |
||
| 121 | } |
||
| 122 | ], |
||
| 123 | 't': 'MetaInlines' |
||
| 124 | }, |
||
| 125 | { |
||
| 126 | 'c': [ |
||
| 127 | { |
||
| 128 | 'c': 'class2', |
||
| 129 | 't': 'Str' |
||
| 130 | } |
||
| 131 | ], |
||
| 132 | 't': 'MetaInlines' |
||
| 133 | } |
||
| 134 | ], |
||
| 135 | 't': 'MetaList' |
||
| 136 | } |
||
| 137 | }, |
||
| 138 | 't': 'MetaMap' |
||
| 139 | } |
||
| 140 | } |
||
| 141 | |||
| 142 | src = json.loads(json.dumps(Div( |
||
| 143 | [ |
||
| 144 | '', |
||
| 145 | [], |
||
| 146 | [] |
||
| 147 | ], |
||
| 148 | [ |
||
| 149 | { |
||
| 150 | 'c': [ |
||
| 151 | { |
||
| 152 | 'c': 'content', |
||
| 153 | 't': 'Str' |
||
| 154 | } |
||
| 155 | ], |
||
| 156 | 't': 'Plain' |
||
| 157 | } |
||
| 158 | ] |
||
| 159 | ))) |
||
| 160 | dest = json.loads(json.dumps(Div( |
||
| 161 | [ |
||
| 162 | '', |
||
| 163 | [], |
||
| 164 | [] |
||
| 165 | ], |
||
| 166 | [ |
||
| 167 | { |
||
| 168 | 'c': [ |
||
| 169 | { |
||
| 170 | 'c': 'content', |
||
| 171 | 't': 'Str' |
||
| 172 | } |
||
| 173 | ], |
||
| 174 | 't': 'Plain' |
||
| 175 | } |
||
| 176 | ] |
||
| 177 | ))) |
||
| 178 | |||
| 179 | pandoc_latex_environment.environment(src['t'], src['c'], 'latex', meta) |
||
| 180 | |||
| 181 | assert json.loads(json.dumps(src)) == dest |
||
| 182 | |||
| 378 |