rezometz/django-paiji2-mettis

View on GitHub

Showing 3 of 3 total issues

Function extract_schedule has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def extract_schedule(self, timetable):
        for row in timetable.findAll('tr'):
            cells = row.findAll('td')
            hour = cells[0].get_text().strip()
            hour = int(re.search('(\d+)', hour).group(0))
Severity: Minor
Found in paiji2_mettis/fetcher.py - About 2 hrs 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

Function find_next_stop has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def find_next_stop(self, from_time):
        if self.data is None or from_time is None:
            return None
        from_time = from_time.replace(minute=from_time.minute)
        weekday = from_time.weekday()
Severity: Minor
Found in paiji2_mettis/fetcher.py - About 1 hr 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

Avoid deeply nested control flow statements.
Open

                        for x in range(0, 60, 10):
                            yield {
                                'hour': hour,
                                'minutes': x,
                                'approximated': True,
Severity: Major
Found in paiji2_mettis/fetcher.py - About 45 mins to fix
    Severity
    Category
    Status
    Source
    Language