Conditions | 7 |
Total Lines | 54 |
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 BaseCard from './BaseCard'; |
||
39 | |||
40 | buildOptionSwitchSection() { |
||
41 | this.card.sections!.push({ |
||
42 | 'widgets': [ |
||
43 | { |
||
44 | 'decoratedText': { |
||
45 | 'bottomLabel': 'If this checked the voters name will be not shown', |
||
46 | 'text': 'Anonymous voter', |
||
47 | 'switchControl': { |
||
48 | 'controlType': 'SWITCH', |
||
49 | 'name': 'is_anonymous', |
||
50 | 'value': '1', |
||
51 | 'selected': this.config?.anon ?? false, |
||
52 | }, |
||
53 | }, |
||
54 | 'horizontalAlignment': 'CENTER', |
||
55 | }, |
||
56 | { |
||
57 | 'decoratedText': { |
||
58 | 'bottomLabel': 'After the poll is created, other member can add more option', |
||
59 | 'text': 'Allow to add more option(s)', |
||
60 | 'switchControl': { |
||
61 | 'controlType': 'SWITCH', |
||
62 | 'name': 'allow_add_option', |
||
63 | 'value': '1', |
||
64 | 'selected': this.config?.optionable ?? true, |
||
65 | }, |
||
66 | }, |
||
67 | 'horizontalAlignment': 'CENTER', |
||
68 | }, |
||
69 | { |
||
70 | 'selectionInput': { |
||
71 | 'type': 'DROPDOWN', |
||
72 | 'label': 'Allow to close poll', |
||
73 | 'name': 'type', |
||
74 | 'items': [ |
||
75 | { |
||
76 | 'text': 'Yes, but only creator', |
||
77 | 'value': '1', |
||
78 | 'selected': this.config.type === ClosableType.CLOSEABLE_BY_CREATOR, |
||
79 | }, |
||
80 | { |
||
81 | 'text': 'Yes, anyone can close', |
||
82 | 'value': '2', |
||
83 | 'selected': this.config.type === ClosableType.CLOSEABLE_BY_ANYONE, |
||
84 | }, |
||
85 | { |
||
86 | 'text': 'No, I want unclosable poll', |
||
87 | 'value': '0', |
||
88 | 'selected': this.config.type === ClosableType.UNCLOSEABLE, |
||
89 | }, |
||
90 | ], |
||
91 | }, |
||
92 | 'horizontalAlignment': 'START', |
||
93 | }, |
||
142 |