alumae/kaldi-gstreamer-server

View on GitHub

Showing 21 of 63 total issues

File worker.py has 369 lines of code (exceeds 250 allowed). Consider refactoring.
Open

__author__ = 'tanel'

import logging
import logging.config
import time
Severity: Minor
Found in kaldigstserver/worker.py - About 4 hrs to fix

    Function received_message has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def received_message(self, m):
            logger.debug("%s: Got message from server of type %s" % (self.request_id, str(type(m))))
            if self.state == self.__class__.STATE_CONNECTED:
                props = json.loads(str(m))
                content_type = props['content_type']
    Severity: Minor
    Found in kaldigstserver/worker.py - About 3 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

    File master_server.py has 290 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python
    #
    # Copyright 2013 Tanel Alumae
    
    """
    Severity: Minor
    Found in kaldigstserver/master_server.py - About 2 hrs to fix

      Function received_message has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def received_message(self, m):
              response = json.loads(str(m))
              #print >> sys.stderr, "RESPONSE:", response
              #print >> sys.stderr, "JSON was:", m
              if response['status'] == 0:
      Severity: Minor
      Found in kaldigstserver/client.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 __testDecoder has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __testDecoder(self):
              finished = [False]
      
      
      
      
      Severity: Minor
      Found in kaldigstserver/decoder_test.py - About 1 hr to fix

        Function create_pipeline has 44 lines of code (exceeds 25 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 kaldigstserver/decoder.py - About 1 hr to fix

          Function post_process_full has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def post_process_full(self, full_result):
                  if self.full_post_processor:
                      self.full_post_processor.stdin.write("%s\n\n" % json.dumps(full_result))
                      self.full_post_processor.stdin.flush()
                      lines = []
          Severity: Minor
          Found in kaldigstserver/worker.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 create_pipeline has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def create_pipeline(self, conf):
          
                  self.appsrc = Gst.ElementFactory.make("appsrc", "appsrc")
                  self.decodebin = Gst.ElementFactory.make("decodebin", "decodebin")
                  self.audioconvert = Gst.ElementFactory.make("audioconvert", "audioconvert")
          Severity: Minor
          Found in kaldigstserver/decoder2.py - About 1 hr to fix

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

                def send_event(self, event):
                    event_str = str(event)
                    if len(event_str) > 100:
                        event_str = event_str[:97] + "..."
                    logging.info("%s: Receiving event %s from worker" % (self.id, event_str))
            Severity: Minor
            Found in kaldigstserver/master_server.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 create_pipeline has a Cognitive Complexity of 12 (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")
                    self.audioconvert = Gst.ElementFactory.make("audioconvert", "audioconvert")
            Severity: Minor
            Found in kaldigstserver/decoder2.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 create_pipeline has a Cognitive Complexity of 10 (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 kaldigstserver/decoder.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 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self, audiofile, url, protocols=None, extensions=None, heartbeat_freq=None, byterate=32000,
            Severity: Major
            Found in kaldigstserver/client.py - About 1 hr to fix

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

                  def post_process(self, texts, blocking=False):
                      if self.post_processor:
                          logging.debug("%s: Waiting for postprocessor lock" % self.request_id)
                          if blocking:
                              timeout=None
              Severity: Minor
              Found in kaldigstserver/worker.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 finish_request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def finish_request(self):
                      if self.state == self.STATE_CONNECTED:
                          # connection closed when we are not doing anything
                          self.decoder_pipeline.finish_request()
                          self.state = self.STATE_FINISHED
              Severity: Minor
              Found in kaldigstserver/worker.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 as_props.get('type', "") == "string+gzip+base64":
                                          adaptation_state = zlib.decompress(base64.b64decode(as_props.get('value', '')))
                                          logger.info("%s: Setting adaptation state to user-provided value" % (self.request_id))
                                          self.decoder_pipeline.set_adaptation_state(adaptation_state)
                                      else:
              Severity: Major
              Found in kaldigstserver/worker.py - About 45 mins to fix

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

                    def _on_full_result(self, full_result_json):
                        try:
                            self._increment_num_processing(1)
                            
                            self.last_decoder_message = time.time()
                Severity: Minor
                Found in kaldigstserver/worker.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

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

                def main():
                    logging.basicConfig(level=logging.DEBUG, format="%(levelname)8s %(asctime)s %(message)s ")
                    logging.debug('Starting up worker')
                    parser = argparse.ArgumentParser(description='Worker for kaldigstserver')
                    parser.add_argument('-u', '--uri', default="ws://localhost:8888/worker/ws/speech", dest="uri", help="Server<-->worker websocket URI")
                Severity: Minor
                Found in kaldigstserver/worker.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 opened has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def opened(self):
                        #print "Socket opened!"
                        def send_data_to_ws():
                            if self.send_adaptation_state_filename is not None:
                                print >> sys.stderr, "Sending adaptation state from %s" % self.send_adaptation_state_filename
                Severity: Minor
                Found in kaldigstserver/client.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 __testDecoder has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __testDecoder(self):
                        finished = [False]
                
                
                
                
                Severity: Minor
                Found in kaldigstserver/decoder_test.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 guard_timeout has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def guard_timeout(self):
                        global SILENCE_TIMEOUT
                        while self.state in [self.STATE_EOS_RECEIVED, self.STATE_CONNECTED, self.STATE_INITIALIZED, self.STATE_PROCESSING]:
                            if time.time() - self.last_decoder_message > SILENCE_TIMEOUT:
                                logger.warning("%s: More than %d seconds from last decoder hypothesis update, cancelling" % (self.request_id, SILENCE_TIMEOUT))
                Severity: Minor
                Found in kaldigstserver/worker.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