| Conditions | 2 |
| Paths | 2 |
| Total Lines | 60 |
| 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 | /** |
||
| 10 | (function (OC, window, $, undefined) { |
||
|
|
|||
| 11 | 'use strict'; |
||
| 12 | /** global: OCA */ |
||
| 13 | if (!OCA.Ocr) { |
||
| 14 | /** |
||
| 15 | * @namespace |
||
| 16 | * global: OCA |
||
| 17 | */ |
||
| 18 | OCA.Ocr = {}; |
||
| 19 | } |
||
| 20 | /** |
||
| 21 | * OCA.Ocr.App |
||
| 22 | * Integrates all necessary objects to build the app. |
||
| 23 | * @type {{initialize: OCA.Ocr.App.initialize}} |
||
| 24 | * global: OCA |
||
| 25 | */ |
||
| 26 | OCA.Ocr.App = { |
||
| 27 | /** |
||
| 28 | * Initialize function. Gets all things together. |
||
| 29 | */ |
||
| 30 | initialize: function () { |
||
| 31 | var self = this; |
||
| 32 | //Create the OCR object |
||
| 33 | /** global: OC, OCA */ |
||
| 34 | this._ocr = new OCA.Ocr.Ocr(OC.generateUrl('/apps/ocr')); |
||
| 35 | // Create the View Object |
||
| 36 | /** global: OCA */ |
||
| 37 | this._view = new OCA.Ocr.View(this._ocr); |
||
| 38 | self._ocr.initialize().done(function(){ |
||
| 39 | self._view.initialize(); |
||
| 40 | }).fail(function (message) { |
||
| 41 | self._view.notifyError('OCR App could not be initialized: ' + message); |
||
| 42 | }); |
||
| 43 | }, |
||
| 44 | /** |
||
| 45 | * Destroy function. Deregisters everthing and destroys the Ocr app. |
||
| 46 | */ |
||
| 47 | destroy: function () { |
||
| 48 | var self = this; |
||
| 49 | this._view.destroy(); |
||
| 50 | } |
||
| 51 | }; |
||
| 52 | /** |
||
| 53 | * Init the App |
||
| 54 | */ |
||
| 55 | $(document).ready(function () { |
||
| 56 | /** |
||
| 57 | * We have to be in the Files App! |
||
| 58 | */ |
||
| 59 | if(!OCA.Files){ // we don't have the files app, so ignore anything |
||
| 60 | return; |
||
| 61 | } |
||
| 62 | if(/(public)\.php/i.exec(window.location.href)!=null){ |
||
| 63 | return; // escape when the requested file is public.php |
||
| 64 | } |
||
| 65 | /** global: OCA */ |
||
| 66 | OCA.Ocr.App.initialize(); |
||
| 67 | }); |
||
| 68 | /** global: OC */ |
||
| 69 | })(OC, window, jQuery); |
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.