| Conditions | 4 | 
| Paths | 4 | 
| Total Lines | 58 | 
| 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 | /** | ||
| 10 | (function (OC, OCA, window, $) { | ||
|  | |||
| 11 | 'use strict'; | ||
| 12 | /** | ||
| 13 | * Adds some util functions mainly used by the OCR controller. | ||
| 14 | * @public | ||
| 15 | * @class Ocr.Util | ||
| 16 | */ | ||
| 17 |     var Util = function (config) { | ||
| 18 | |||
| 19 | /** Constructor */ | ||
| 20 | var ocrConfig; | ||
| 21 |         config !== undefined ? ocrConfig = config : console.error('OCR config is not defined.'); | ||
| 22 | |||
| 23 | /** TODO: | ||
| 24 | * Filter file array for files with supported mimetypes and return | ||
| 25 | * the clean array of all input elements with a proper mimetype. | ||
| 26 | * @public | ||
| 27 |          * @param {Array<File>} selectedFiles | ||
| 28 |          * @returns {Array<File>} | ||
| 29 | */ | ||
| 30 |         this.filterFilesWithMimeTypes = function (selectedFiles) { | ||
| 31 | 			return selectedFiles.filter(function(file){ | ||
| 32 | return ocrConfig.ALLOWED_MIMETYPES.indexOf(file.mimetype) == -1 ? false : true; | ||
| 33 | }); | ||
| 34 | } | ||
| 35 | |||
| 36 | /** Reduce the input array of file elements to only contain the file id. | ||
| 37 | * @public | ||
| 38 |          * @param {Array<File>} files | ||
| 39 |          * @returns {Array<File>} | ||
| 40 | */ | ||
| 41 |         this.shrinkData = function(files) { | ||
| 42 | 			return files.map(function(file){ | ||
| 43 | 				return {id: file.id}; | ||
| 44 | }); | ||
| 45 | } | ||
| 46 | |||
| 47 | } | ||
| 48 | |||
| 49 | /** | ||
| 50 | * Init OCR Util | ||
| 51 | */ | ||
| 52 | /** We have to be in the Files App! */ | ||
| 53 |     if (!OCA.Files) { | ||
| 54 | return; | ||
| 55 | } | ||
| 56 | /** Escape when the requested file is public.php */ | ||
| 57 |     if (/(public)\.php/i.exec(window.location.href) !== null) { | ||
| 58 | return; | ||
| 59 | } | ||
| 60 | /** Create namespace Ocr */ | ||
| 61 |     if (!OCA.Ocr) { | ||
| 62 |         OCA.Ocr = {}; | ||
| 63 | } | ||
| 64 | OCA.Ocr.Util = Util; | ||
| 65 | |||
| 66 | /** global: OC, OCA */ | ||
| 67 | })(OC, OCA, window, jQuery); | ||
| 68 | 
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.