| Conditions | 12 |
| Total Lines | 18 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Complex classes like prune_ReadingOrder.prune_ReadingOrder() 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 | def prune_ReadingOrder(self): |
||
| 2 | """ |
||
| 3 | Remove any empty ReadingOrder elements |
||
| 4 | """ |
||
| 5 | ro = self.get_Page().get_ReadingOrder() |
||
| 6 | if ro: |
||
| 7 | og = ro.get_OrderedGroup() |
||
| 8 | if og and (not og.get_RegionRefIndexed() and |
||
| 9 | not og.get_OrderedGroupIndexed() and |
||
| 10 | not og.get_UnorderedGroupIndexed()): |
||
| 11 | og = None |
||
| 12 | ug = ro.get_UnorderedGroup() |
||
| 13 | if ug and (not ug.get_RegionRef() and |
||
| 14 | not ug.get_OrderedGroup() and |
||
| 15 | not ug.get_UnorderedGroup()): |
||
| 16 | ug = None |
||
| 17 | if not og and not ug: |
||
| 18 | self.get_Page().set_ReadingOrder(None) |
||
| 19 |