| Conditions | 1 |
| Paths | 2 |
| Total Lines | 65 |
| Lines | 0 |
| Ratio | 0 % |
| 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 | 'use strict'; |
||
| 16 | analyze: url => { |
||
| 17 | return new Promise((resolve, reject) => { |
||
| 18 | wappalyzer.driver.log = (message, source, type) => { |
||
| 19 | if ( type === 'error' ) { |
||
| 20 | return reject(message); |
||
| 21 | } |
||
| 22 | |||
| 23 | if ( !driver.quiet ) { |
||
| 24 | console.log('[wappalyzer ' + type + ']', '[' + source + ']', message); |
||
| 25 | } |
||
| 26 | }; |
||
| 27 | |||
| 28 | wappalyzer.driver.displayApps = detected => { |
||
| 29 | var apps = []; |
||
| 30 | |||
| 31 | Object.keys(detected).forEach(appName => { |
||
| 32 | const app = detected[appName]; |
||
| 33 | |||
| 34 | var categories = []; |
||
| 35 | |||
| 36 | app.props.cats.forEach(id => { |
||
| 37 | var category = {}; |
||
| 38 | |||
| 39 | category[id] = wappalyzer.categories[id].name; |
||
| 40 | |||
| 41 | categories.push(category) |
||
| 42 | }); |
||
| 43 | |||
| 44 | apps.push({ |
||
| 45 | name: app.name, |
||
| 46 | confidence: app.confidenceTotal.toString(), |
||
| 47 | version: app.version, |
||
| 48 | icon: app.props.icon || 'default.svg', |
||
| 49 | website: app.props.website, |
||
| 50 | categories |
||
| 51 | }); |
||
| 52 | }); |
||
| 53 | |||
| 54 | resolve(apps); |
||
| 55 | }; |
||
| 56 | |||
| 57 | const browser = new Browser(); |
||
| 58 | |||
| 59 | browser.visit(url, error => { |
||
| 60 | if ( error ) { |
||
| 61 | return reject(error); |
||
| 62 | } |
||
| 63 | |||
| 64 | wappalyzer.driver.document = browser.document; |
||
| 65 | |||
| 66 | const headers = browser.resources['0'].response.headers; |
||
| 67 | const vars = Object.getOwnPropertyNames(browser.window); |
||
| 68 | const html = browser.html(); |
||
| 69 | |||
| 70 | const hostname = wappalyzer.parseUrl(url).hostname; |
||
| 71 | |||
| 72 | wappalyzer.analyze(hostname, url, { |
||
| 73 | headers, |
||
| 74 | html, |
||
| 75 | env: vars |
||
| 76 | }); |
||
| 77 | }); |
||
| 78 | |||
| 79 | }); |
||
| 80 | } |
||
| 81 | } |
||
| 84 |