Conditions | 8 |
Paths | 28 |
Total Lines | 87 |
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 | /** |
||
59 | function payoneRatepayRateCalculatorAction(mode, paymentMethod, url) |
||
60 | { |
||
61 | var calcValue, |
||
62 | calcMethod, |
||
63 | notification, |
||
64 | html, |
||
65 | ratePayshopId, |
||
66 | amount, |
||
67 | ratePayCurrency, |
||
68 | ajaxLoader = $("ajaxLoaderId"), |
||
69 | cover = $("cover"); |
||
70 | |||
71 | ajaxLoader.setStyle( |
||
72 | { |
||
73 | display: 'block' |
||
74 | } |
||
75 | ); |
||
76 | cover.setStyle( |
||
77 | { |
||
78 | display: 'block' |
||
79 | } |
||
80 | ); |
||
81 | |||
82 | |||
83 | if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari |
||
84 | xmlhttp = new XMLHttpRequest(); |
||
85 | } else {// code for IE6, IE5 |
||
86 | xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); |
||
87 | } |
||
88 | |||
89 | amount = document.getElementById('amount').value; |
||
90 | ratePayshopId = document.getElementById('ratePayShopId').value; |
||
91 | ratePayCurrency = document.getElementById('ratePayCurrency').value; |
||
92 | if (mode == 'rate') { |
||
93 | calcValue = document.getElementById(paymentMethod + '-rate').value; |
||
94 | |||
95 | |||
96 | calcMethod = 'calculation-by-rate'; |
||
97 | if (document.getElementById('debitSelect')) { |
||
98 | dueDate = document.getElementById('debitSelect').value; |
||
99 | } else { |
||
100 | dueDate= ''; |
||
101 | } |
||
102 | } else if (mode == 'runtime') { |
||
103 | calcValue = document.getElementById(paymentMethod + '-runtime').value; |
||
104 | calcMethod = 'calculation-by-time'; |
||
105 | notification = (document.getElementById(paymentMethod + '_Notification') == null) ? 0 : 1; |
||
106 | if(document.getElementById('debitSelectRuntime')){ |
||
107 | dueDate = document.getElementById('debitSelectRuntime').value; |
||
108 | } else { |
||
109 | dueDate= ''; |
||
110 | } |
||
111 | } |
||
112 | |||
113 | xmlhttp.open("POST", url, false); |
||
114 | |||
115 | xmlhttp.setRequestHeader( |
||
116 | "Content-Type", |
||
117 | "application/x-www-form-urlencoded" |
||
118 | ); |
||
119 | |||
120 | xmlhttp.send( |
||
121 | "paymentMethod=" + paymentMethod + "&calcValue=" + calcValue + "&calcMethod=" + calcMethod + "&dueDate=" + dueDate |
||
122 | + "¬ification=" + notification |
||
123 | + "&ratePayshopId=" + ratePayshopId + "&ratePayCurrency=" + ratePayCurrency + "&amount=" + amount |
||
124 | ); |
||
125 | |||
126 | if (xmlhttp.responseText != null) { |
||
127 | html = xmlhttp.responseText; |
||
128 | document.getElementById(paymentMethod + '_ResultContainer').innerHTML = html; |
||
129 | document.getElementById(paymentMethod + '_ResultContainer').style.display = 'block'; |
||
130 | document.getElementById(paymentMethod + '_ResultContainer').style.padding = '3px 0 0 0'; |
||
131 | document.getElementById(paymentMethod + '_SwitchToTerm').style.display = 'none'; |
||
132 | |||
133 | ajaxLoader.setStyle( |
||
134 | { |
||
135 | display: 'none' |
||
136 | } |
||
137 | ); |
||
138 | cover.setStyle( |
||
139 | { |
||
140 | display: 'none' |
||
141 | } |
||
142 | ); |
||
143 | } |
||
144 | |||
145 | } |
||
146 | /** |
||
197 | ); |
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.