DragonComputer/Dragonfire

View on GitHub
dragonfire/__init__.py

Summary

Maintainability
F
6 days
Test Coverage

Function command has a Cognitive Complexity of 249 (exceeds 5 allowed). Consider refactoring.
Open

    def command(self, com):
        """Function that serves as the entry point for each one of the user commands.

        This function goes through these steps for each one of user's commands, respectively:

Severity: Minor
Found in dragonfire/__init__.py - About 5 days 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 start has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def start(args, userin):
    """Function that starts the virtual assistant with the correct mode according to command-line arguments.

    Args:
        args:       Command-line arguments.
Severity: Minor
Found in dragonfire/__init__.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

Consider simplifying this complex logical expression.
Open

                        if not (token.lemma_ == "search" or token.lemma_ == "find" or token.lemma_ == "Google" or token.lemma_ == "web" or token.lemma_ == "internet" or token.lemma_ == "image" or token.is_stop):
                            search_query += ' ' + token.text
                    search_query = search_query.strip()
Severity: Major
Found in dragonfire/__init__.py - About 1 hr to fix

    Function greet has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def greet(userin):
        """The top-level method to greet the user with message like "*Good morning, sir.*".
    
        Args:
            userin:  :class:`dragonfire.utilities.TextToAction` instance.
    Severity: Minor
    Found in dragonfire/__init__.py - About 55 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

    Avoid deeply nested control flow statements.
    Open

                            if not self.testing:
                                m.scroll(5, 0)
                    return "swipe up"
    Severity: Major
    Found in dragonfire/__init__.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if not (token.lemma_ == "search" or token.lemma_ == "find" or token.lemma_ == "Google" or token.lemma_ == "web" or token.lemma_ == "internet" or token.lemma_ == "image" or token.is_stop):
                                  search_query += ' ' + token.text
                          search_query = search_query.strip()
      Severity: Major
      Found in dragonfire/__init__.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if not self.testing:
                                    m.scroll(0, -5)
                        return "swipe left"
        Severity: Major
        Found in dragonfire/__init__.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if not self.testing:
                                      m.scroll(-5, 0)
                          return "swipe down"
          Severity: Major
          Found in dragonfire/__init__.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if not (token.lemma_ == "search" or token.lemma_ == "find" or token.lemma_ == "Google" or token.lemma_ == "web" or token.lemma_ == "internet" or token.is_stop):
                                        search_query += ' ' + token.text
                                search_query = search_query.strip()
            Severity: Major
            Found in dragonfire/__init__.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if not self.testing:
                                          m.scroll(0, 5)
                              return "swipe right"
              Severity: Major
              Found in dragonfire/__init__.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if len(info['entries']) > 0:
                                            youtube_title = info['entries'][0]['title']
                                            youtube_url = "https://www.youtube.com/watch?v=%s" % (info['entries'][0]['id'])
                                            userin.execute(["sensible-browser", youtube_url], youtube_title)
                                            youtube_title = TextToAction.fix_the_encoding_in_text_for_tts(youtube_title)
                Severity: Major
                Found in dragonfire/__init__.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if not args["server"] and not self.testing:
                                              time.sleep(5)
                                              k.tap_key(k.tab_key)
                                              k.tap_key(k.tab_key)
                                              k.tap_key(k.tab_key)
                  Severity: Major
                  Found in dragonfire/__init__.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            for character in com[n:]:
                                                k.tap_key(character)
                                            k.tap_key(" ")
                    Severity: Major
                    Found in dragonfire/__init__.py - About 45 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                                              if not (token.lemma_ == "search" or token.lemma_ == "find" or token.lemma_ == "Google" or token.lemma_ == "web" or token.lemma_ == "internet" or token.is_stop):
                                                  search_query += ' ' + token.text
                                          search_query = search_query.strip()
                      Severity: Major
                      Found in dragonfire/__init__.py - About 40 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                                if ((h.check_text("shut") and h.check_text("down")) or (h.check_text("power") and h.check_text("off"))) and h.check_text("computer") and not args["server"]:
                                    return userin.execute(["sudo", "poweroff"], "Shutting down", True, 3)
                                # Input: GOODBYE | BYE BYE | SEE YOU LATER
                                if h.check_nth_lemma(0, "goodbye") or h.check_nth_lemma(0, "bye") or (h.check_verb_lemma("see") and h.check_text("you") and h.check_adv_lemma("later")):
                        Severity: Major
                        Found in dragonfire/__init__.py - About 40 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                  if (h.check_lemma("search") or h.check_lemma("find")) and (h.check_lemma("Google") or h.check_lemma("web") or h.check_lemma("internet")) and h.check_lemma("image"):
                                      with nostdout():
                                          with nostderr():
                                              search_query = ""
                                              for token in doc:
                          Severity: Major
                          Found in dragonfire/__init__.py - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                        if com.startswith("FIRST") or com.startswith("THE FIRST") or com.startswith("SECOND") or com.startswith("THE SECOND") or com.startswith("THIRD") or com.startswith("THE THIRD"):
                                            user_answering['status'] = False
                                            selection = None
                                            if com.startswith("FIRST") or com.startswith("THE FIRST"):
                                                selection = 0
                            Severity: Major
                            Found in dragonfire/__init__.py - About 40 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                      if (h.check_lemma("search") or h.check_lemma("find")) and (h.check_lemma("Google") or h.check_lemma("web") or h.check_lemma("internet")) and not h.check_lemma("image"):
                                          with nostdout():
                                              with nostderr():
                                                  search_query = ""
                                                  for token in doc:
                              Severity: Major
                              Found in dragonfire/__init__.py - About 40 mins to fix

                                There are no issues that match your filters.

                                Category
                                Status