schwehr/libais

View on GitHub

Showing 48 of 169 total issues

File test_data.py has 763 lines of code (exceeds 250 allowed). Consider refactoring.
Open

top_level = [
  {
    'nmea': [ '!AIVDM,1,1,,B,181:Kjh01ewHFRPDK1s3IRcn06sd,0*08,raishub,1342569600' ],
    'result': {'cog': 87.0,
             'id': 1,
Severity: Major
Found in test/test_data.py - About 1 day to fix

    Function normalize has a Cognitive Complexity of 84 (exceeds 5 allowed). Consider refactoring.
    Open

    def normalize(nmea=sys.stdin,
                  uscg=True,
                  validate_checksum=True,
                  allow_unknown=False,
                  window=2,
    Severity: Minor
    Found in ais/stream/__init__.py - About 1 day 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

    Mangler has 88 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Mangler(object):
      """Convert libais dictionaries to gpsd dictionaries."""
    
      def __init__(self, copy_tagblock_timestamp=True):
        self.copy_tagblock_timestamp = copy_tagblock_timestamp
    Severity: Major
    Found in ais/compatibility/gpsd.py - About 1 day to fix

      File gpsd.py has 447 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """Convert libais message dictionaries to GPSD JSON."""
      
      import datetime
      
      
      
      Severity: Minor
      Found in ais/compatibility/gpsd.py - About 6 hrs to fix

        File uscg_test.py has 420 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """Tests for ais.uscg."""
        
        import unittest
        
        from ais import uscg
        Severity: Minor
        Found in test/uscg_test.py - About 6 hrs to fix

          File vdm_test.py has 419 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          #!/usr/bin/env python
          
          """Tests for ais.vdm."""
          
          import unittest
          Severity: Minor
          Found in test/vdm_test.py - About 6 hrs to fix

            File nmea_messages_test.py has 374 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            """Tests for ais.nmea_messages."""
            
            import datetime
            import unittest
            
            
            Severity: Minor
            Found in test/nmea_messages_test.py - About 5 hrs to fix

              File nmea_messages.py has 367 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              """Parse non-AIS NMEA messages.
              
              National Marine Electronics Association (NMEA) messages are comma separated
              value lines of text that start with sender or "talker" code and the sentence
              type.  They finish up with a checksum.  For example, this is a time message
              Severity: Minor
              Found in ais/nmea_messages.py - About 4 hrs to fix

                File tag_block_test.py has 366 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                #!/usr/bin/env python
                """Tests for ais.tag_block."""
                
                import unittest
                
                
                Severity: Minor
                Found in test/tag_block_test.py - About 4 hrs to fix

                  File benthos_validate.py has 333 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  #!/usr/bin/env python
                  
                  """
                  Validator to ensure libais can produce Benthos's expected input
                  """
                  Severity: Minor
                  Found in utils/benthos_validate.py - About 4 hrs to fix

                    Function put has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def put(self, line, line_num=None):
                        if line_num is not None:
                          self.line_num = line_num
                        else:
                          self.line_num += 1
                    Severity: Minor
                    Found in ais/uscg.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 validate_file has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def validate_file(self, base):
                        nmea_name = os.path.join(self.dir, base + '.nmea')
                        json_name = os.path.join(self.dir, base + '.gpsdecode.json')
                    
                        subprocess.check_call('gpsdecode < %s > %s' % (nmea_name, json_name),
                    Severity: Minor
                    Found in test/compatibility/gpsd_test.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 validate_file has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def validate_file(self, base):
                        nmea_name = os.path.join(self.dir, base + '.nmea')
                        json_name = os.path.join(self.dir, base + '.json')
                    
                        def Json():
                    Severity: Minor
                    Found in test/compatibility/gpsd_test.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 validate_messages has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def validate_messages(messages, err=None):
                    
                        """
                        Determine whether or not an input message conforms to the Benthos spec.
                    
                    
                    Severity: Minor
                    Found in utils/benthos_validate.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

                    File __init__.py has 263 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    # Based on ais_normalize.py from https://github.com/schwehr/noaadata
                    
                    import sys
                    import traceback
                    import warnings
                    Severity: Minor
                    Found in ais/stream/__init__.py - About 2 hrs to fix

                      File nmea_queue_test.py has 261 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      """Tests for ais.nmea_queue."""
                      
                      import contextlib
                      import unittest
                      
                      
                      Severity: Minor
                      Found in test/nmea_queue_test.py - About 2 hrs to fix

                        Function put has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def put(self, line, line_num=None):
                            if line_num is not None:
                              self.line_num = line_num
                            else:
                              self.line_num += 1
                        Severity: Minor
                        Found in ais/tag_block.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 put has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def put(self, line, line_num=None):
                            """Add a line of NMEA or raw text to the queue."""
                        
                            if line_num is not None:
                              self.line_num = line_num
                        Severity: Minor
                        Found in ais/vdm.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 AddLine has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def AddLine(self, line):
                            print(line.rstrip())
                            self.counts['lines'] += 1
                            self.queue.put(line)
                            msg = self.queue.GetOrNone()
                        Severity: Minor
                        Found in ais/stats.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 mmsi_codes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def mmsi_codes(filename=None):
                            '''Create a table of 3 digit MMSI codes
                            @return: code lookup table
                            @rtype: dict
                            '''
                        Severity: Minor
                        Found in utils/maritime_id_codes.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

                        Severity
                        Category
                        Status
                        Source
                        Language