WtfJoke/kult-lunchbot

View on GitHub

Showing 5 of 80 total issues

Function analyze has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def analyze(self):
        for trigger in self.TRIGGERS:
            if self.trigger_word(trigger):
                self.triggers = True
                break
Severity: Minor
Found in menu/lunchmenu.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 slack_event_handler has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def slack_event_handler(event_type, slack_event):
    """
    A helper function that routes events from Slack to our Bot
    by event type and subtype.

Severity: Minor
Found in application.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

Function fill_menu_item has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Confirmed

    def fill_menu_item(positioned_text, text_lines, menu_item):
        current_positioned_text = positioned_text
        # not menu and not begins line with monday-friday:
        while "Menü" not in current_positioned_text.text and not \
                KultTexTractor.is_week_day(current_positioned_text.text):
Severity: Minor
Found in menu/kult_textractor.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

Function action_selected_menu_number has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def action_selected_menu_number(self):
        menu_numbers = self.request_result["parameters"]["number"]
        daily_menu = self.kult_menu.get_daily_menu_by_date(datetime.date.today().strftime(DateFormats.COMMON))
        menu_texts = []
        if not menu_numbers:  # empty string means all menus
Severity: Minor
Found in googleaction.py - About 35 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

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

def extract_menu_card_link():
    logging.info("Crawl pdf")
    page = open_url(URL)
    soup = BeautifulSoup(page, "html.parser", parse_only=SoupStrainer('a'))  # parse only links
    menu_card_link = None
Severity: Minor
Found in scraper.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

Severity
Category
Status
Source
Language