| Conditions | 8 |
| Paths | 96 |
| Total Lines | 134 |
| 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 | /** |
||
| 31 | function payoneSwitchOnlineBankTransfer(typeCode, methodCode, element, country, currency) { |
||
| 32 | |||
| 33 | var accountNumberWrap = $('account_number_wrap'); |
||
| 34 | var bankCodeWrap = $('bank_code_wrap'); |
||
| 35 | var sepaIbanWrap = $('sepa_iban_wrap'); |
||
| 36 | var sepaBicWrap = $('sepa_bic_wrap'); |
||
| 37 | var bankGroupWrapAt = $('bank_group_wrap_at'); |
||
| 38 | var bankGroupWrapNl = $('bank_group_wrap_nl'); |
||
| 39 | var accountNumberInput = $(methodCode + '_account_number'); |
||
| 40 | var bankCodeInput = $(methodCode + '_bank_code'); |
||
| 41 | var sepaIbanInput = $(methodCode + '_sepa_iban'); |
||
| 42 | var sepaBicInput = $(methodCode + '_sepa_bic'); |
||
| 43 | var bankGroupSelectAt = $(methodCode + '_bank_group_at'); |
||
| 44 | var bankGroupSelectNl = $(methodCode + '_bank_group_nl'); |
||
| 45 | var sofortueberweisungShowIban = $(methodCode + '_pnt_show_iban'); |
||
| 46 | |||
| 47 | function enableBankGroupNl() { |
||
| 48 | if (bankGroupWrapNl) { |
||
| 49 | bankGroupWrapNl.show(); |
||
| 50 | bankGroupSelectNl.removeAttribute("disabled"); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 54 | function enableBankGroupAt() { |
||
| 55 | if (bankGroupWrapAt) { |
||
| 56 | bankGroupWrapAt.show(); |
||
| 57 | bankGroupSelectAt.removeAttribute("disabled"); |
||
| 58 | } |
||
| 59 | } |
||
| 60 | |||
| 61 | function enableAccountNumber() { |
||
| 62 | if (accountNumberWrap) { |
||
| 63 | accountNumberWrap.show(); |
||
| 64 | accountNumberInput.removeAttribute("disabled"); |
||
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | function enableBankCode() { |
||
| 69 | if (bankCodeWrap) { |
||
| 70 | bankCodeWrap.show(); |
||
| 71 | bankCodeInput.removeAttribute("disabled"); |
||
| 72 | } |
||
| 73 | } |
||
| 74 | |||
| 75 | function enableSepaIban() { |
||
| 76 | |||
| 77 | if (sepaIbanWrap) { |
||
| 78 | sepaIbanWrap.show(); |
||
| 79 | sepaIbanInput.removeAttribute("disabled"); |
||
| 80 | } |
||
| 81 | } |
||
| 82 | |||
| 83 | function enableSepaBic() { |
||
| 84 | |||
| 85 | if (sepaBicWrap) { |
||
| 86 | sepaBicWrap.show(); |
||
| 87 | sepaBicInput.removeAttribute("disabled"); |
||
| 88 | } |
||
| 89 | } |
||
| 90 | |||
| 91 | if (typeCode == 'EPS') { |
||
| 92 | $("dt_method_payone_online_bank_transfer_eps").on("click", function (event) { |
||
|
|
|||
| 93 | disableAll(); |
||
| 94 | enableBankGroupAt(); |
||
| 95 | |||
| 96 | }); |
||
| 97 | } |
||
| 98 | if (typeCode == 'IDL') { |
||
| 99 | $("dt_method_payone_online_bank_transfer_idl").on("click", function (event) { |
||
| 100 | disableAll(); |
||
| 101 | enableBankGroupNl(); |
||
| 102 | }); |
||
| 103 | } |
||
| 104 | if (typeCode == 'GPY') { |
||
| 105 | $("dt_method_payone_online_bank_transfer_giropay").on("click", function (event) { |
||
| 106 | disableAll(); |
||
| 107 | enableSepaIban(); |
||
| 108 | enableSepaBic(); |
||
| 109 | }); |
||
| 110 | } |
||
| 111 | |||
| 112 | if (typeCode == 'PFF') { |
||
| 113 | $("dt_method_payone_online_bank_transfer_pff").on("click", function (event) { |
||
| 114 | disableAll(); |
||
| 115 | }); |
||
| 116 | } |
||
| 117 | |||
| 118 | if (typeCode == 'PNT') { |
||
| 119 | $("dt_method_payone_online_bank_transfer_sofortueberweisung").on("click", function (event) { |
||
| 120 | disableAll(); |
||
| 121 | if (sofortueberweisungShowIban.value == 1) { |
||
| 122 | enableSepaIban(); |
||
| 123 | enableSepaBic(); |
||
| 124 | } |
||
| 125 | |||
| 126 | if (country == 'CH' && currency == 'CHF') { |
||
| 127 | enableAccountNumber(); |
||
| 128 | enableBankCode(); |
||
| 129 | } |
||
| 130 | }); |
||
| 131 | } |
||
| 132 | |||
| 133 | if (typeCode == 'PFC' || typeCode == 'P24') { |
||
| 134 | disableAll(); |
||
| 135 | } |
||
| 136 | |||
| 137 | function disableAll() { |
||
| 138 | if (accountNumberWrap && accountNumberInput) { |
||
| 139 | accountNumberWrap.hide(); |
||
| 140 | accountNumberInput.setAttribute("disabled", "disabled"); |
||
| 141 | } |
||
| 142 | |||
| 143 | if (bankCodeWrap && bankCodeInput) { |
||
| 144 | bankCodeWrap.hide(); |
||
| 145 | bankCodeInput.setAttribute("disabled", "disabled"); |
||
| 146 | } |
||
| 147 | |||
| 148 | if (sepaIbanWrap && sepaIbanInput) { |
||
| 149 | sepaIbanWrap.hide(); |
||
| 150 | sepaIbanInput.setAttribute("disabled", "disabled"); |
||
| 151 | } |
||
| 152 | |||
| 153 | if (sepaBicWrap && sepaBicInput) { |
||
| 154 | sepaBicWrap.hide(); |
||
| 155 | sepaBicInput.setAttribute("disabled", "disabled"); |
||
| 156 | } |
||
| 157 | |||
| 158 | if (bankGroupWrapNl && bankGroupSelectNl) { |
||
| 159 | bankGroupWrapNl.hide(); |
||
| 160 | bankGroupSelectNl.setAttribute("disabled", "disabled"); |
||
| 161 | } |
||
| 162 | } |
||
| 163 | |||
| 164 | } |
||
| 165 | |||
| 171 |
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.