Completed
Pull Request — master (#2304)
by Arma
07:07
created

st2reactor.rules.ProcessSensorContainer   B

Complexity

Total Complexity 47

Size/Duplication

Total Lines 378
Duplicated Lines 0 %
Metric Value
wmc 47
dl 0
loc 378
rs 8.439

17 Methods

Rating   Name   Duplication   Size   Complexity  
A _get_sensor_id() 0 8 1
B _stop_sensor_process() 0 38 4
A _dispatch_trigger_for_sensor_exit() 0 11 1
B run() 0 29 5
A running() 0 2 1
A add_sensor() 0 16 2
A remove_sensor() 0 15 2
B __init__() 0 36 3
A stopped() 0 2 1
A _dispatch_trigger_for_sensor_spawn() 0 12 1
B _poll_sensors_for_results() 0 33 5
A _delete_sensor() 0 7 3
A _run_all_sensors() 0 17 3
B _spawn_sensor_process() 0 69 5
A shutdown() 0 17 3
B _respawn_sensor() 0 30 4
A _should_respawn_sensor() 0 14 3

How to fix   Complexity   

Complex Class

Complex classes like st2reactor.rules.ProcessSensorContainer often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
__author__ = 'manas'
2