Conditions | 1 |
Paths | 1 |
Total Lines | 79 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
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 | /* |
||
41 | $(document).ready(function () { |
||
42 | |||
43 | /** |
||
44 | * @constructs CMSPico |
||
45 | */ |
||
46 | var CMSPico = function () { |
||
47 | |||
48 | $.extend(CMSPico.prototype, pico_nav); |
||
49 | $.extend(CMSPico.prototype, pico_elements); |
||
50 | $.extend(CMSPico.prototype, pico_result); |
||
51 | |||
52 | this.initialize(); |
||
53 | this.retrieveWebsites(); |
||
54 | }; |
||
55 | |||
56 | CMSPico.prototype = { |
||
57 | |||
58 | initialize: function () { |
||
59 | pico_define.nchost = window.location.protocol + '//' + window.location.host; |
||
60 | pico_elements.initElements(); |
||
61 | pico_elements.initUI(); |
||
62 | pico_elements.initTweaks(); |
||
63 | |||
64 | pico_define.index = OC.getRootPath(); |
||
65 | if (oc_config.modRewriteWorking !== true) { |
||
|
|||
66 | pico_define.index += '/index.php'; |
||
67 | } |
||
68 | }, |
||
69 | |||
70 | |||
71 | retrieveWebsites: function () { |
||
72 | |||
73 | $.ajax({ |
||
74 | method: 'GET', |
||
75 | url: OC.generateUrl('/apps/cms_pico/personal/websites'), |
||
76 | data: {} |
||
77 | }).done(function (res) { |
||
78 | pico_result.displayWebsites(res.websites); |
||
79 | }); |
||
80 | |||
81 | } |
||
82 | |||
83 | }; |
||
84 | |||
85 | |||
86 | /** |
||
87 | * @constructs Notification |
||
88 | */ |
||
89 | var Notification = function () { |
||
90 | this.initialize(); |
||
91 | }; |
||
92 | |||
93 | Notification.prototype = { |
||
94 | |||
95 | initialize: function () { |
||
96 | |||
97 | var notyf = new Notyf({ |
||
98 | delay: 5000 |
||
99 | }); |
||
100 | |||
101 | this.onSuccess = function (text) { |
||
102 | notyf.confirm(text); |
||
103 | }; |
||
104 | |||
105 | this.onFail = function (text) { |
||
106 | notyf.alert(text); |
||
107 | }; |
||
108 | |||
109 | } |
||
110 | |||
111 | }; |
||
112 | |||
113 | OCA.CMSPico = CMSPico; |
||
114 | OCA.CMSPico.manage = new CMSPico(); |
||
115 | |||
116 | OCA.Notification = Notification; |
||
117 | OCA.notification = new Notification(); |
||
118 | |||
119 | }); |
||
120 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.