Conditions | 1 |
Paths | 1 |
Total Lines | 73 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 | /* |
||
40 | $(document).ready(function () { |
||
41 | |||
42 | /** |
||
43 | * @constructs CMSPico |
||
44 | */ |
||
45 | var CMSPico = function () { |
||
46 | |||
47 | $.extend(CMSPico.prototype, pico_elements); |
||
48 | $.extend(CMSPico.prototype, pico_result); |
||
49 | |||
50 | this.initialize(); |
||
51 | this.retrieveWebsites(); |
||
52 | }; |
||
53 | |||
54 | CMSPico.prototype = { |
||
55 | |||
56 | initialize: function () { |
||
57 | define.nchost = window.location.protocol + '//' + window.location.host; |
||
58 | pico_elements.initElements(); |
||
59 | pico_elements.initUI(); |
||
60 | pico_elements.initTweaks(); |
||
61 | }, |
||
62 | |||
63 | |||
64 | retrieveWebsites: function () { |
||
65 | |||
66 | $.ajax({ |
||
67 | method: 'GET', |
||
68 | url: OC.generateUrl('/apps/cms_pico/personal/websites'), |
||
69 | data: {} |
||
70 | }).done(function (res) { |
||
71 | pico_result.displayWebsites(res.websites); |
||
72 | }); |
||
73 | |||
74 | } |
||
75 | |||
76 | }; |
||
77 | |||
78 | |||
79 | /** |
||
80 | * @constructs Notification |
||
81 | */ |
||
82 | var Notification = function () { |
||
83 | this.initialize(); |
||
84 | }; |
||
85 | |||
86 | Notification.prototype = { |
||
87 | |||
88 | initialize: function () { |
||
89 | |||
90 | var notyf = new Notyf({ |
||
|
|||
91 | delay: 5000 |
||
92 | }); |
||
93 | |||
94 | this.onSuccess = function (text) { |
||
95 | notyf.confirm(text); |
||
96 | }; |
||
97 | |||
98 | this.onFail = function (text) { |
||
99 | notyf.alert(text); |
||
100 | }; |
||
101 | |||
102 | } |
||
103 | |||
104 | }; |
||
105 | |||
106 | OCA.CMSPico = CMSPico; |
||
107 | OCA.CMSPico.manage = new CMSPico(); |
||
108 | |||
109 | OCA.Notification = Notification; |
||
110 | OCA.notification = new Notification(); |
||
111 | |||
112 | }); |
||
113 |
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.