GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Failed Conditions
Pull Request — master (#17)
by Yngve
02:15
created

paytext.paytext.PaymentText.clean()   C

Complexity

Conditions 10

Size

Total Lines 50
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 33
dl 0
loc 50
rs 5.9999
c 0
b 0
f 0
cc 10
nop 1

How to fix   Complexity   

Complexity

Complex classes like paytext.paytext.PaymentText.clean() 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
# pyre-strict
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
from re import compile as compile_regex
4
from typing import List, Any
5
6
import iso4217parse
7
8
9
class PaymentText:
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
10
    text: str = ''
11
12
    def __init__(self, text: str) -> None:
13
        self.text = text
14
15
    def __repr__(self) -> str:
16
        return self.text
17
18
    def clean(self) -> None:
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
19
        parts: List[str] = self.text.split()
20
21
        pattern = compile_regex(r'\*\d{4}')
22
23
        try:
24
            if pattern.match(parts[0]):
1 ignored issue
show
Comprehensibility Best Practice introduced by
The variable parts does not seem to be defined.
Loading history...
25
                del parts[0]
26
        except IndexError:
27
            return
28
29
        pattern = compile_regex(r'\d{2}\.\d{2}')
30
31
        if pattern.match(parts[0]):
32
            del parts[0]
33
34
        currency: Any = iso4217parse.by_alpha3(parts[0])
35
36
        if isinstance(currency, iso4217parse.Currency):
1 ignored issue
show
Comprehensibility Best Practice introduced by
The variable currency does not seem to be defined.
Loading history...
37
            del parts[0]
38
            del parts[0]
39
40
        pattern = compile_regex(r'\d{1}\.\d{4}')
41
42
        if pattern.match(parts[-1]):
43
            del parts[-1]
44
            del parts[-1]
45
46
        pattern = compile_regex(r'\d{2}\.\d{2}\.\d{2}')
47
48
        if pattern.match(parts[-1]):
49
            del parts[-1]
50
51
            pattern = compile_regex(r'.+:')
52
53
            if pattern.match(parts[-1]):
54
                del parts[-1]
55
56
        pattern = compile_regex(r'\d+,\d{2}')
57
58
        if pattern.match(parts[-1]):
59
            del parts[-1]
60
61
            currency: Any = iso4217parse.by_alpha3(parts[-1])
62
            if isinstance(currency, iso4217parse.Currency):
63
                del parts[-1]
64
65
        text = ' '.join(parts)
66
67
        self.text = text
68