| Conditions | 1 | 
| Total Lines | 60 | 
| Code Lines | 51 | 
| 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 test the KytosGraph in graph.py."""  | 
            ||
| 132 | @staticmethod  | 
            ||
| 133 | def generate_topology():  | 
            ||
| 134 | """Generates a predetermined topology"""  | 
            ||
| 135 |         switches = {} | 
            ||
| 136 |         interfaces = {} | 
            ||
| 137 |         links = {} | 
            ||
| 138 | |||
| 139 |         TestSearchResults.create_switch("User1", switches) | 
            ||
| 140 | TestSearchResults.add_interfaces(3, switches["User1"], interfaces)  | 
            ||
| 141 | |||
| 142 |         TestSearchResults.create_switch("S2", switches) | 
            ||
| 143 | TestSearchResults.add_interfaces(2, switches["S2"], interfaces)  | 
            ||
| 144 | |||
| 145 |         TestSearchResults.create_switch("User2", switches) | 
            ||
| 146 | TestSearchResults.add_interfaces(3, switches["User2"], interfaces)  | 
            ||
| 147 | |||
| 148 |         TestSearchResults.create_switch("S4", switches) | 
            ||
| 149 | TestSearchResults.add_interfaces(4, switches["S4"], interfaces)  | 
            ||
| 150 | |||
| 151 |         TestSearchResults.create_switch("S5", switches) | 
            ||
| 152 | TestSearchResults.add_interfaces(2, switches["S5"], interfaces)  | 
            ||
| 153 | |||
| 154 |         TestSearchResults.create_link("User1:1", "S2:1", interfaces, links) | 
            ||
| 155 |         TestSearchResults.create_link("User1:2", "S5:1", interfaces, links) | 
            ||
| 156 |         TestSearchResults.create_link("User1:3", "S4:1", interfaces, links) | 
            ||
| 157 |         TestSearchResults.create_link("S2:2", "User2:1", interfaces, links) | 
            ||
| 158 |         TestSearchResults.create_link("User2:2", "S4:2", interfaces, links) | 
            ||
| 159 |         TestSearchResults.create_link("S5:2", "S4:3", interfaces, links) | 
            ||
| 160 |         TestSearchResults.create_link("User2:3", "S4:4", interfaces, links) | 
            ||
| 161 | |||
| 162 | TestSearchResults.add_metadata_to_link(  | 
            ||
| 163 |             "User1:1", "S2:1", { | 
            ||
| 164 | "reliability": 3, "ownership": "B", "delay": 30,  | 
            ||
| 165 | "bandwidth": 20}, links)  | 
            ||
| 166 | TestSearchResults.add_metadata_to_link(  | 
            ||
| 167 |             "User1:2", "S5:1", { | 
            ||
| 168 | "reliability": 1, "ownership": "A", "delay": 5,  | 
            ||
| 169 | "bandwidth": 50}, links)  | 
            ||
| 170 | TestSearchResults.add_metadata_to_link(  | 
            ||
| 171 |             "User1:3", "S4:1", { | 
            ||
| 172 | "reliability": 3, "ownership": "A", "delay": 60,  | 
            ||
| 173 | "bandwidth": 10}, links)  | 
            ||
| 174 | TestSearchResults.add_metadata_to_link(  | 
            ||
| 175 |             "S2:2", "User2:1", { | 
            ||
| 176 | "reliability": 3, "ownership": "B", "delay": 30,  | 
            ||
| 177 | "bandwidth": 20}, links)  | 
            ||
| 178 | TestSearchResults.add_metadata_to_link(  | 
            ||
| 179 |             "User2:2", "S4:2", { | 
            ||
| 180 | "reliability": 3, "ownership": "B", "delay": 30,  | 
            ||
| 181 | "bandwidth": 10}, links)  | 
            ||
| 182 | TestSearchResults.add_metadata_to_link(  | 
            ||
| 183 |             "S5:2", "S4:3", { | 
            ||
| 184 | "reliability": 1, "ownership": "A", "delay": 10,  | 
            ||
| 185 | "bandwidth": 50}, links)  | 
            ||
| 186 | TestSearchResults.add_metadata_to_link(  | 
            ||
| 187 |             "User2:3", "S4:4", { | 
            ||
| 188 | "reliability": 3, "ownership": "A", "delay": 29,  | 
            ||
| 189 | "bandwidth": 20}, links)  | 
            ||
| 190 | |||
| 191 | return (switches, links)  | 
            ||
| 192 |