Conditions | 1 |
Total Lines | 55 |
Code Lines | 46 |
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 asyncio |
||
40 | def script_ladder_settings(props): |
||
41 | ladder_group = obs.obs_properties_create() |
||
42 | obs.obs_properties_add_group( |
||
43 | props, lp.ladder_group, _("Ladder Settings"), obs.OBS_GROUP_NORMAL, |
||
44 | ladder_group) |
||
45 | p = obs.obs_properties_add_text( |
||
46 | ladder_group, lp.ladder_name, _("Ladder Name"), obs.OBS_TEXT_DEFAULT) |
||
47 | obs.obs_property_set_modified_callback(p, name_modified) |
||
48 | obs.obs_properties_add_color( |
||
49 | ladder_group, lp.pre_color, _("Color Pre-Race")) |
||
50 | obs.obs_properties_add_color( |
||
51 | ladder_group, lp.racing_color, _("Still Racing Color")) |
||
52 | obs.obs_properties_add_color( |
||
53 | ladder_group, lp.winner_color, _("Winner Color")) |
||
54 | obs.obs_properties_add_color( |
||
55 | ladder_group, lp.loser_color, _("Loser Color")) |
||
56 | obs.obs_properties_add_color( |
||
57 | ladder_group, lp.ff_color, _("Forfeit Color")) |
||
58 | p = obs.obs_properties_add_list( |
||
59 | ladder_group, lp.stats_source, _("Ladder Stats Source"), |
||
60 | obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING |
||
61 | ) |
||
62 | fill_source_list(p) |
||
63 | obs.obs_properties_add_bool( |
||
64 | ladder_group, lp.show_season_name, _("Show Season Name") |
||
65 | ) |
||
66 | obs.obs_properties_add_bool( |
||
67 | ladder_group, lp.show_mode_name, _("Show Mode Name") |
||
68 | ) |
||
69 | obs.obs_properties_add_bool( |
||
70 | ladder_group, lp.show_rating, _("Show Rating") |
||
71 | ) |
||
72 | obs.obs_properties_add_bool( |
||
73 | ladder_group, lp.show_rank, _("Show Rank") |
||
74 | ) |
||
75 | obs.obs_properties_add_bool( |
||
76 | ladder_group, lp.show_change, _("Show Change") |
||
77 | ) |
||
78 | obs.obs_properties_add_bool( |
||
79 | ladder_group, lp.show_win_loss_tie, _("Show Win/Loss/Tie Record") |
||
80 | ) |
||
81 | p = obs.obs_properties_add_list( |
||
82 | ladder_group, lp.ladder_season, _("Season for Stats"), |
||
83 | obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING |
||
84 | ) |
||
85 | obs.obs_property_set_modified_callback(p, season_or_mode_changed) |
||
86 | obs.obs_property_list_add_string(p, _("Lifetime"), "0") |
||
87 | obs.obs_property_list_add_string(p, _("Current Season"), "-1") |
||
88 | p = obs.obs_properties_add_list( |
||
89 | ladder_group, lp.ladder_mode, _("Mode for Stats"), |
||
90 | obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING |
||
91 | ) |
||
92 | obs.obs_property_set_modified_callback(p, season_or_mode_changed) |
||
93 | obs.obs_property_list_add_string(p, _("Global"), "0") |
||
94 | obs.obs_property_list_add_string(p, _("Current Mode"), "-1") |
||
95 | |||
134 |