| Conditions | 6 |
| Total Lines | 70 |
| Code Lines | 43 |
| 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 | import Vuex from 'vuex'; |
||
| 77 | |||
| 78 | async function createWrapper(privileges = []): Promise<Wrapper<Vue>> { |
||
| 79 | const localVue = createLocalVue(); |
||
| 80 | localVue.use(Vuex); |
||
| 81 | localVue.directive('tooltip', { |
||
| 82 | bind(el, binding) { |
||
| 83 | el.setAttribute('tooltip-message', binding.value.message); |
||
| 84 | }, |
||
| 85 | inserted(el, binding) { |
||
| 86 | el.setAttribute('tooltip-message', binding.value.message); |
||
| 87 | }, |
||
| 88 | update(el, binding) { |
||
| 89 | el.setAttribute('tooltip-message', binding.value.message); |
||
| 90 | } |
||
| 91 | }); |
||
| 92 | localVue.filter('currency', Shopware.Filter.getByName('currency')); |
||
| 93 | |||
| 94 | return shallowMount(await Shopware.Component.build('sw-order-detail-general'), { |
||
| 95 | localVue, |
||
| 96 | stubs: { |
||
| 97 | 'sw-container': { |
||
| 98 | template: ` |
||
| 99 | <div class="sw-container"><slot></slot></div> |
||
| 100 | ` |
||
| 101 | }, |
||
| 102 | 'sw-card-section': { |
||
| 103 | template: ` |
||
| 104 | <div class="sw-card-section"><slot></slot></div> |
||
| 105 | ` |
||
| 106 | }, |
||
| 107 | 'sw-description-list': { |
||
| 108 | template: ` |
||
| 109 | <div class="sw-description-list"><slot></slot></div> |
||
| 110 | ` |
||
| 111 | }, |
||
| 112 | 'sw-card': { |
||
| 113 | template: ` |
||
| 114 | <div class="sw-card"> |
||
| 115 | <slot></slot> |
||
| 116 | <slot name="grid"></slot> |
||
| 117 | </div> |
||
| 118 | ` |
||
| 119 | }, |
||
| 120 | 'sw-order-general-info': true, |
||
| 121 | 'sw-order-line-items-grid': true, |
||
| 122 | 'sw-order-saveable-field': { |
||
| 123 | props: ['value'], |
||
| 124 | template: '<input class="sw-order-saveable-field" :value="value" @input="$emit(\'value-change\', $event.target.value)" />', |
||
| 125 | }, |
||
| 126 | }, |
||
| 127 | mocks: { |
||
| 128 | $tc: (key, number, value) => { |
||
| 129 | if (!value) { |
||
| 130 | return key; |
||
| 131 | } |
||
| 132 | return key + JSON.stringify(value); |
||
| 133 | }, |
||
| 134 | }, |
||
| 135 | provide: { |
||
| 136 | acl: { |
||
| 137 | can: (key) => { |
||
| 138 | if (!key) { return true; } |
||
| 139 | |||
| 140 | return privileges.includes(key); |
||
| 141 | } |
||
| 142 | }, |
||
| 143 | }, |
||
| 144 | propsData: { |
||
| 145 | orderId: '1a2b3c', |
||
| 146 | isSaveSuccessful: false |
||
| 147 | } |
||
| 245 |