schwehr/libais

View on GitHub

Showing 169 of 169 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

      try:
        while True:
          gmsg = six.advance_iterator(g)
          amsg = six.advance_iterator(a)
          while amsg['type'] != gmsg['type']:
Severity: Major
Found in test/compatibility/gpsd_test.py and 1 other location - About 1 day to fix
test/compatibility/gpsd_test.py on lines 116..137

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 198.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    try:
      while True:
        gmsg = six.advance_iterator(g)
        amsg = six.advance_iterator(a)
        while amsg['type'] != gmsg['type']:
Severity: Major
Found in test/compatibility/gpsd_test.py and 1 other location - About 1 day to fix
test/compatibility/gpsd_test.py on lines 182..203

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 198.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        def testMiddleOfGroup(self):
          line = (r'\g:2-3-42349,n:111459*15\!AIVDM,2,2,5,A,P000,2*71')
          match = tag_block.TAG_BLOCK_RE.match(line).groupdict()
          match['group_id'] = int(match['group_id'])
          match['line_num'] = int(match['line_num'])
      Severity: Major
      Found in test/tag_block_test.py and 1 other location - About 1 day to fix
      test/tag_block_test.py on lines 170..189

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 177.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        def testEndOfGroup(self):
          line = (r'\g:3-3-42349,n:111460*1E\$'
                  'ARVSI,r003669945,5,201704.05687473,0152,-085,0*2E')
          match = tag_block.TAG_BLOCK_RE.match(line).groupdict()
          match['group_id'] = int(match['group_id'])
      Severity: Major
      Found in test/tag_block_test.py and 1 other location - About 1 day to fix
      test/tag_block_test.py on lines 150..168

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 177.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        def testPassThroughText(self):
          # Pass through anything that does not totally match a NMEA sentence.
          lines = (
              '',
              '\n',
      Severity: Major
      Found in test/vdm_test.py and 1 other location - About 1 day to fix
      test/uscg_test.py on lines 298..317

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 133.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        def testPassThroughText(self):
          lines = (
              '',
              '\n',
              ' \n',
      Severity: Major
      Found in test/uscg_test.py and 1 other location - About 1 day to fix
      test/vdm_test.py on lines 112..133

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 133.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        def testUscg(self):
          self.assertEqual(
              nmea.LineType('$PRDCB,CONRPT,1425514093,SLS_AIS,example.com,242,0,*1C'
                            ',bEXAMPLE,1370787180'),
              nmea.USCG)
      Severity: Major
      Found in test/nmea_test.py and 1 other location - About 1 day to fix
      test/nmea_test.py on lines 39..46

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 132.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        def testNone(self):
          self.assertEqual(nmea.LineType(''), nmea.TEXT)
          self.assertEqual(nmea.LineType('a'), nmea.TEXT)
          self.assertEqual(nmea.LineType('$'), nmea.TEXT)
          self.assertEqual(nmea.LineType('!'), nmea.TEXT)
      Severity: Major
      Found in test/nmea_test.py and 1 other location - About 1 day to fix
      test/nmea_test.py on lines 69..94

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 132.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      def DecodeMultiple(message):
        """Decode a message that spans multiple lines."""
        payloads = [msg['payload'] for msg in message['matches']]
      
        q = vdm.BareQueue()
      Severity: Major
      Found in ais/uscg.py and 1 other location - About 6 hrs to fix
      ais/tag_block.py on lines 213..225

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 107.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      def DecodeTagMultiple(tag_block_message):
        """Decode a TAG block message that spans multiple lines."""
        payloads = [msg['payload'] for msg in tag_block_message['matches']]
      
        q = vdm.BareQueue()
      Severity: Major
      Found in ais/tag_block.py and 1 other location - About 6 hrs to fix
      ais/uscg.py on lines 212..224

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 107.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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
                    Severity
                    Category
                    Status
                    Source
                    Language