maestro-server/discovery-api

View on GitHub
app/tasks/scan.py

Summary

Maintainability
A
3 hrs
Test Coverage
F
28%

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

def task_scan(conn, conn_id, task, options, lasted=False, vars=[]):
    access = decodeConn(conn, conn_id, task)

    oVars = Normalize.optionsVarsNormalize(options['vars']),
    vars = sum(oVars, vars)
Severity: Minor
Found in app/tasks/scan.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 iterTranslate has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def iterTranslate(conn, conn_id, options, task, result, tlasted):
Severity: Minor
Found in app/tasks/scan.py - About 45 mins to fix

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

    def task_scan(conn, conn_id, task, options, lasted=False, vars=[]):
    Severity: Minor
    Found in app/tasks/scan.py - About 45 mins to fix

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

      def iterTranslate(conn, conn_id, options, task, result, tlasted):
          if isinstance(result, list):
              return task_translate.delay(conn, conn_id, options, task, result, tlasted)
      
          if isinstance(result, GeneratorType):
      Severity: Minor
      Found in app/tasks/scan.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

      Line too long (108 > 79 characters)
      Open

                  task_ws.apply_async((conn, conn_id, task, status), countdown=app.config['MAESTRO_COUNTDOWN_WS'])
      Severity: Minor
      Found in app/tasks/scan.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (90 > 79 characters)
      Open

              tlasted = lasted and Crawler.isLast()  # lasted of regions and lasted of scan iter
      Severity: Minor
      Found in app/tasks/scan.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (107 > 79 characters)
      Open

          if hasattr(result, '__iter__'):  # get chunk of iterator, transform to list and send for translate task
      Severity: Minor
      Found in app/tasks/scan.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (104 > 79 characters)
      Open

                  task_last.apply_async((conn, task, options), countdown=app.config['MAESTRO_COUNTDOWN_LAST'])
      Severity: Minor
      Found in app/tasks/scan.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (82 > 79 characters)
      Open

              return task_translate.delay(conn, conn_id, options, task, result, tlasted)
      Severity: Minor
      Found in app/tasks/scan.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (84 > 79 characters)
      Open

              key = iterTranslate(conn, conn_id, options, task, result['result'], tlasted)
      Severity: Minor
      Found in app/tasks/scan.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (90 > 79 characters)
      Open

              task_notification.delay(msg=str(error), conn_id=conn_id, task=task, status=status)
      Severity: Minor
      Found in app/tasks/scan.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Comparison to false should be 'if cond is false:' or 'if not cond:'
      Open

              if Crawler.isLast() == False:
      Severity: Minor
      Found in app/tasks/scan.py by pep8

      Comparison to singletons should use "is" or "is not".

      Comparisons to singletons like None should always be done
      with "is" or "is not", never the equality operators.
      
      Okay: if arg is not None:
      E711: if arg != None:
      E711: if None == arg:
      E712: if arg == True:
      E712: if False == arg:
      
      Also, beware of writing if x when you really mean if x is not None
      -- e.g. when testing whether a variable or argument that defaults to
      None was set to some other value.  The other value might have a type
      (such as a container) that could be false in a boolean context!

      Whitespace before ','
      Open

                  {'msg': str(error), 'name': error.__class__.__name__}
      Severity: Minor
      Found in app/tasks/scan.py by pep8

      Avoid extraneous whitespace.

      Avoid extraneous whitespace in these situations:
      - Immediately inside parentheses, brackets or braces.
      - Immediately before a comma, semicolon, or colon.
      
      Okay: spam(ham[1], {eggs: 2})
      E201: spam( ham[1], {eggs: 2})
      E201: spam(ham[ 1], {eggs: 2})
      E201: spam(ham[1], { eggs: 2})
      E202: spam(ham[1], {eggs: 2} )
      E202: spam(ham[1 ], {eggs: 2})
      E202: spam(ham[1], {eggs: 2 })
      
      E203: if x == 4: print x, y; x, y = y , x
      E203: if x == 4: print x, y ; x, y = y, x
      E203: if x == 4 : print x, y; x, y = y, x

      There are no issues that match your filters.

      Category
      Status