| Conditions | 11 |
| Total Lines | 18 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Complex classes like striped_words.checkio() 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 | VOWELS = "AEIOUY" |
||
| 19 | def checkio(text): |
||
| 20 | counter = 0 |
||
| 21 | for j in split_text(text): |
||
| 22 | not_striped = True |
||
| 23 | if len(j) == 1: |
||
| 24 | not_striped = False |
||
| 25 | for i in zip(j, j[1:]): |
||
| 26 | if (i[0] in VOWELS + CONSONANTS) and (i[1] in VOWELS + CONSONANTS): |
||
| 27 | if (i[0] in CONSONANTS and i[1] in CONSONANTS) or ( |
||
| 28 | i[1] in VOWELS and i[0] in VOWELS |
||
| 29 | ): |
||
| 30 | not_striped = False |
||
| 31 | break |
||
| 32 | else: |
||
| 33 | not_striped = False |
||
| 34 | if not_striped: |
||
| 35 | counter += 1 |
||
| 36 | return counter |
||
| 37 | |||
| 46 |