| Conditions | 3 | 
| Total Lines | 54 | 
| Code Lines | 35 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 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 | package producer_test  | 
            ||
| 16 | func TestNewReProducer(t *testing.T) { | 
            ||
| 17 | t.Parallel()  | 
            ||
| 18 | |||
| 19 | 	methods := []string{http.MethodGet} | 
            ||
| 20 | 	dictionary := []string{"/home"} | 
            ||
| 21 | |||
| 22 | dictionaryProducer := producer.NewDictionaryProducer(methods, dictionary, 1)  | 
            ||
| 23 | |||
| 24 | sut := producer.NewReProducer(  | 
            ||
| 25 | methods,  | 
            ||
| 26 | dictionary,  | 
            ||
| 27 | dictionaryProducer,  | 
            ||
| 28 | time.Millisecond*100,  | 
            ||
| 29 | )  | 
            ||
| 30 | |||
| 31 | 	go sut.Reproduce(scan.Result{ | 
            ||
| 32 | 		Target: scan.Target{ | 
            ||
| 33 | Path: "/home",  | 
            ||
| 34 | Method: http.MethodGet,  | 
            ||
| 35 | Depth: 1,  | 
            ||
| 36 | },  | 
            ||
| 37 | 		Response: &http.Response{ | 
            ||
| 38 | StatusCode: 200,  | 
            ||
| 39 | 			Request: &http.Request{ | 
            ||
| 40 | Method: http.MethodGet,  | 
            ||
| 41 | URL: test.MustParseUrl(t, "http://mysite/contacts"),  | 
            ||
| 42 | },  | 
            ||
| 43 | },  | 
            ||
| 44 | })  | 
            ||
| 45 | |||
| 46 | targets := make([]scan.Target, 0, 10)  | 
            ||
| 47 | 	for tar := range sut.Produce() { | 
            ||
| 48 | targets = append(targets, tar)  | 
            ||
| 49 | }  | 
            ||
| 50 | |||
| 51 | 	sort.Slice(targets, func(i, j int) bool { | 
            ||
| 52 | return targets[i].Path < targets[j].Path  | 
            ||
| 53 | })  | 
            ||
| 54 | |||
| 55 | assert.Len(t, targets, 2)  | 
            ||
| 56 | |||
| 57 | 	expectedTargets := []scan.Target{ | 
            ||
| 58 | 		{ | 
            ||
| 59 | Path: "/home",  | 
            ||
| 60 | Method: http.MethodGet,  | 
            ||
| 61 | Depth: 1,  | 
            ||
| 62 | },  | 
            ||
| 63 | 		{ | 
            ||
| 64 | Path: "/home/home",  | 
            ||
| 65 | Method: http.MethodGet,  | 
            ||
| 66 | Depth: 0,  | 
            ||
| 67 | },  | 
            ||
| 68 | }  | 
            ||
| 69 | assert.Equal(t, expectedTargets, targets)  | 
            ||
| 70 | }  | 
            ||
| 71 |