rapid7/metasploit-framework

View on GitHub
modules/auxiliary/crawler/msfcrawler.rb

Summary

Maintainability
D
2 days
Test Coverage

File msfcrawler.rb has 297 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'openssl'
require 'rinda/tuplespace'
require 'pathname'
require 'uri'

Severity: Minor
Found in modules/auxiliary/crawler/msfcrawler.rb - About 3 hrs to fix

    Method run has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def run
        i, a = 0, []
    
        self.ctarget = datastore['RHOSTS']
        self.cport = datastore['RPORT']
    Severity: Major
    Found in modules/auxiliary/crawler/msfcrawler.rb - About 2 hrs to fix

      Method run has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

        def run
          i, a = 0, []
      
          self.ctarget = datastore['RHOSTS']
          self.cport = datastore['RPORT']
      Severity: Minor
      Found in modules/auxiliary/crawler/msfcrawler.rb - 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

      Method urltohash has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def urltohash(m,url,basepath,dat)
      
            # m:   method
            # url: uri?[query]
            # basepath: base path/uri to determine absolute path when relative
      Severity: Minor
      Found in modules/auxiliary/crawler/msfcrawler.rb - About 1 hr to fix

        Method urltohash has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def urltohash(m,url,basepath,dat)
        
              # m:   method
              # url: uri?[query]
              # basepath: base path/uri to determine absolute path when relative
        Severity: Minor
        Found in modules/auxiliary/crawler/msfcrawler.rb - 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

        Method sendreq has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def sendreq(nclient,reqopts={})
        
            begin
              r = nclient.request_raw(reqopts)
              resp = nclient.send_recv(r, datastore['ReadTimeout'])
        Severity: Minor
        Found in modules/auxiliary/crawler/msfcrawler.rb - About 1 hr to fix

          Method sendreq has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def sendreq(nclient,reqopts={})
          
              begin
                r = nclient.request_raw(reqopts)
                resp = nclient.send_recv(r, datastore['ReadTimeout'])
          Severity: Minor
          Found in modules/auxiliary/crawler/msfcrawler.rb - 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

          Method insertnewpath has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def insertnewpath(hashreq)
          
              hashreq['uri'] = canonicalize(hashreq['uri'])
          
              if hashreq['rhost'] == datastore['RHOSTS'] and hashreq['rport'] == datastore['RPORT']
          Severity: Minor
          Found in modules/auxiliary/crawler/msfcrawler.rb - 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

          Method canonicalize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def canonicalize(uri)
          
              u = uri.kind_of?(URI) ? uri : URI.parse(uri.to_s)
              u.normalize!
              newpath = u.path
          Severity: Minor
          Found in modules/auxiliary/crawler/msfcrawler.rb - 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

          There are no issues that match your filters.

          Category
          Status