rapid7/metasploit-framework

View on GitHub
lib/metasploit/framework/data_service/remote/http/core.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method build_client_pool has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def build_client_pool(size)
    @client_pool = Queue.new()
    (1..size).each {
      http = Net::HTTP.new(@endpoint.host, @endpoint.port)
      if @endpoint.is_a?(URI::HTTPS)
Severity: Minor
Found in lib/metasploit/framework/data_service/remote/http/core.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

Class RemoteHTTPDataService has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class RemoteHTTPDataService
  include Metasploit::Framework::DataService
  include DataServiceAutoLoader

  DEFAULT_USER_AGENT = "metasploit v#{Metasploit::Framework::VERSION}"
Severity: Minor
Found in lib/metasploit/framework/data_service/remote/http/core.rb - About 2 hrs to fix

    Method make_request has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def make_request(request_type, path, data_hash = nil, query = nil)
        begin
          # simplify query by removing nil values
          query_str = (!query.nil? && !query.empty?) ? query.compact.to_query : nil
          uri = URI::HTTP::build({path: path, query: query_str})
    Severity: Minor
    Found in lib/metasploit/framework/data_service/remote/http/core.rb - About 1 hr to fix

      Method make_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def make_request(request_type, path, data_hash = nil, query = nil)
          begin
            # simplify query by removing nil values
            query_str = (!query.nil? && !query.empty?) ? query.compact.to_query : nil
            uri = URI::HTTP::build({path: path, query: query_str})
      Severity: Minor
      Found in lib/metasploit/framework/data_service/remote/http/core.rb - About 25 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