| Conditions | 1 |
| Total Lines | 70 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 | # Licensed to the StackStorm, Inc ('StackStorm') under one or more |
||
| 60 | def test_run_fail_on_mutliple_targets(self): |
||
| 61 | action = self.setup_query_blank_results() |
||
| 62 | |||
| 63 | # nodes = 1, subnets = 1, ip_ranges = 1 |
||
| 64 | nodes = ["192.168.1.1", "192.168.1.10"] |
||
| 65 | subnets = ["192.168.1.0/24"] |
||
| 66 | ip_ranges = ["192.168.1.1:192.168.1.10"] |
||
| 67 | |||
| 68 | self.assertRaises(ValueError, |
||
| 69 | action.run, |
||
| 70 | name="Unit Test Discovery", |
||
| 71 | platform="orion", |
||
| 72 | poller="primary", |
||
| 73 | snmp_communities=["public"], |
||
| 74 | nodes=nodes, |
||
| 75 | subnets=subnets, |
||
| 76 | ip_ranges=ip_ranges, |
||
| 77 | no_icmp_only=True, |
||
| 78 | auto_import=False) |
||
| 79 | |||
| 80 | # nodes = 1, subnets = 0, ip_ranges = 1 |
||
| 81 | nodes = ["192.168.1.1", "192.168.1.10"] |
||
| 82 | subnets = None |
||
| 83 | ip_ranges = ["192.168.1.1:192.168.1.10"] |
||
| 84 | |||
| 85 | self.assertRaises(ValueError, |
||
| 86 | action.run, |
||
| 87 | name="Unit Test Discovery", |
||
| 88 | platform="orion", |
||
| 89 | poller="primary", |
||
| 90 | snmp_communities=["public"], |
||
| 91 | nodes=nodes, |
||
| 92 | subnets=subnets, |
||
| 93 | ip_ranges=ip_ranges, |
||
| 94 | no_icmp_only=True, |
||
| 95 | auto_import=False) |
||
| 96 | |||
| 97 | # nodes = 1, subnets = 1, ip_ranges = 0 |
||
| 98 | nodes = ["192.168.1.1", "192.168.1.10"] |
||
| 99 | subnets = ["192.168.1.0/24"] |
||
| 100 | ip_ranges = None |
||
| 101 | |||
| 102 | self.assertRaises(ValueError, |
||
| 103 | action.run, |
||
| 104 | name="Unit Test Discovery", |
||
| 105 | platform="orion", |
||
| 106 | poller="primary", |
||
| 107 | snmp_communities=["public"], |
||
| 108 | nodes=nodes, |
||
| 109 | subnets=subnets, |
||
| 110 | ip_ranges=ip_ranges, |
||
| 111 | no_icmp_only=True, |
||
| 112 | auto_import=False) |
||
| 113 | |||
| 114 | # nodes = 0, subnets = 1, ip_ranges = 1 |
||
| 115 | nodes = None |
||
| 116 | subnets = ["192.168.1.0/24"] |
||
| 117 | ip_ranges = ["192.168.1.1:192.168.1.10"] |
||
| 118 | |||
| 119 | self.assertRaises(ValueError, |
||
| 120 | action.run, |
||
| 121 | name="Unit Test Discovery", |
||
| 122 | platform="orion", |
||
| 123 | poller="primary", |
||
| 124 | snmp_communities=["public"], |
||
| 125 | nodes=nodes, |
||
| 126 | subnets=subnets, |
||
| 127 | ip_ranges=ip_ranges, |
||
| 128 | no_icmp_only=True, |
||
| 129 | auto_import=False) |
||
| 130 | |||
| 218 |