| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 56 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 3 | ||
| 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 | import test from 'ava'; | ||
| 21 | test('should set correct HTTP method', t => { | ||
| 22 |     t.deepEqual(GET(dummy), { | ||
| 23 | path: ['path', 'to', 'resource'], | ||
| 24 |         query: { param: 'value' }, | ||
| 25 |         options: { credentials: 'include', method: 'GET' }, | ||
| 26 | method: 'text' | ||
| 27 | }, 'GET'); | ||
| 28 |     t.deepEqual(HEAD(dummy), { | ||
| 29 | path: ['path', 'to', 'resource'], | ||
| 30 |         query: { param: 'value' }, | ||
| 31 |         options: { credentials: 'include', method: 'HEAD' }, | ||
| 32 | method: 'text' | ||
| 33 | }, 'HEAD'); | ||
| 34 |     t.deepEqual(POST(dummy), { | ||
| 35 | path: ['path', 'to', 'resource'], | ||
| 36 |         query: { param: 'value' }, | ||
| 37 |         options: { credentials: 'include', method: 'POST' }, | ||
| 38 | method: 'text' | ||
| 39 | }, 'POST'); | ||
| 40 |     t.deepEqual(PUT(dummy), { | ||
| 41 | path: ['path', 'to', 'resource'], | ||
| 42 |         query: { param: 'value' }, | ||
| 43 |         options: { credentials: 'include', method: 'PUT' }, | ||
| 44 | method: 'text' | ||
| 45 | }, 'PUT'); | ||
| 46 |     t.deepEqual(DELETE(dummy), { | ||
| 47 | path: ['path', 'to', 'resource'], | ||
| 48 |         query: { param: 'value' }, | ||
| 49 |         options: { credentials: 'include', method: 'DELETE' }, | ||
| 50 | method: 'text' | ||
| 51 | }, 'DELETE'); | ||
| 52 |     t.deepEqual(CONNECT(dummy), { | ||
| 53 | path: ['path', 'to', 'resource'], | ||
| 54 |         query: { param: 'value' }, | ||
| 55 |         options: { credentials: 'include', method: 'CONNECT' }, | ||
| 56 | method: 'text' | ||
| 57 | }, 'CONNECT'); | ||
| 58 |     t.deepEqual(OPTIONS(dummy), { | ||
| 59 | path: ['path', 'to', 'resource'], | ||
| 60 |         query: { param: 'value' }, | ||
| 61 |         options: { credentials: 'include', method: 'OPTIONS' }, | ||
| 62 | method: 'text' | ||
| 63 | }, 'OPTIONS'); | ||
| 64 |     t.deepEqual(TRACE(dummy), { | ||
| 65 | path: ['path', 'to', 'resource'], | ||
| 66 |         query: { param: 'value' }, | ||
| 67 |         options: { credentials: 'include', method: 'TRACE' }, | ||
| 68 | method: 'text' | ||
| 69 | }, 'TRACE'); | ||
| 70 |     t.deepEqual(PATCH(dummy), { | ||
| 71 | path: ['path', 'to', 'resource'], | ||
| 72 |         query: { param: 'value' }, | ||
| 73 |         options: { credentials: 'include', method: 'PATCH' }, | ||
| 74 | method: 'text' | ||
| 75 | }, 'PATCH'); | ||
| 76 | }); | ||
| 77 | |||
| 86 | }); |