| Conditions | 8 |
| Paths | 64 |
| Total Lines | 71 |
| 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 | 'use strict'; |
||
| 32 | update: function ( formContent ) { |
||
| 33 | this.intervalElement.text( this.formatPaymentInterval( formContent.paymentIntervalInMonths ) ); |
||
| 34 | this.intervalTextElement.text( this.intervalText[formContent.paymentIntervalInMonths] ); |
||
| 35 | |||
| 36 | var amountFormat = this.numberFormatter.format(formContent.amount); |
||
| 37 | this.amountElement.each(function () { |
||
| 38 | if (formContent.amount > 0 || $(this).data('display-error') === undefined) { |
||
| 39 | $(this).text(amountFormat); |
||
| 40 | } |
||
| 41 | else { |
||
| 42 | $(this).text('Betrag'); |
||
| 43 | } |
||
| 44 | }); |
||
| 45 | |||
| 46 | var paymentTypeText = this.formatPaymentType( formContent.paymentType ); |
||
| 47 | this.paymentTypeElement.each(function () { |
||
| 48 | if (formContent.paymentType !== "" || $(this).data('display-error') === undefined) { |
||
| 49 | $(this).text(paymentTypeText); |
||
| 50 | } |
||
| 51 | else { |
||
| 52 | $(this).text('Zahlart'); |
||
| 53 | } |
||
| 54 | }); |
||
| 55 | |||
| 56 | this.setSummaryIcon(this.intervalIconElement, formContent.paymentIntervalInMonths, this.intervalIcons); |
||
| 57 | this.setSummaryIcon(this.paymentIconsElement, formContent.paymentType, this.paymentIcons); |
||
| 58 | this.periodicityTextElement.text( this.periodicityText[formContent.paymentIntervalInMonths] ); |
||
| 59 | |||
| 60 | var paymentTextFormatted = this.paymentText[formContent.paymentType]; |
||
| 61 | if (formContent.paymentType == "BEZ") { |
||
| 62 | paymentTextFormatted = '<div class="col-lg-6 no-gutter">' + paymentTextFormatted + "</div>"; |
||
| 63 | paymentTextFormatted = paymentTextFormatted.replace('<br />', '</div><div class="col-lg-6 no-gutter">'); |
||
| 64 | |||
| 65 | if (formContent.accountNumber && formContent.bankCode) { |
||
| 66 | paymentTextFormatted = "<dl class='bank-info'><div><dt>Kontonummer</dt><dd>"+formContent.accountNumber+"</dd></div>" + |
||
| 67 | "<div><dt>Bankleitzahl</dt><dd>"+formContent.bankCode+"</dd></div></dl>" + paymentTextFormatted; |
||
| 68 | } |
||
| 69 | else if (formContent.iban && formContent.bic) { |
||
| 70 | paymentTextFormatted = "<dl class='bank-info'><div><dt>IBAN</dt><dd>"+formContent.iban+"</dd></div>" + |
||
| 71 | "<div><dt>BIC</dt><dd>"+formContent.bic+"</dd></div></dl>" + paymentTextFormatted; |
||
| 72 | } |
||
| 73 | } |
||
| 74 | this.paymentElement.html(paymentTextFormatted); |
||
| 75 | this.setSummaryIcon(this.addressTypeIconElement, formContent.addressType, this.addressTypeIcon); |
||
| 76 | |||
| 77 | if (formContent.addressType != "") { |
||
| 78 | this.addressTypeElement.text(this.addressType[formContent.addressType]); |
||
| 79 | } |
||
| 80 | else { |
||
| 81 | this.addressTypeElement.each(function () { |
||
| 82 | if ($(this).data('display-error') === undefined) { |
||
| 83 | $(this).text("Daten noch nicht ausgewählt."); |
||
| 84 | } |
||
| 85 | }); |
||
| 86 | } |
||
| 87 | |||
| 88 | this.addressTypeTextElement.html(this.getAddressSummaryContent(formContent)); |
||
| 89 | |||
| 90 | if (this.memberShipTypeElement) { |
||
| 91 | var textMemberShipType = this.memberShipType[formContent.membershipType]; |
||
| 92 | this.memberShipTypeElement.each(function () { |
||
| 93 | if (formContent.membershipType) { |
||
| 94 | $(this).text(textMemberShipType); |
||
| 95 | } |
||
| 96 | }); |
||
| 97 | |||
| 98 | this.setSummaryIcon(this.memberShipTypeIconElement, formContent.membershipType, this.memberShipTypeIcon); |
||
| 99 | |||
| 100 | this.memberShipTypeTextElement.text(this.memberShipTypeText[formContent.membershipType]); |
||
| 101 | } |
||
| 102 | }, |
||
| 103 | capitalize: function (s) { |
||
| 195 |