| Conditions | 4 |
| Paths | 4 |
| Total Lines | 66 |
| 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 | /** |
||
| 14 | * Instantiates all necessary objects to construct the app. |
||
| 15 | * @public |
||
| 16 | * @class Ocr.App |
||
| 17 | */ |
||
| 18 | var App = (function () { |
||
| 19 | /** |
||
| 20 | * The Ocr wide config parameters. |
||
| 21 | * @private |
||
| 22 | * @static |
||
| 23 | */ |
||
| 24 | var config = { |
||
| 25 | STATUS_ENDPOINT: OC.generateUrl('/apps/ocr/status'), |
||
| 26 | PROCESSING_ENDPOINT: OC.generateUrl('/apps/ocr'), |
||
| 27 | ALLOWED_MIMETYPES: ['application/pdf', 'image/png', 'image/jpeg', 'image/tiff', 'image/jp2', 'image/jpm', 'image/jpx', 'image/webp', 'image/gif'], |
||
| 28 | }; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Inner class |
||
| 32 | * @private |
||
| 33 | * @returns class |
||
| 34 | */ |
||
| 35 | var App = function () { |
||
| 36 | /** Constructor */ |
||
| 37 | |||
| 38 | /** Instantiation of the OCA.Ocr.View. */ |
||
| 39 | this.$view = new OCA.Ocr.View(); |
||
| 40 | |||
| 41 | /** Instantiation of the OCA.Ocr.HttpService with OCR config as input parameter. */ |
||
| 42 | this.$httpService = new OCA.Ocr.HttpService(config); |
||
| 43 | |||
| 44 | /** Instantiation of the OCA.Ocr.Util with OCR config as input parameter. */ |
||
| 45 | this.$util = new OCA.Ocr.Util(config); |
||
| 46 | |||
| 47 | /** Instantiation of the OCA.Ocr.Controller with OCR config as input parameter. */ |
||
| 48 | this.$controller = new OCA.Ocr.Controller(this.$view, this.$util, this.$httpService); |
||
| 49 | |||
| 50 | this.init = function () { |
||
| 51 | this.$controller.init(); |
||
| 52 | } |
||
| 53 | |||
| 54 | } |
||
| 55 | |||
| 56 | return App; |
||
| 57 | })(); |
||
| 58 | /** |
||
| 59 | * Register the App in the namespace |
||
| 60 | */ |
||
| 61 | /** We have to be in the Files App! */ |
||
| 62 | if (!OCA.Files) { |
||
| 63 | return; |
||
| 64 | } |
||
| 65 | /** Escape when the requested file is public.php */ |
||
| 66 | if (/(public)\.php/i.exec(window.location.href) !== null) { |
||
| 67 | return; |
||
| 68 | } |
||
| 69 | /** Create namespace Ocr */ |
||
| 70 | if (!OCA.Ocr) { |
||
| 71 | OCA.Ocr = {}; |
||
| 72 | } |
||
| 73 | OCA.Ocr.App = App; |
||
| 74 | /** global: OC, OCA */ |
||
| 75 | })(OC, OCA, window, jQuery); |
||
| 76 |
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.