DragonComputer/Dragonfire

View on GitHub

Showing 61 of 61 total issues

Function _createBatch has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def _createBatch(self, samples):
        """Create a single batch from the list of sample. The batch size is automatically defined by the number of
        samples given.
        The inputs should already be inverted. The target should already have <go> and <eos>
        Warning: This function should not make direct calls to args.batchSize !!!
Severity: Minor
Found in dragonfire/deepconv/textdata.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 loadCorpus has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def loadCorpus(self):
        """Load/create the conversations data
        """
        datasetExist = os.path.isfile(self.filteredSamplesPath)
        if not datasetExist:  # First time we load the database: creating all files
Severity: Minor
Found in dragonfire/deepconv/textdata.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 __init__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, dirName):
        """
        Args:
            dirName (string): directory where to load the corpus
        """
Severity: Minor
Found in dragonfire/deepconv/corpus/ubuntudata.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 execute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def execute(self, cmd="", msg="", speak=False, duration=0):
        """Method to execute the given bash command and display a desktop environment independent notification.

        Keyword Args:
            cmd (str):          Bash command.
Severity: Minor
Found in dragonfire/utilities.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 buildNetwork has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def buildNetwork(self):
        """ Create the computational graph
        """

        # TODO: Create name_scopes (for better graph visualisation)
Severity: Minor
Found in dragonfire/deepconv/model.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 async_performer has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def async_performer(self, thread_number, samples, results, s_print):
        s_print('\nThead {0} is started.\n'.format(thread_number + 1))
        from termcolor import colored

        correct_counter = 0
Severity: Minor
Found in dragonfire/odqa.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 extract has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def extract(self, sentence):
        """Extract the main topics from the sentence.

        Returns:
            (list) of (str)s:  List of strings.
Severity: Minor
Found in dragonfire/nlplib.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 predictTestset has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def predictTestset(self, sess):
        """ Try predicting the sentences from the samples.txt file.
        The sentences are saved on the modelDir under the same name
        Args:
            sess: The current running session
Severity: Minor
Found in dragonfire/deepconv/__init__.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

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

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

        def loadConversations(self, dirName):
            """
            Args:
                dirName (str): folder to load
            Return:
    Severity: Minor
    Found in dragonfire/deepconv/corpus/opensubsdata.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 (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

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

          def get_config(self, key):
              config = {}
              config['model'] = "/usr/share/dragonfire/deepspeech/models/output_graph.pb"
              config['alphabet'] = "/usr/share/dragonfire/deepspeech/models/alphabet.txt"
              config['lm'] = "/usr/share/dragonfire/deepspeech/models/lm.binary"
      Severity: Minor
      Found in dragonfire/sr/deepspeech/config.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

      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

                                if reduction < 1:
                                    reduction = None
                                text = text[:reduction] + " " + cmd[1]
        Severity: Major
        Found in dragonfire/utilities.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if not first_clause:  # if the first verbtense assignment does not made yet
                                      answer += ' ' + clause  # concatenate with a whitespace
                                      first_clause = True
                                  else:
                                      answer += ' and ' + clause  # otherwise concatenate with ' AND '
          Severity: Major
          Found in dragonfire/learn.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

              Avoid deeply nested control flow statements.
              Open

                                      if img_url:
                                          response = urllib.request.urlopen(img_url)
                                          img_data = response.read()
                                          img_extension = mimetypes.guess_extension(response.headers['content-type'])
                                          filename = "/tmp/tmp" + uuid.uuid4().hex + img_extension
              Severity: Major
              Found in dragonfire/utilities.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 right"
                  Severity: Major
                  Found in dragonfire/__init__.py - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language