| Conditions | 4 | 
| Total Lines | 59 | 
| Code Lines | 45 | 
| 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 cmd  | 
            ||
| 139 | func StartScan(logger *logrus.Logger, cnf *scan.Config, u *url.URL) error { | 
            ||
| 140 | c, err := client.NewClientFromConfig(  | 
            ||
| 141 | cnf.TimeoutInMilliseconds,  | 
            ||
| 142 | cnf.Socks5Url,  | 
            ||
| 143 | cnf.UserAgent,  | 
            ||
| 144 | cnf.UseCookieJar,  | 
            ||
| 145 | cnf.Cookies,  | 
            ||
| 146 | cnf.Headers,  | 
            ||
| 147 | u,  | 
            ||
| 148 | )  | 
            ||
| 149 | 	if err != nil { | 
            ||
| 150 | return errors.Wrap(err, "failed to build client")  | 
            ||
| 151 | }  | 
            ||
| 152 | |||
| 153 | dict, err := dictionary.NewDictionaryFrom(cnf.DictionaryPath, c)  | 
            ||
| 154 | 	if err != nil { | 
            ||
| 155 | return errors.Wrap(err, "failed to build dictionary")  | 
            ||
| 156 | }  | 
            ||
| 157 | |||
| 158 | targetProducer := producer.NewDictionaryProducer(cnf.HTTPMethods, dict, cnf.ScanDepth)  | 
            ||
| 159 | decoratedProducer := producer.NewReProducer(  | 
            ||
| 160 | cnf.HTTPMethods,  | 
            ||
| 161 | dict,  | 
            ||
| 162 | targetProducer,  | 
            ||
| 163 | time.Millisecond*(time.Duration(cnf.TimeoutInMilliseconds)+50),  | 
            ||
| 164 | )  | 
            ||
| 165 | |||
| 166 | s := scan.NewScanner(  | 
            ||
| 167 | c,  | 
            ||
| 168 | decoratedProducer,  | 
            ||
| 169 | logger,  | 
            ||
| 170 | )  | 
            ||
| 171 | |||
| 172 | 	logger.WithFields(logrus.Fields{ | 
            ||
| 173 | "url": u.String(),  | 
            ||
| 174 | "threads": cnf.Threads,  | 
            ||
| 175 | "dictionary-length": len(dict),  | 
            ||
| 176 | "scan-depth": cnf.ScanDepth,  | 
            ||
| 177 | "timeout": cnf.TimeoutInMilliseconds,  | 
            ||
| 178 | "socks5": cnf.Socks5Url,  | 
            ||
| 179 | "cookies": strigifyCookies(cnf.Cookies),  | 
            ||
| 180 | "cookie-jar": cnf.UseCookieJar,  | 
            ||
| 181 | "headers": stringyfyHeaders(cnf.Headers),  | 
            ||
| 182 | "user-agent": cnf.UserAgent,  | 
            ||
| 183 | 	}).Info("Starting scan") | 
            ||
| 184 | |||
| 185 | resultLogger := scan.NewResultLogger(logger)  | 
            ||
| 186 | summarizer := scan.NewResultSummarizer(logger.Out)  | 
            ||
| 187 | 	for result := range s.Scan(u, cnf.Threads) { | 
            ||
| 188 | decoratedProducer.Reproduce(result)  | 
            ||
| 189 | resultLogger.Log(result)  | 
            ||
| 190 | summarizer.Add(result)  | 
            ||
| 191 | }  | 
            ||
| 192 | |||
| 193 | summarizer.Summarize()  | 
            ||
| 194 | |||
| 195 | 	logger.Info("Finished scan") | 
            ||
| 196 | |||
| 197 | return nil  | 
            ||
| 198 | }  | 
            ||
| 219 |