okfn-brasil/serenata-de-amor

View on GitHub
research/src/fetch_congressperson_details.py

Summary

Maintainability
A
25 mins
Test Coverage

Function get_civil_names has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def get_civil_names(self):
        congresspeople_ids = self.get_all_congresspeople_ids()
        for i, congress_id in enumerate(congresspeople_ids):
            if not np.math.isnan(float(congress_id)):
                percentage = (i / self.total * 100)
Severity: Minor
Found in research/src/fetch_congressperson_details.py - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Invalid escape sequence '\d'
Open

        date_regex = re.compile('\d{4}-\d{2}-\d{2}')

Invalid escape sequences are deprecated in Python 3.6.

Okay: regex = r'\.png$'
W605: regex = '\.png$'

Invalid escape sequence '\d'
Open

        date_regex = re.compile('\d{4}-\d{2}-\d{2}')

Invalid escape sequences are deprecated in Python 3.6.

Okay: regex = r'\.png$'
W605: regex = '\.png$'

Invalid escape sequence '\d'
Open

        date_regex = re.compile('\d{4}-\d{2}-\d{2}')

Invalid escape sequences are deprecated in Python 3.6.

Okay: regex = r'\.png$'
W605: regex = '\.png$'

Ambiguous variable name 'l'
Open

        dates = sorted(set([l[0] for l in matches if l]), reverse=True)

Never use the characters 'l', 'O', or 'I' as variable names.

In some fonts, these characters are indistinguishable from the
numerals one and zero. When tempted to use 'l', use 'L' instead.

Okay: L = 0
Okay: o = 123
Okay: i = 42
E741: l = 0
E741: O = 123
E741: I = 42

Variables can be bound in several other contexts, including class
and function definitions, 'global' and 'nonlocal' statements,
exception handlers, and 'with' and 'for' statements.
In addition, we have a special handling for function parameters.

Okay: except AttributeError as o:
Okay: with lock as L:
Okay: foo(l=12)
Okay: for a in foo(l=12):
E741: except AttributeError as O:
E741: with lock as l:
E741: global I
E741: nonlocal l
E741: def foo(l):
E741: def foo(l=12):
E741: l = foo(l=12)
E741: for l in range(10):
E742: class I(object):
E743: def l(x):

There are no issues that match your filters.

Category
Status