schwehr/libais

View on GitHub

Showing 48 of 169 total issues

Function DictDiff has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def DictDiff(a, b):
  """Compares two dictionaries. Intended to be used in a test to
  compare the actual return value from some function with a
  known-good value.

Severity: Minor
Found in test/testutils.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 parseTagBlock has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def parseTagBlock(line):
  if not line.startswith("\\"):
    return {}, line
  tagblock, line = line[1:].split("\\", 1)
  tagblock, checksum = tagblock.rsplit("*", 1)
Severity: Minor
Found in ais/stream/__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

Function normalize has 12 arguments (exceeds 4 allowed). Consider refactoring.
Open

def normalize(nmea=sys.stdin,
Severity: Major
Found in ais/stream/__init__.py - About 1 hr to fix

    Function testManySingleLineVdms has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def testManySingleLineVdms(self):
        # Pass a series of independent one line messages through a queue.
        # All of these lines should be decoded.  The only interaction
        # between messages is that the line number is incremented.
        # Only do spot checks on the results.
    Severity: Minor
    Found in test/vdm_test.py - About 1 hr to fix

      Function put has 26 lines of code (exceeds 25 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 1 hr to fix

        Function ErrorPrinter has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def ErrorPrinter(e,
        Severity: Minor
        Found in ais/stream/__init__.py - About 45 mins to fix

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

          def decode(nmea=sys.stdin,
                     errorcb=ErrorPrinter,
                     keep_nmea=False,
                     stats=None,
                     **kw):
          Severity: Minor
          Found in ais/stream/__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

          Avoid deeply nested control flow statements.
          Open

                              if err is not None:
                                  sys.stdout.write("Field `%s' failed: %s" % (field, json.dumps(msg) + os.linesep))
                              return_val = False
          Severity: Major
          Found in utils/benthos_validate.py - About 45 mins to fix

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

              def put(self, line, line_num=None):
                """Add a line to the queue.
            
                Args:
                  line: str, Text to add to the queue.
            Severity: Minor
            Found in ais/nmea_queue.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 decode has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def decode(nmea=sys.stdin,
            Severity: Minor
            Found in ais/stream/__init__.py - About 35 mins to fix

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

              def HandleGga(line):
                try:
                  fields = GGA_RE.match(line).groupdict()
                except TypeError:
                  return
              Severity: Minor
              Found in ais/nmea_messages.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 open has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def open(name, mode='r', **kwargs):
                """Open a file containing NMEA and instantiate an instance of `NmeaFile()`.
                Like Python's `open()`, set the `mode` parameter to 'r' for normal reading or
                or 'rU' for opening the file in universal newline mode.
              
              
              Severity: Minor
              Found in ais/io.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 mangle__eta_day has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def mangle__eta_day(self, res, msg):
                  if msg['eta_month'] < 1 or msg['eta_day'] == 0 or msg['eta_hour'] == 24:
                    return
                  if msg['eta_minute'] == 60:
                    return
              Severity: Minor
              Found in ais/compatibility/gpsd.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 LineType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def LineType(line):
                """Give the type of NMEA line this is.
              
                Args:
                  line: str, Text to try to interpret.
              Severity: Minor
              Found in ais/nmea.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

              Avoid too many return statements within this function.
              Open

                      return
              Severity: Major
              Found in ais/uscg.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return
                Severity: Major
                Found in ais/vdm.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return
                  Severity: Major
                  Found in ais/vdm.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                      return TEXT
                    Severity: Major
                    Found in ais/nmea.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return
                      Severity: Major
                      Found in ais/uscg.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return
                        Severity: Major
                        Found in ais/tag_block.py - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language