StackStorm /
st2contrib
| Total Complexity | 66 |
| Total Lines | 294 |
| Duplicated Lines | 0 % |
| Metric | Value |
|---|---|
| dl | 0 |
| loc | 294 |
| rs | 3.1915 |
| wmc | 66 |
| Rating | Name | Duplication | Size | Complexity |
|---|---|---|---|---|
| A | _is_downtime_recovered() | 0 | 2 | 1 |
| A | _get_servers() | 0 | 11 | 3 |
| A | _is_escalated_downtime() | 0 | 2 | 1 |
| D | _app_hook_handler() | 0 | 34 | 8 |
| A | _get_sensor_config() | 0 | 3 | 1 |
| A | add_trigger() | 0 | 2 | 1 |
| A | _dispatch_trigger() | 0 | 3 | 1 |
| A | setup() | 0 | 2 | 1 |
| A | remove_trigger() | 0 | 2 | 1 |
| A | _is_alert_canceled() | 0 | 2 | 1 |
| A | __init__() | 0 | 16 | 1 |
| C | _dispatch_server_normal() | 0 | 27 | 7 |
| C | _server_hook_handler() | 0 | 25 | 7 |
| A | cleanup() | 0 | 2 | 1 |
| A | update_trigger() | 0 | 2 | 1 |
| F | run() | 0 | 57 | 12 |
| A | _dispatch_application_normal() | 0 | 19 | 4 |
| B | handle_nrhook() | 0 | 41 | 6 |
| A | _get_sensor_config_param() | 0 | 6 | 2 |
| A | _is_alert_closed() | 0 | 2 | 1 |
| A | _is_alert_opened() | 0 | 2 | 1 |
| A | _get_hook_handler() | 0 | 10 | 3 |
| A | _is_alert_acknowledged() | 0 | 2 | 1 |
| A | _get_application() | 0 | 10 | 4 |
| A | _get_headers_as_dict() | 0 | 6 | 2 |
Complex classes like NewRelicHookSensor 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.