etlt.cleaner.WhitespaceCleaner   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 24
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A WhitespaceCleaner.clean() 0 14 2
1
from typing import Optional
2
3
4
class WhitespaceCleaner:
5
    """
6
    Utility class for cleaning whitespace from strings.
7
    """
8
9
    # ------------------------------------------------------------------------------------------------------------------
10
    @staticmethod
11
    def clean(string: Optional[str]) -> Optional[str]:
12
        """
13
        Prunes whitespace from a string.
14
15
        :param str string: The string.
16
17
        :rtype: str
18
        """
19
        # Return empty input immediately.
20
        if not string:
21
            return string
22
23
        return string.replace('  ', ' ').strip()
24
25
# ----------------------------------------------------------------------------------------------------------------------
26