DragonComputer/Dragonfire

View on GitHub

Showing 61 of 61 total issues

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 word.pos_ != 'PUNCT':  # exclude punctuations
                                clause.append(word.text)
                        if word.pos_ == 'VERB' and word.is_stop and not verb_found:  # if that's a verb and verb does not found yet then
    Severity: Major
    Found in dragonfire/learn.py - About 45 mins to fix

      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 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

            Function mainTestInteractive has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def mainTestInteractive(self, sess):
                    """ Try predicting the sentences that the user will enter in the console
                    Args:
                        sess: The current running session
                    """
            Severity: Minor
            Found in dragonfire/deepconv/__init__.py - About 45 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

            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

              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 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_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

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

                          def sequence2str(self, sequence, clean=False, reverse=False):
                              """Convert a list of integer into a human readable string
                              Args:
                                  sequence (list<int>): the sentence to print
                                  clean (Bool): if set, remove the <go>, <pad> and <eos> tokens
                      Severity: Minor
                      Found in dragonfire/deepconv/textdata.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 check_how_odqa_performs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def check_how_odqa_performs(self):
                              import json
                              import urllib.request
                              import random
                              import multiprocessing
                      Severity: Minor
                      Found in dragonfire/odqa.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 normalize_tags has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def normalize_tags(self, tagged):
                              """Normalize brown corpus' tags `("NN", "NN-PL", "NNS" -> "NN")`.
                      
                              Args:
                                  tagged ((list) of (str)s):  Tagged words.
                      Severity: Minor
                      Found in dragonfire/nlplib.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 db_upsert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def db_upsert(self, subject, verbtense, clause, com, is_public=True, user_id=None):
                              """Function to insert(or update) a record to the database.
                      
                              Args:
                                  subject (str):      Subject that extracted from the user's input/command.
                      Severity: Minor
                      Found in dragonfire/learn.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 pretty_print_nlp_parsing_results has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def pretty_print_nlp_parsing_results(self, doc):
                              """Method to print the nlp parsing results in a pretty way.
                      
                              Args:
                                  doc:  A :class:`Doc` instance from :mod:`spacy` library.
                      Severity: Minor
                      Found in dragonfire/utilities.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

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

                          def loadModelParams(self):
                              """ Load the some values associated with the current model, like the current globStep value
                              For now, this function does not need to be called before loading the model (no parameters restored). However,
                              the modelDir name will be initialized here so it is required to call this function before managePreviousModel(),
                              _getModelName() or _getSummaryName()
                      Severity: Minor
                      Found in dragonfire/deepconv/__init__.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

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

                          def create_pipeline(self, conf):
                      
                              self.appsrc = Gst.ElementFactory.make("appsrc", "appsrc")
                      
                              self.decodebin = Gst.ElementFactory.make("decodebin", "decodebin")
                      Severity: Minor
                      Found in dragonfire/sr/decoder.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

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

                          def extractConversation(self, conversation):
                              """Extract the sample lines from the conversations
                              Args:
                                  conversation (Obj): a conversation object containing the lines to extract
                              """
                      Severity: Minor
                      Found in dragonfire/deepconv/textdata.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

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

                          def resolve_api(self, com, previous=None):
                              if not previous:
                                  return com
                              com_doc = self.nlp(com)
                              n_sents = sum(1 for sent in com_doc.sents)
                      Severity: Minor
                      Found in dragonfire/coref.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