Conditions | 1 |
Total Lines | 101 |
Code Lines | 86 |
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 | """Module to help to create tests.""" |
||
68 | def topology_setting(): |
||
69 | """Set the default values associated to a real topology.""" |
||
70 | switches_to_interface_counts = { |
||
71 | "S1": 2, |
||
72 | "S2": 2, |
||
73 | "S3": 6, |
||
74 | "S4": 2, |
||
75 | "S5": 6, |
||
76 | "S6": 5, |
||
77 | "S7": 2, |
||
78 | "S8": 8, |
||
79 | "S9": 4, |
||
80 | "S10": 3, |
||
81 | "S11": 3, |
||
82 | "User1": 4, |
||
83 | "User2": 2, |
||
84 | "User3": 2, |
||
85 | "User4": 3, |
||
86 | } |
||
87 | |||
88 | links_to_interfaces = [ |
||
89 | ["S1:1", "S2:1"], |
||
90 | ["S1:2", "User1:1"], |
||
91 | ["S2:2", "User4:1"], |
||
92 | ["S3:1", "S5:1"], |
||
93 | ["S3:2", "S7:1"], |
||
94 | ["S3:3", "S8:1"], |
||
95 | ["S3:4", "S11:1"], |
||
96 | ["S3:5", "User3:1"], |
||
97 | ["S3:6", "User4:2"], |
||
98 | ["S4:1", "S5:2"], |
||
99 | ["S4:2", "User1:2"], |
||
100 | ["S5:3", "S6:1"], |
||
101 | ["S5:4", "S6:2"], |
||
102 | ["S5:5", "S8:2"], |
||
103 | ["S5:6", "User1:3"], |
||
104 | ["S6:3", "S9:1"], |
||
105 | ["S6:4", "S9:2"], |
||
106 | ["S6:5", "S10:1"], |
||
107 | ["S7:2", "S8:3"], |
||
108 | ["S8:4", "S9:3"], |
||
109 | ["S8:5", "S9:4"], |
||
110 | ["S8:6", "S10:2"], |
||
111 | ["S8:7", "S11:2"], |
||
112 | ["S8:8", "User3:2"], |
||
113 | ["S10:3", "User2:1"], |
||
114 | ["S11:3", "User2:2"], |
||
115 | ["User1:4", "User4:3"], |
||
116 | ] |
||
117 | |||
118 | links_to_metadata = [ |
||
119 | {"reliability": 5, "bandwidth": 100, "delay": 105}, |
||
120 | {"reliability": 5, "bandwidth": 100, "delay": 1}, |
||
121 | {"reliability": 5, "bandwidth": 100, "delay": 10}, |
||
122 | {"reliability": 5, "bandwidth": 10, "delay": 112}, |
||
123 | {"reliability": 5, "bandwidth": 100, "delay": 1}, |
||
124 | {"reliability": 5, "bandwidth": 100, "delay": 1}, |
||
125 | {"reliability": 3, "bandwidth": 100, "delay": 6}, |
||
126 | {"reliability": 5, "bandwidth": 100, "delay": 1}, |
||
127 | {"reliability": 5, "bandwidth": 100, "delay": 10}, |
||
128 | { |
||
129 | "reliability": 1, |
||
130 | "bandwidth": 100, |
||
131 | "delay": 30, |
||
132 | "ownership": {"A": {}}, |
||
133 | }, |
||
134 | { |
||
135 | "reliability": 3, |
||
136 | "bandwidth": 100, |
||
137 | "delay": 110, |
||
138 | "ownership": {"A": {}}, |
||
139 | }, |
||
140 | {"reliability": 1, "bandwidth": 100, "delay": 40}, |
||
141 | { |
||
142 | "reliability": 3, |
||
143 | "bandwidth": 100, |
||
144 | "delay": 40, |
||
145 | "ownership": {"A": {}}, |
||
146 | }, |
||
147 | {"reliability": 5, "bandwidth": 100, "delay": 112}, |
||
148 | {"reliability": 3, "bandwidth": 100, "delay": 60}, |
||
149 | {"reliability": 3, "bandwidth": 100, "delay": 60}, |
||
150 | {"reliability": 5, "bandwidth": 100, "delay": 62}, |
||
151 | {"bandwidth": 100, "delay": 108, "ownership": "A"}, |
||
152 | {"reliability": 5, "bandwidth": 100, "delay": 1}, |
||
153 | {"reliability": 3, "bandwidth": 100, "delay": 32}, |
||
154 | {"reliability": 3, "bandwidth": 100, "delay": 110}, |
||
155 | {"reliability": 5, "bandwidth": 100, "ownership": {"A": {}}}, |
||
156 | {"reliability": 3, "bandwidth": 100, "delay": 7}, |
||
157 | {"reliability": 5, "bandwidth": 100, "delay": 1}, |
||
158 | { |
||
159 | "reliability": 3, |
||
160 | "bandwidth": 100, |
||
161 | "delay": 10, |
||
162 | "ownership": {"A": {}}, |
||
163 | }, |
||
164 | {"reliability": 3, "bandwidth": 100, "delay": 6}, |
||
165 | {"reliability": 5, "bandwidth": 10, "delay": 105}, |
||
166 | ] |
||
167 | |||
168 | return links_to_interfaces, links_to_metadata, switches_to_interface_counts |
||
169 | |||
260 |