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:
- Read upRead up
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.
- Read upRead up
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()
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.
- Read upRead up
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"
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()
Avoid deeply nested control flow statements. Open
if not self.testing:
m.scroll(0, -5)
return "swipe left"
Avoid deeply nested control flow statements. Open
if not self.testing:
m.scroll(-5, 0)
return "swipe down"
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()
Avoid deeply nested control flow statements. Open
if not self.testing:
m.scroll(0, 5)
return "swipe right"
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)
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)
Avoid deeply nested control flow statements. Open
for character in com[n:]:
k.tap_key(character)
k.tap_key(" ")
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()
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")):
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:
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
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: